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

How to Inspect and Verify MCP-Generated Rive Data Binding ViewModels in Code

By the Charmotion team · Updated · How we write guides

Cover illustration for the guide: How to Inspect and Verify MCP-Generated Rive Data Binding ViewModels in Code, with Charmotion demo characters

Inspect a .riv file generated by an MCP server in the Rive editor or a file inspector to confirm its Data Binding ViewModel, property names, types and default instance. Then read the bound ViewModelInstance in app code, set each value your states need, and check results against the runtime version you ship. Test every state before release.

Key takeaways

  • Check the .riv file's ViewModel, property names, types and default instance before any app code depends on them.
  • Read bound values through the runtime's ViewModelInstance and treat a null instance as a failed load.
  • Match the runtime version to the file and to the binding calls your code uses.
  • Run a read-back test for every state after each MCP regeneration and runtime upgrade.

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 does an MCP server generate for Rive data binding?

An MCP server that builds a Rive character or component can also write the data binding your app reads. That binding is a ViewModel: typed properties defined inside the Rive file, plus ViewModelInstances that hold the live values those properties take while the animation runs. This guide covers how to inspect and verify Rive Data Binding ViewModels generated by an MCP server before your code depends on them.

Rive View Model properties can be Number, String, Boolean, Color, Enum, Trigger, Image, nested View Model or List. Each type fails in a different way, so each needs its own check.

Property typeWhat to check
NumberThe range your states use, for example 0 to 9 for a mood value
StringExact text, including the empty string your UI may send
BooleanThe default value and the flag your UI reads
ColorThe hex value against your brand palette
EnumThe allowed values and their order
TriggerThat your code fires it and the state it drives responds
ImageThat the asset resolves in your app build
Nested View ModelThe path to the child instance
ListThe item count and the item type

Names matter most. A renamed property can fail silently: the file loads, the animation plays, and nothing reacts to your code. Compare every name in the file with every name in the code before you write logic on top of it.

How do you inspect a generated .riv file before using it?

Start with the file, not the app. Load the .riv in the Rive file inspector on this site, or open it in the Rive editor, and write down what it contains. You are looking for five things.

  1. The ViewModel name and its path, including any nested View Models.
  2. Each property name, its type and its default value.
  3. The default instance, and whether the file binds it without extra code.
  4. The state machine names your code will load, such as CharacterStateMachine.
  5. Any list or image properties, which need the most care because they depend on the runtime version.

Charmotion character files are a concrete case. Each one has a CharacterViewModelMachine with a number property named mood, a CharacterStateMachine with a number input named mood, and a boolean named accents that hides the small accents when false. 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. A file that renames or retypes mood fails this table, so you can reject it in one minute. The same method works for any MCP-generated file: write the expected table first, then compare the file to it. For a fuller walk through preview tools, see how to preview a .riv file online and test its state machines.

How do you read a ViewModelInstance in web code?

On the web, the runtime reads and writes ViewModelInstance values after the file loads. The example below creates a Rive instance, waits for the load callback and checks that an instance is bound before any app logic runs.

import { Rive } from '@rive-app/canvas';

const riveInstance = new Rive({
  src: '/character.riv',
  canvas: document.getElementById('character'),
  stateMachines: 'CharacterStateMachine',
  autoplay: true,
  onLoad: () => {
    const vmi = riveInstance.viewModelInstance;
    if (!vmi) {
      console.error('No ViewModelInstance bound. Check the file, the ViewModel path and the runtime version.');
      return;
    }
    console.log('Bound ViewModelInstance ready');
  },
});

The web runtime exposes a viewModelInstance getter for the instance that is bound, and a viewModel(path) method that returns a ViewModelInstance for a path you name. Treat a null result as a failed check, not a cosmetic issue. The animation may still play while your app has no link to its data.

If you assemble instances yourself, the order matters. setViewModelInstance assigns an instance to the state machine without binding it, and bind() then applies the instances that were set. Call bind once, after all assignments. For files with several artboards, getBindableArtboard(name) returns a BindableArtboard whose viewModel property can be set to bind an instance to that artboard.

Read each typed property through the accessor your runtime version documents for its type, then log the value. A read-back that matches what you wrote is the evidence you need. The next section covers the native runtimes, where the same ideas apply with different calls. For React and Next.js setups, see how to use Rive in React and Next.js.

Which runtime versions bind ViewModels differently?

Binding behavior changed across Rive's runtime releases, so the version check belongs in the same review as the property check. As of December 2026, this is what to confirm on each platform.

RuntimeWhat to confirm for an MCP-generated file
WebviewModelInstance is set after load; hand-built instances use setViewModelInstance and then bind()
React NativeuseViewModelInstance can create an instance from a RiveFile, a ViewModel or a RiveViewRef; its async option needs @rive-app/react-native 0.4.18 or later
FlutterInstances can be created blank, default, by index or by name, and disposed; from 0.15.0 binding happens when RiveWidgetController is created, with Flutter 3.32.0 (Dart 3.8.0) as the minimum
AppleFrom v6.28.0, authored default instances bind automatically; Rive.viewModelInstance returns nil with the new initializers and DataBind is deprecated
Androidv11.13.0 added font data binding and an ASSET_BLOB value on PropertyDataType

