Animating a Mascot During MCP Tool Calls and Multi-Step AI Reasoning
By the Charmotion team · Updated · How we write guides

Give the mascot one mood per stage of a multi-step AI run in your chat UI, driven by events your client already receives: listening while the message sends, thinking while the model reasons, loading while each MCP tool call runs, talking as the answer streams, and happy or sad when the run ends.
Key takeaways
- Tie each mascot mood to a stage of the agent run, not to a timer.
- Keep loading on while any MCP tool call is pending, even between reasoning steps.
- Set moods from stream events, and return to idle after the run finishes.
- Characters have no one-shot triggers, so show success with happy and errors with sad.
- Write the mood value from one function so the mapping is easy to test.
Already have a character or logo? See examples in real app screens: splash, onboarding, loading and empty-state screens, with the animation that plays in each.
What should a mascot show during an AI agent run?
An agent run is not one event. The user sends a message, the model reasons, one or more MCP tools run, and then the answer streams in. A mascot that plays one loop for all of that looks stuck. Map each stage to a mood and the character becomes a status signal the user can read at a glance.
| Run stage | Mood | Why |
|---|---|---|
| Message sent, waiting for the first event | listening (6) | The user has spoken and the agent has the turn |
| Model reasoning before text or a tool call | thinking (3) | Thinking dots show the model is working |
| MCP tool call running | loading (5) | A tool can take seconds, and loading matches a wait |
| Answer text streaming | talking (7) | The response is arriving |
| Run finished without error | happy (1), then idle (0) | Success is shown with happy |
| Tool or run failed | sad (4), then idle (0) | Errors are shown with sad |
| Agent waits for the user to approve a step | attention (9) | The exclamation mark accent asks for attention |
Six or seven moods cover most agent runs. Use the same mapping across the product so users learn what each state means.
How do you set up the mood numbers in the Rive file?
If your character comes from Charmotion, the Rive file already has the inputs. It holds a CharacterViewModelMachine with a number property named mood, a CharacterStateMachine with a number input named mood, and a LaunchStateMachine when launch was picked. The mood numbers are fixed: idle 0, happy 1, wave 2, thinking 3, sad 4, loading 5, listening 6, talking 7, sleeping 8, attention 9.
Moods blend into each other, so a change from thinking to loading moves smoothly rather than cutting. That suits chat, where the state can change several times in a second. The thinking loop runs 2.4 s and the loading loop runs 1.2 s, so loading reads as a quick wait without a separate animation for each tool.
Some moods carry small accents: Z z z while sleeping, thinking dots, an exclamation mark for attention and sparkles when happy. They are on by default. The boolean accents hides them, which helps when your interface already shows its own status text.
Pick one control path and write to it from one place. Two writers can set conflicting values. For the state-level details, see how to drive Rive character mood states from app state.
Which Claude streaming events mark the start and end of a run?
Setting stream to true on a Messages API request makes the response arrive as server-sent events. A streamed response begins with message_start, then content block events, then one or more message_delta events, and ends with message_stop. The message_start event carries a Message object with an empty content array, and stop_reason is null there. The value arrives in message_delta.
- message_start: the turn has begun. Keep the mood on thinking.
- Content block events: a tool-use block moves the mood to loading, and the first text chunk moves it to talking.
- message_delta: read stop_reason here. The token counts in the usage field are cumulative, so do not add them up per event.
- message_stop: this message is complete. In a multi-step run it may not end the whole task, so check whether a tool result is still owed.
The Python SDK exposes stream.text_stream and the TypeScript SDK exposes stream.textStream. Those helpers suit plain text, but a mascot needs the event order, so loop over the raw events. Check the streaming page for the full event list, including any ping or error events.
const stream = client.messages.stream({ model: 'YOUR_MODEL_ID', max_tokens: 1024, messages, tools });
setMood(3); // request sent, model reasoning
for await (const event of stream) {
if (event.type === 'message_start') setMood(3);
if (isToolUseStart(event)) { pending += 1; setMood(5); } // your helper checks the block type
if (isTextChunk(event)) setMood(7); // your helper checks for text
if (event.type === 'message_delta') stopReason = event.delta.stop_reason;
if (event.type === 'message_stop') { /* end of this message, see the loop below */ }
}How to animate a mascot during MCP tool calls and multi-step reasoning in an AI chat UI
In an MCP run, the model asks for a tool, the client calls the MCP server, the result goes back to the model, and the model may reason again or ask for another tool. The mascot should follow that loop rather than the single message. Track a count of pending tool calls and set the mood from the count and the current stage.
- When a tool-use block starts, add one to pending and set loading (5).
- When the tool result goes back to the model, subtract one from pending. If pending is 0, set thinking (3) because the model is reasoning on the result.
- If the model asks for another tool, set loading again. Between two tools the mood moves loading, thinking, loading.
- When text chunks start, set talking (7). If a later tool call starts, the mood returns to loading.
- When the whole run ends, set happy (1) for success, then return to idle (0) after a short pause.
Two details keep this stable. Write the mood only when it changes, so the mascot does not restart its loop on every event. And let the run end the mood, not the individual tool result, because the model may still reason after a result arrives.
Anthropic's fine-grained tool streaming adds an eager_input_streaming flag to a tool definition, which lets tool inputs stream without server-side JSON buffering. Your client then receives the tool input as it arrives, so the loading mood can start while a slow tool is still being described. If your agent runs in Claude Code, its MCP servers are declared in a JSON file described in the official docs. For a wider event map, see mapping coding agent tool-call events to animated mascot states.
How do Rive state machine inputs get set in web, Android and Flutter?
A Rive state machine input is a boolean, a number or a trigger. The mood is a number input, so the number path is the one that matters here. In the web runtime, you list a state machine's inputs with stateMachineInputs and the state machine name, find the input by its name, and set its value property.
const inputs = rive.stateMachineInputs('CharacterStateMachine');
const mood = inputs.find(i => i.name === 'mood');
function setMood(n) { if (mood && mood.value !== n) mood.value = n; }The Android runtime has a separate method for each input type, called through the view. In Flutter, you create a state machine controller from an artboard and a state machine name, then read the inputs from controller.stateMachine.inputs. Trigger inputs are fired by calling a method on them in the web runtime. A mood path only needs the number input, so triggers can stay unused.
The React runtime includes a useStateMachineInput hook, but Rive's React runtime page marks it deprecated in favor of newer data binding hooks. Check that page before you start a React build, and prefer data binding for new code.
How should the mascot handle errors, long waits and approvals?
Errors use sad, because characters have no error trigger. Set sad (4) when a tool call fails or the run stops with an error, hold it for a moment, then return to idle. Success uses happy (1), as the table in the first section shows.
Long waits need a rule. A tool call can take much longer than the 1.2 s loading loop, and users notice a mascot that seems to wait forever. After a few seconds without a tool result, name the tool in the text beside the mascot. Set a timeout that moves the run to sad if the client gives up. Also avoid changing mood on every network chunk. A change that lasts only a few hundred milliseconds looks like flicker, so wait briefly before switching.
When the agent needs the user to approve a step, set attention (9). Its exclamation mark accent draws the eye, so use it for one decision at a time. If the chat has been inactive for a long time, sleeping (8) shows that the agent is waiting for input, but keep it off during an active run.
Keep the mapping in one function that turns run state into a mood number. That is easier to test than moods set across many components. Feed it a fake event stream with a slow tool to check each transition.
How to animate a mascot during MCP tool calls and multi-step reasoning
- Set up the mood input. Open the character's Rive file and confirm the number input named mood on CharacterStateMachine, or the mood property on CharacterViewModelMachine. Choose one control path and write to it from one place.
- Map run stages to moods. Assign thinking (3) to the model reasoning, loading (5) to a running MCP tool call, talking (7) to streamed answer text, listening (6) to a sent message, and attention (9) to an approval request.
- Read the stream events. Set stream to true on the Messages API request and loop over the raw events. Use message_start to begin thinking, the content block events to detect tool use and text, and message_delta to read stop_reason.
- Track pending tool calls. Add one to a pending count when a tool call starts and subtract one when its result returns. Keep loading while pending is above 0, and use thinking when the model reasons on a result.
- Finish or fail the run. When the run ends without error, show happy (1) and return to idle (0) after a short pause. On a failed tool or run, show sad (4) and then return to idle.
- Write the mood only on change. Compare the new mood with the current value and set it only when different, so the state machine does not restart its loop on every stream event.
- Test with a slow tool. Feed the mapping function a fake event stream with a slow tool, an error and an approval request. Confirm each transition, then check the mascot in the real chat UI.
Frequently asked questions
Can the mascot show which MCP tool is running?
Not through the mood number. The mood input is one value from 0 to 9, so it signals a stage such as loading or thinking, not a tool name. Show the tool name as short text next to the mascot and let the character carry the state. Keep the label and the mood consistent so users read them together.
Do Charmotion characters support trigger inputs for success or error?
No. Charmotion characters have no one-shot triggers, such as success, error, yes, no, enter or exit. Show success with happy (1) and an error with sad (4), then return to idle (0). Rive's runtimes support trigger inputs in general, but Charmotion files do not expose them for characters.
Does Rive's free plan work for an AI chat mascot?
Rive's runtimes are open source and play any .riv file. On Rive's Free plan, exported files play a Rive splash screen, and paid plans export without it. Plan names and prices change, so check the current Rive pricing page before you ship. The breakdown is in is Rive free, pricing, plans and commercial use.
Sources
- Streaming Messages (Claude API), Anthropic
- Fine-grained tool streaming, Anthropic
- Rive state machines (runtime help), Rive
- Rive React runtime overview, Rive
- Connect MCP servers to Claude Code, Anthropic
- Charmotion MCP server, Charmotion