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

@xstate-devtools/mcp

v0.3.0

Published

Model Context Protocol server for XState: list machines, describe structure, Mermaid diagrams, test paths, validation, find references, find implementation, setup() coverage, events, and state detail — over any workspace, no VS Code required.

Downloads

377

Readme

@xstate-devtools/mcp

A Model Context Protocol server that exposes XState analysis over any workspace, no VS Code required. It statically parses your JS/TS source (XState v4 and v5) and answers structured queries, so an AI agent can reason about your state machines instead of grepping source text.

It reuses the same analysis engine as the XState Devtools VS Code extension (@xstate-devtools/diagram-core).

Tools

| Tool | Description | | --- | --- | | list_machines | Every machine in the workspace: id, file, line, state count. | | describe_machine | One machine as JSON: states (hierarchy, initial/final/parallel, entry/exit actions, invokes) plus transitions. Optionally scoped to a subtree via parent/depth. | | machine_diagram | Mermaid stateDiagram-v2 for a machine. | | test_paths | Shortest event sequence to reach each state, unreachable states flagged, plus test skeletons. | | validate | XState diagnostics (invalid properties, unknown transition targets, unreachable states, etc). | | find_references | Every place a name is used as an action, guard, invoked actor, or event, with machine, state, file, and line. | | setup_coverage | Which actions/guards/actors a machine references, and which are missing from setup() (plus which declared ones are unused). | | list_events | A machine's send() API: every event, the states that handle it, and any guard or target. | | state_detail | One state's entry/exit actions, invokes, and outgoing transitions. |

Usage

The server scans the directory given by XSTATE_MCP_ROOT (defaults to the process working directory).

Claude Code / Desktop (MCP client config)

{
  "mcpServers": {
    "xstate": {
      "command": "npx",
      "args": ["-y", "@xstate-devtools/mcp"],
      "env": { "XSTATE_MCP_ROOT": "/absolute/path/to/your/project" }
    }
  }
}

Or run the built binary directly:

XSTATE_MCP_ROOT=/path/to/project node dist/index.js

Benchmark: MCP vs. manual file reading

To measure the effect of structured access, we gave an agent the same task against the same large, complex XState machine twice: once with only file-read/grep tools, once with the xstate MCP server enabled.

Task. Enumerate every top-level sibling of three named states in a 9,101-line machine, listing each one's child states, on events, and whether it has a matching entry action, verifying actual nesting depth rather than guessing from indentation.

Results.

| Metric | Without MCP | With MCP | Change | | --- | --- | --- | --- | | Tool calls | 40 | 6 | −85% | | Wall time | 5m 22s | 1m 59s | −63% | | Tool time | 3m 17s | 3.8s | −98% | | Output tokens | 12,673 | 4,608 | −64% | | Total tokens (input + cache + output) | 1,676,796 | 163,993 | −90% |

Without the server, the agent had no structural view of the machine. It read the file in chunks and delegated to a subagent that grepped raw text across saved tool-output files to reconstruct the hierarchy by eye — 40 tool calls and 1.7M tokens, over five minutes. With the server, a single describe_machine call returned the parsed state/transition graph directly: 6 tool calls, 164K tokens, under two minutes, with the state hierarchy read straight from the parsed AST rather than inferred from source indentation.

Takeaways:

  • Fewer round-trips — one structured query replaced dozens of read/grep calls and a delegated subagent.
  • Lower cost — 90% fewer total tokens, since the agent no longer had to re-read large spans of source into context.
  • Faster — under two minutes end to end, versus over five without.
  • Correct by construction — state and transition data comes from the parsed AST, not text pattern-matching, so nesting depth and sibling counts can't be misread the way raw indentation was.