state-machine

state-machine

Enables validating, simulating, and analyzing finite state machines via MCP tools for step execution, path finding, and schema inspection.

Category
访问服务器

README

Step Switch

Step Switch turns a finite business workflow into executable data. Given one Machine Spec, a snapshot, and an event, it deterministically accepts or rejects the transition, returns the next snapshot, and emits symbolic effect intents. It never executes those effects.

The repository includes one shared TypeScript core, a CLI, six read-only MCP tools in a Codex plugin, and a browser editor/simulator.

It intentionally stays smaller than a complete statechart runtime: guards are explicit caller-supplied facts, effects are symbolic intents, Agent inputs are inline and closed-world, and no surface evaluates user code.

Install the Codex plugin

The public source-distribution channel is the GitHub repository marketplace. After the v0.1.0 release is available:

codex plugin marketplace add tetracoralla/state-machine --ref v0.1.0
codex plugin add state-machine@state-machine

Restart ChatGPT or Codex, open a new task, and use a concrete Machine Spec. For example, ask it to validate examples/order.machine.yaml, test whether an event is legal from a snapshot, or simulate an event sequence. An ordinary supported request should require one machine.* tool call.

The repository includes .agents/plugins/marketplace.json and the committed prebuilt server, so plugin users do not need npm, TypeScript, or a build step. See the current OpenAI plugin packaging documentation for marketplace and host behavior.

Develop from source

npm ci
npm run check

Node.js 22 or later and npm 10 or later are required. The Node package is intentionally private and is not an npm distribution channel.

Run the editor

npm ci
npm run build
npm run start:ui

Open http://127.0.0.1:4317. The workspace ships with an order lifecycle example. Edit the YAML definition, inspect validation and topology, choose explicit guard outcomes, run events, inspect the trace and effect intents, find a route to a target state, and import or export the spec.

For development with live reload:

npm run dev:ui

Use the CLI

npm run build

node dist/node/adapters/cli.js validate examples/order.machine.yaml --pretty

node dist/node/adapters/cli.js step examples/order.machine.yaml \
  --event '{"type":"PAYMENT_SUCCESS","payload":{"amount":128,"payment_id":"pay_1024"}}' \
  --guards '{"payment_amount_matches":true}' \
  --pretty

node dist/node/adapters/cli.js simulate \
  examples/order.machine.yaml \
  examples/order.events.yaml \
  --pretty

node dist/node/adapters/cli.js path \
  examples/order.machine.yaml \
  completed \
  --pretty

The CLI also supports inspect and diff. Run it without arguments for the complete command summary. Exit code 0 means the operation completed, including ordinary transition rejections and unreachable paths. Exit code 1 means the machine or operation result is invalid; exit code 2 is reserved for command, file, or JSON usage errors. Every outcome is still emitted as JSON.

Use the Agent tools

The built plugin is plugins/state-machine. It contains the bundled stdio MCP server, manifest, and use-state-machine Skill. This repository does not modify a personal marketplace or install itself automatically. Contributors can add a local checkout for pre-release testing:

codex plugin marketplace add /absolute/path/to/state-machine
codex plugin add state-machine@state-machine

Restart the host and test in a new task after installing or upgrading.

Public tools:

Tool Result
machine.validate strict structure and semantic graph diagnostics
machine.step one accepted or rejected event with next snapshot and effects
machine.simulate bounded event trace and final snapshot
machine.find_path shortest structural route and required guard names
machine.inspect compact states, events, transitions, statistics, and limits
machine.diff bounded semantic changes between two valid specs

All tools accept inline data, make no external changes, and publish strict input schemas. Results are checked against the executable output schemas before they leave the server. The six-tool discovery catalog is capped at 36 KiB by the runtime contract. A normal request should use one direct tool call.

Machine Spec

The canonical format is YAML or JSON with version: "0.1", an initial state, declared context and event fields, named guards, and a state map. Each state/event pair owns at most one transition. Context assignment uses only tagged literal, event, or context value sources. Effects contain only a symbolic type and input value sources.

See Machine Spec v0.1, the generated machine-spec.schema.json, and the shipped order.machine.yaml.

Verify the project

npm run check

This runs type checks, core tests, schema drift checks, all builds, built CLI and MCP stdio tests, an isolated package install, browser interaction and responsive regressions, and plugin/contract checks. Overall visual and business acceptance remains the owner's rendered-runtime judgment; its current route is recorded in docs/REVIEW_CONTRACT.md.

Contribution and release details are in CONTRIBUTING.md and docs/RELEASE.md. Stable public identifiers are recorded in docs/PRODUCT_IDENTITY.md.

Boundary

v0.1 intentionally excludes hierarchical, parallel, history, delayed, actor, and eventless statechart semantics. It also excludes expression evaluation, effect execution, production orchestration, AI-generated business rules, and XState/SCXML compatibility claims. The current product boundary is maintained in docs/PRODUCT_MODEL.md.

License

Step Switch is licensed under the Apache License 2.0. See LICENSE and NOTICE. The standalone plugin includes its own copies plus the license and attribution text for software bundled into the browser and MCP distributions.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选