The useful habit is to pin the runtime version next to the file version. When a release changes when binding happens, as Flutter 0.15.0 did by tying it to controller creation, code that still calls the old step can fail without a clear message. Read the migration guide for the version you upgrade to, then run the test in the next section again.

Apple and Android are the most likely to surprise an upgrade. The October 1, 2026 runtime update says authored default instances bind automatically in Apple v6.28.0, and that Rive.viewModelInstance returns nil with the new initializers. Android v11.13.0 added font data binding, so a file with font properties needs that version or later. For SwiftUI specifics, see Rive data binding in SwiftUI.

How do you test every state of a generated ViewModel?

A read-back of the bound instance is worth more than a screenshot. The script below sets every mood value, reads it back and stops at the first mismatch. The helpers setMood, readMood and waitForFrames are functions your team writes around the runtime accessors you verified in the previous step.

const expectedMoods = { idle: 0, happy: 1, wave: 2, thinking: 3, sad: 4, loading: 5, listening: 6, talking: 7, sleeping: 8, attention: 9 };

for (const [name, value] of Object.entries(expectedMoods)) {
  setMood(value);
  await waitForFrames(3);
  const actual = readMood();
  if (actual !== value) {
    throw new Error('Mood ' + name + ' expected ' + value + ' but got ' + actual);
  }
}

console.log('All ten moods bound and read back.');

Run it in a browser test runner. Playwright drives Chromium, Firefox and WebKit through one API, so the same script covers the browser engines your users run. Add a screenshot at each mood if you also need to see that the pose changed, not only that the number did.

Two more checks catch common gaps. First, confirm that every success or error your product shows maps to a state that exists. If the file has no trigger for success, show success with a happy state and an error with a sad state, and test those mappings directly. Second, test the default instance: load the file with no app code and confirm the resting state is idle.

What breaks a generated ViewModel after it ships?

Most failures come from a few patterns. Each one has a fast check.

  • Renamed or retyped properties. The file was regenerated and a name or type changed. Compare the file's table with the one your code expects on every regeneration.
  • No default instance. The file loads but nothing is bound. Check the default instance in the editor and treat a null instance as a failed load.
  • Old binding calls. Code written for an earlier runtime still calls a removed or deprecated step. From Flutter 0.15.0 the separate dataBind call is gone, and in Apple DataBind is deprecated.
  • A runtime older than the file. A file that uses fonts, assets or lists needs a runtime that supports them, so pin the version alongside the file.
  • Hand-built instances bound too early. Assignments made after bind() may not reach the state machine, so keep the order from the web section.

Treat DataBind as deprecated and plan the move to the newer initializers rather than waiting for a deadline you cannot see. Run the full test after every MCP regeneration and every runtime upgrade. If a mood test passes on the old file and fails on the new one, the difference is the regeneration, and the diff in property names will show why. When you only need state changes and no typed values, a plain state machine may be simpler; Lottie vs Rive state machines and data binding explains the difference.

How to inspect and verify Rive Data Binding ViewModels from an MCP server

  1. Open the file and record the ViewModel. Open the .riv file in the Rive editor or a file inspector and write down the ViewModel name, each property name and type, and the default instance.
  2. Confirm the state machine names. Check that the state machine names in the file, such as CharacterStateMachine, match the names your code loads.
  3. Read the bound instance in code. Use the runtime's ViewModelInstance accessor after load, log the result and treat a null instance as a failed load.
  4. Set and read back every property. Write a test that sets each value your states need, reads it back and fails on the first mismatch.
  5. Pin the runtime version and retest. Match the runtime version to the features the file uses, and rerun the test after every MCP regeneration or runtime upgrade.

Frequently asked questions

Should I trust an MCP server's description of its ViewModel?

Use it as a starting point, not as proof. An MCP server can report what it intended to build, but only the file shows what was written. Open the .riv, compare the property names, types and default instance with your expected table, and run the read-back test in your target runtime. Record the file version and runtime version together so a later failure can be traced.

Can I check the file without installing the Rive editor?

Yes, for a first pass. The Rive file inspector on this site is a quick way to review a .riv file's structure. A runtime test still has to run in the app or a test page, because only the runtime shows whether values bind and update in your code.

Why is my ViewModelInstance null after the file loads?

Check that the state machine name matches the file, that the ViewModel path is correct and that the runtime supports the features the file uses. On Apple, from v6.28.0, Rive.viewModelInstance returns nil with the new initializers, so obtain the instance through those initializers instead.

Does Rive's free plan affect data binding tests?

Rive's runtimes are open source and play any .riv file, so your test does not need a paid editor seat. Splash screen and export rules depend on the editor plan. The free pricing guide covers those rules in detail.

Sources

Related guides