npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@rosneri/xstate-mcp

v0.1.8

Published

MCP server for XState machine introspection and simulation

Readme

@rosneri/xstate-mcp

MCP server for XState v5 machine introspection and simulation. Gives Claude (and any MCP client) 9 tools to inspect, simulate, and navigate XState state machines — purely from machine definitions, no running app required.

Tools

| Tool | Description | |------|-------------| | list_machines | List all registered machines with summary info | | inspect_machine | Full state tree with every transition and guard flag | | simulate_events | Run an event sequence, capture a state snapshot after each step | | validate_event_sequence | Like simulate but continues past invalid events, reports each step | | suggest_capabilities | Events available in a given state (own + ancestor + root) | | get_reachable_states | All states reachable from a given state via static analysis | | find_path | BFS shortest event sequence from state A to state B | | list_guard_conditions | Every guarded transition with human-readable guard description | | export_state_diagram | Mermaid stateDiagram-v2 output for any machine |

Getting started

Install it as a dev dependency:

bun add -d @rosneri/xstate-mcp

Write a small entry file that imports your machines and registers them. Each entry needs a name, a short description, the machine itself, and supportsSimulation:

// xstate-mcp-server.ts
import { createXstateMcpServer } from "@rosneri/xstate-mcp";
import { authMachine } from "./auth-machine.js";
import { checkoutMachine } from "./checkout-machine.js";

await createXstateMcpServer([
  {
    name: "auth",
    description: "Handles login, logout, and session refresh",
    machine: authMachine,
    supportsSimulation: true,
  },
  {
    name: "checkout",
    description: "Multi-step checkout flow",
    machine: checkoutMachine,
    supportsSimulation: false, // requires a payment service actor
  },
]);

Point your MCP client at that file. In .mcp.json:

{
  "mcpServers": {
    "xstate-mcp": {
      "command": "bun",
      "args": ["./xstate-mcp-server.ts"]
    }
  }
}

Reconnect the server (or restart your client), then ask it to list_machines — your machines will show up, ready for inspect_machine, simulate_events, export_state_diagram, and the rest.

The entry file is the only place machines are registered; the server has no auto-discovery. Whenever you add a machine, add it to the array and reconnect.

Troubleshooting

list_machines is empty, or you get Unknown machine. The server only knows about machines passed to createXstateMcpServer. Check that .mcp.json runs your entry file (not the bare package) and that the machine is in the array.

Edited the entry file but nothing changed. Clients start the server once and cache the process. Reconnect the server or restart your client after editing the entry or .mcp.json — it does not hot-reload.

supportsSimulation

Set supportsSimulation: false for machines that require complex input (actor references, external services, etc.) that can't be created without a running context. The simulate_events and validate_event_sequence tools will require an explicit input object for those machines.

Lower-level utilities

All internal utilities are re-exported for consumers who want to build custom tools:

import {
  inspectMachine,
  simulateEvents,
  validateEventSequence,
  getReachableStates,
  findPath,
  listGuardConditions,
  exportStateDiagram,
} from "@rosneri/xstate-mcp";

License

MIT