Skip to content
Limited timeStarter is now $9 a month instead of $20.See plans
charmotion

How to Preview MCP-Generated Rive Animations Before Committing .riv Files

By the Charmotion team · Updated · How we write guides

Cover illustration for the guide: How to Preview MCP-Generated Rive Animations Before Committing .riv Files, with Charmotion demo characters

Open each generated Rive animation as a .riv file in a local test page, check every state, mood value and data-bound property, and commit only after it plays correctly. Previewing before you commit catches broken states from an AI coding workflow early, while a fix is still one more tool call.

Key takeaways

  • Preview each generated .riv in a local test page before it reaches your repository.
  • Check state machine names, the mood number input and launch behavior against the file itself, not against memory.
  • Pin the runtime to the same version as the @rive-app package your app installs.
  • Test transparent video in Safari separately, because Safari has been reported to ignore WebM alpha.
  • Commit the .riv, its code and the README together once every check passes.

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.

Why preview a generated .riv file before you commit it?

The habit that matters most is simple: learn how to preview generated Rive animations in an AI coding workflow before committing, because a code diff shows what a file is called, not how it moves. A .riv file is a binary bundle of artboards, animations, state machines and data binding settings, so review tools cannot tell you whether the mascot still waves when a request fails.

Three problems show up often. A state machine input has a different name than the code expects, so setting it does nothing. A mood number maps to the wrong animation. Or the file plays in the editor but fails in the browser because the runtime version does not match your app. Each is cheap to catch before the file reaches the repository and expensive after a release.

The preview is also the moment to check the license tier. Rive's pricing page lists a free tier and paid plans (as of December 2026). Exported files on the free tier play a Rive splash screen, while paid plans export without it. Read Is Rive free? before you ship a file made on the free tier.

What should you check in a generated Rive file?

Open the file and write down what the code expects. For a Charmotion character, the .riv file contains CharacterViewModelMachine with a number property named mood, CharacterStateMachine with a number input named mood, and 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 and attention 9. Moods blend into each other, so a jump from 0 to 9 animates through the states in between.

Then test each row of this table against the actual file:

ItemWhat to confirmPass condition
State machine namesThe names in code match the fileThe runtime finds each machine without errors
Mood inputA number input named mood exists in CharacterStateMachineValues 0 to 9 change the visible state
LaunchLaunchStateMachine plays onceIt ends on idle and does not restart
AccentsThe boolean accents hides the small marksMarks match your design, on or off
TransparencyThe figure sits over your page colorNo box or halo appears around it

Characters have no one-shot triggers, so code should set mood rather than fire a trigger. Show a success with happy and an error with sad. If an assistant writes a call to a trigger that does not exist, the preview shows nothing, which is why this check comes first.

How do you preview a .riv in a local test page?

A test page is the fastest honest preview. It runs the same web runtime your app uses, and Rive's runtimes are open source and play any .riv file, so a file that plays on the page is likely to play in production. Keep the page in a scratch folder outside your app so nothing lands in a commit by accident.

The example below loads a file from a local path, selects the state machine named in the file, finds the mood input and steps through the ten moods every 1.5 seconds.

<canvas id="mascot" width="400" height="400"></canvas>
<script type="module">
import { Rive } from "https://unpkg.com/@rive-app/canvas@2.47.1";

const r = new Rive({
  src: "/preview/character.riv",
  canvas: document.getElementById("mascot"),
  stateMachines: "CharacterStateMachine",
  autoplay: true,
  onLoad: () => {
    const mood = r.stateMachineInputs("CharacterStateMachine").find((i) => i.name === "mood");
    if (!mood) console.error("mood input not found");
    let n = 0;
    setInterval(() => { if (mood) mood.value = n; n = (n + 1) % 10; }, 1500);
  },
});
</script>

The console line is the first check. If it reports that the input was not found, the name in code does not match the file. Serve the folder with any static HTTP server and open it in each browser you support.

Rive's preloading docs say rive.wasm should be served with the application/wasm MIME type, otherwise the browser falls back to a slower path. They also say a self-hosted rive.wasm must match the @rive-app package version in package.json, because the two are built as a pair. By default the runtime loads its WASM file from unpkg. Self-hosting gives you control over the WASM origin, faster initialization and the caching policy for rive.wasm, which helps when the preview should match a production CDN setup.

For a look at the state machine before writing any code, the online viewer in How to preview a .riv file online is a quicker first step.

How do MCP tools fit into the preview step?

An MCP server lets an AI assistant call tools rather than write every file by hand. Charmotion's remote server, described on the MCP server page, is one example. It signs in with OAuth, so no API key goes into the repository. The assistant can design a character with design_character or work from your own image, create a set with the animations you choose through create_character_set, and read back download links and integration notes with get_character_set.

Disclosure: Charmotion is our product.

The preview belongs between get_character_set and your commit. Download the .riv and the video exports into a scratch folder, then run the checks above. The export_videos tool renders MP4 at 1080x1080 and 60 fps, GIF, transparent WebM, transparent MOV and a 9:16 launch MP4 in about a minute. Exports don't use credits, so you can regenerate them after every change. Use the MP4 and GIF to review motion in a pull request, and the transparent files to test the figure over a real page.

Connecting the server depends on your tool. Claude Code reads project servers from a .mcp.json file, as described in the Claude Code MCP docs. Cursor reads an mcp.json file, and VS Code's Copilot agent mode has its own MCP configuration. Codex CLI keeps servers in a config.toml file. Paths and sign-in steps change between versions, so copy configuration from each product's own page. The Model Context Protocol site covers the protocol itself.

If the source began as a flat PNG, PNG to Rive Animation explains how the file is built before any of these checks apply.

Can you automate the preview with Playwright or Storybook?

Manual checks catch most problems once. Automated checks catch them every time a file is regenerated. Two tools fit this workflow.

  • Storybook is a free, open source workshop for building and testing UI components in isolation. Give the mascot one story per state (idle, happy, wave, loading, sad) and a visual test per story, so a regenerated file that changes a state shows up as a diff.
  • Playwright drives Chromium, Firefox and WebKit through one API. Its config controls when screenshots and videos are captured, so a script can load the test page in all three engines, set the mood, and save a screenshot for comparison.

Use WebKit for the transparency check, because Safari is the browser most likely to differ. Chromium and Firefox display WebM alpha, while Safari has been reported to ignore it, so a transparent WebM can show a box there. Test the transparent MOV with HEVC alpha in Safari, and keep a fallback in your markup. The Chrome notes on alpha transparency describe the encoding side of the same problem.

For a fuller test setup that covers data binding in both tools, see Testing MCP-generated Rive data binding states in Storybook and Playwright.

What should block a commit?

Commit only when the file passes every check, and write down what blocks it. The table lists the failures that come up most often with generated Rive files and the fix for each.

SymptomLikely causeFix
Console says the state machine is not foundThe name in code differs from the fileUse the name in the file, or regenerate with the exact name
A mood does nothingThe input is missing or has the wrong typeConfirm a number input named mood exists and send values 0 to 9
Plays locally, fails on stagingRuntime and .riv versions differ, or rive.wasm is served with the wrong typePin @rive-app to the version in package.json and serve rive.wasm as application/wasm
A box or halo around the figureA transparent video is shown in a browser that ignores alphaUse WebM for Chromium and Firefox, and HEVC MOV for Safari
Launch repeatsCode restarts the launch machineLaunch plays once and ends on idle, so stop re-triggering it

Also confirm that the code sets mood rather than calling a trigger, since characters have none. When every row passes, commit the .riv, the code and the README together, so the next developer can see what each mood number means.

For SwiftUI projects, the same kind of file loads through Rive's Apple runtime. The steps are in How to use Rive in SwiftUI.

How to preview a generated Rive animation before committing the .riv file

  1. Generate and download the files. Run the MCP tools that create the character set, then download the .riv file and any video exports into a scratch folder outside the repository.
  2. Write down the expected names. Note the state machine names, the mood number input and the view model property that the code will use, and confirm they match the file.
  3. Build a local test page. Create a small page with the same @rive-app runtime version as your app, load the .riv from a local path and serve the folder over HTTP.
  4. Step through every mood. Set mood values 0 to 9 and confirm each state plays, launch ends on idle and accents behave as designed.
  5. Check transparency in each browser. Open the page in Chromium, Firefox and Safari, and test the transparent WebM and HEVC MOV for boxes or halos.
  6. Commit once every check passes. Move the .riv, the integration code and the README into the repository together, and leave the scratch exports out of the commit.

Frequently asked questions

Can I preview a generated .riv file without a paid Rive plan?

Yes, for testing. Rive's pricing page lists a free tier with an editor, and exported files on it play a Rive splash screen, which is acceptable on a test page. Paid plans export without the splash screen (as of December 2026). Check the current terms at /guides/is-rive-free-pricing before you ship a file made on the free tier.

Does a passing preview in Chrome mean the file works in Safari?

Not automatically. Chromium and Firefox display WebM alpha, while Safari has been reported to ignore it. Run a first pass in Playwright's WebKit engine, then check the transparent HEVC MOV on a real Safari on macOS or iOS before launch.

Which runtime version should the preview use?

Use the version your app installs. Rive's preloading docs say the rive.wasm version must match the @rive-app package version in package.json, because the two are built as a pair. Pin the same version in the test page, and update both together when you upgrade.

Should I commit the exported videos with the .riv file?

Usually not. Commit the .riv, its integration code and the README. Keep MP4, GIF and WebM exports in your review or asset storage. Exports don't use credits on Charmotion, so you can regenerate them whenever the character changes.

Sources

Related guides