
X Openapi Flow Mcp
io.github.tiago-marques由 GitHub 账号 tiago-marques 发布v1.7.4更新于 Oct 25, 2026
OpenAPI lifecycle guard and MCP sidecar for policy-driven API orchestration.
概览
x-openapi-flow 的本地 MCP 附属工具,为助手提供 OpenAPI API 生命周期状态、调用顺序与决策规则的机器可读契约。
- 可以做什么
- 向编码代理提供紧凑、非叙述式的流程契约,使其了解集成所需的准确调用顺序、决策规则和字段引用,而无需从人类文档中重新推导(export-llm-flows,可作为 MCP 工具调用)。
- 适用场景
- 当助手(例如编码代理)需要正确实现或调用多步骤、有状态的 API,并应遵循已声明的生命周期转换而不是猜测操作顺序时使用。
- 运行要求
- 作为本地 stdio 进程在桌面端运行,从 npm 包 x-openapi-flow 安装;需要 Node.js 和 npx。它针对 OpenAPI 规范工作,通常配合生成的 openapi.x.json 附属文件。未声明认证、环境变量或请求头。
安装
在 SourceWeft 中
- 打开 控制台中的 X Openapi Flow Mcp,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
OpenAPI describes APIs. x-openapi-flow turns them into executable workflows — for developers and AI agents.
Define your API workflows in openapi.x.json and execute them without writing custom clients or orchestration logic
[npm version] [npm downloads] [npm total downloads] [node] [license] [CI] [open issues] [last commit] [copilot ready]
🚀 2,100+ downloads in the first 3 weeks!
⚡ Get started in seconds
This generates an openapi.x.json file where you can declaratively define how your API should be executed — not just described.
See your API lifecycle come alive from your OpenAPI spec, with one simple command
Validate, document, and generate flow-aware SDKs automatically.
What is this?
x-openapi-flow extends your OpenAPI specification with a workflow layer.
openapi.json → describes your API
openapi.x.json → describes how to use it (flows)
Instead of writing imperative code to orchestrate API calls, you define workflows declaratively and run them anywhere.
x-openapi-flow adds a declarative state machine to your OpenAPI spec.
Model resource lifecycles, enforce valid transitions, and generate flow-aware artifacts for documentation, SDKs, and automation.
🚀 Example
Define stateful workflows and lifecycle transitions directly inside your OpenAPI operations:
This flow defines an order lifecycle directly inside your OpenAPI:
- Starts in the
createdstate - Transitions to
paidwhen payment is confirmed - Supports both synchronous and polling-based transitions
- Propagates data between operations automatically
- Can include explicit decision/evidence and failure-path metadata for AI-guided orchestration
Instead of manually orchestrating API calls, the workflow is fully described alongside your API specification.
Why This Exists
Building APIs is cheap. Building complex, multi-step APIs that teams actually use correctly is hard.
Teams face recurring problems:
- 📄 Manual documentation is brittle – OpenAPI specs are static, often out of sync with real workflows
- 🤖 AI agents can hallucinate – LLMs and code-generating agents may produce invalid calls if workflows are unclear or undocumented
- 🤯 Workflows are confusing – multi-step operations are hard to track for humans and AI agents
- ⚠️ Invalid calls slip through – developers make mistakes because lifecycle rules aren’t enforced
- ⏱️ Integration slows down – SDKs, Postman collections, and docs need constant manual updates
- 🛡️ Hard to prevent errors in production – without explicit lifecycle rules, invalid operations can reach live systems, causing outages or inconsistencies
x-openapi-flow exists to solve these pains: it makes lifecycles explicit, validates transitions automatically, and generates flow-aware docs and SDKs — so teams move faster, make fewer mistakes, and ship confident integrations.
What This Enables
Turn your OpenAPI spec into a single source of truth for API behavior:
- Visualize API lifecycles directly in Swagger UI and Redoc
- Validate flows and state transitions in CI pipelines
- Generate lifecycle diagrams automatically from your OpenAPI spec
- Build SDKs that understand and respect API workflows
- Export Postman and Insomnia collections organized by lifecycle
- Create AI-ready API contracts for agentic integrations
- Export a dense, non-prose flow contract for coding agents (
export-llm-flows) — or call it directly as an MCP tool — so an agent like Claude Code knows the exact call order, decision rules, and field refs to implement an integration, without re-deriving them from human docs
Quick Start (without OpenAPI file)
Start in 2 Minutes (Online Playground)
Prefer no local setup? Open the minimal runtime-guard demo directly in your browser:
- StackBlitz: https://stackblitz.com/github/tiago-marques/x-openapi-flow/tree/main/example/runtime-guard/minimal-order
- Codespaces (repo): https://github.com/tiago-marques/x-openapi-flow
Once open, run:
Then in another terminal:
Expected: 409 INVALID_STATE_TRANSITION.
Fastest way to see value (guided scaffold):
Optional runtime:
Then run:
Expected: 409 INVALID_STATE_TRANSITION.
If you already have an OpenAPI file, use the sidecar workflow:
Initialize flow support in your project:
After regenerating your OpenAPI file, apply and validate the flow (optional):
This will:
- enrich your OpenAPI spec with flow metadata
- validate lifecycle consistency
- catch invalid transitions early
💡 Tip: run this in CI to enforce API workflow correctness
Less Verbose DSL for Large Flows
For larger APIs, you can define flow rules by resource (with shared transitions/defaults) and reduce duplication in sidecar files.
See: Sidecar Contract
GitHub Action (One-Step CI Validation)
Use the official reusable action to validate lifecycle rules in CI with a single step:
Integration guide: GitHub-Actions-Integration.md
Real Lifecycle Example
Here’s a real-world payment lifecycle represented in x-openapi-flow:
Generate a visual graph of the lifecycle:
Resulting diagram:
This visualization makes your API workflow explicit, easy to communicate, and ready for documentation or demos.
Generate Flow-Aware SDKs
Create a TypeScript or Python SDK that respects your API’s lifecycle and transition rules, following best practices seen in leading companies like Stripe and Adyen:
- Orchestrator by model: each resource exposes methods that enforce valid transitions
- Chainable API calls: perform sequences naturally and safely
Example usage (TypeScript):
Example usage (Python — zero-dependency, stdlib urllib-backed client, generated under ./sdk/src):
This SDK guides developers through valid transition paths, following patterns used by market leaders to ensure safe and intuitive integrations.
Runtime Enforcement (Express + Fastify + Hono)
CI validation is important, but production safety needs request-time enforcement.
x-openapi-flow now includes an official runtime guard for Node.js that can block invalid state transitions during request handling.
- Works with Express and Fastify
- Resolves operations by
operationId(when available) or by method + route - Reads current resource state using your own persistence callback
- Blocks invalid transitions with explicit
409error payloads
Install and use directly in your API server:
Express example:
Fastify example:
Hono example:
Error payload for blocked transition:
More details: Runtime Guard
Built-in Persistence Adapters
No need to write your own getCurrentState from scratch. x-openapi-flow ships five ready-made adapters:
GenericSQLAdapter example with pg:
MongoAdapter example with the official mongodb driver:
All adapters implement getCurrentState, setState, deleteState and forGuard() — a convenience method that returns the exact shape expected by the guard options.
Observability Hooks (Metrics/Audit)
You can instrument runtime decisions with onDecision to feed Prometheus, logs, or tracing.
Common decision values include:
allowed_transitionallowed_idempotent_stateallowed_initial_statedenied_invalid_transitiondenied_missing_resource_iddenied_unknown_operationskipped_unknown_operation
Want to see the value immediately? Use the official minimal demo:
Run in under 5 minutes:
Create an order, then try to ship before payment (must return 409 INVALID_STATE_TRANSITION):
HTTPie equivalent:
Programmatic State Machine Engine
Use a reusable deterministic engine independently of CLI and OpenAPI parsing:
More details: State Machine Engine
OpenAPI to Engine Adapter
Convert x-openapi-flow metadata to a pure engine definition:
More details: OpenAPI State Machine Adapter
Who Benefits Most
x-openapi-flow is ideal for teams and organizations that want clear, enforceable API workflows:
- API-first organizations – maintain a single source of truth for API behavior
- Teams building AI agents – provide AI-friendly contracts and enforce correct API usage, so agents can safely call endpoints in the right order without guessing or violating workflow rules
- API platform teams – ensure consistent lifecycle rules across endpoints
- Companies with complex API workflows – reduce errors and ambiguity in multi-step processes
- SDK teams – generate flow-aware SDKs that guide developers
Why x-openapi-flow?
See how x-openapi-flow extends OpenAPI to make your API workflows explicit, enforceable, and actionable:
How does it compare to OpenAPI Workflows (Arazzo) and AsyncAPI?
In short: use x-openapi-flow when you need enforceable, stateful API lifecycles that go beyond documentation into runtime safety, SDK generation, and AI-ready contracts. Use Arazzo for scripting multi-step HTTP journeys. Use AsyncAPI for documenting event/message-driven systems.
Integration Demos
Explore how x-openapi-flow integrates with popular API tools, making lifecycles and flows explicit for documentation and testing.
Swagger UI – Visualize Flows in Your Docs
Lifecycle panel shows valid states and transitions
Detailed view of transitions per operation
Redoc – Flow-Aware Documentation
[Redoc Flow Lifecycle 1] [Redoc Flow Lifecycle 2] [Redoc Flow Lifecycle 3]
Auto-generated lifecycle diagrams make documentation clear and consistent
Postman – Organized API Collections
[Postman Flow Lifecycle 1] [Postman Flow Lifecycle 2]
Collections reflect lifecycle order, reducing integration errors
Insomnia – Organized API Collections
[Insomnia Flow Lifecycle 1] [Insomnia Flow Lifecycle 2]
Requests are pre-organized according to lifecycle transitions
CLI Reference – Common Commands
Use x-openapi-flow from the command line to manage, validate, visualize, and generate SDKs/docs for your API workflows.
General
Workflow Management
Visualization & Documentation
SDK Generation
Test Generation
Full details:
NestJS Integration
Dedicated package: x-openapi-flow-nestjs-kit
Then import from x-openapi-flow-nestjs-kit.
This package wraps the official runtime-guard helpers and exposes a NestJS-first API.
Release automation for this package uses dedicated tags in the format nestjs-v<version>
(example: nestjs-v0.1.1) so it does not conflict with x-openapi-flow tags.
Option A: Middleware (drop-in)
Option B: CanActivate Guard
After each successful state-changing request, call store.setState to advance the resource:
Documentation and Guides
Get the most out of x-openapi-flow with detailed guides, examples, and integration instructions:
-
Adoption Guide – docs/wiki/getting-started/Adoption-Playbook.md
Learn how to introduce x-openapi-flow into your API workflow efficiently -
Troubleshooting – docs/wiki/reference/Troubleshooting.md
Quick solutions to common issues and validation errors -
Real Examples – docs/wiki/engineering/Real-Examples.md
Explore real OpenAPI specs enhanced with lifecycle metadata -
Integrations:
- GitHub Actions – docs/wiki/integrations/GitHub-Actions-Integration.md
Validate flow rules in CI in one reusable workflow step - Swagger UI – docs/wiki/integrations/Swagger-UI-Integration.md
See flow-aware panels in Swagger UI - Redoc – docs/wiki/integrations/Redoc-Integration.md
Generate lifecycle diagrams in Redoc documentation - Postman – docs/wiki/integrations/Postman-Integration.md
Organize collections according to valid transitions - Insomnia – docs/wiki/integrations/Insomnia-Integration.md
Pre-configure requests according to lifecycle flows
- GitHub Actions – docs/wiki/integrations/GitHub-Actions-Integration.md
Community and Proof
- Share your case study – docs/wiki/community/Case-Study-Template.md
- Open discussions and ideas – use GitHub Issues to share adoption blockers, metrics, and integration stories : use the structured forms at .github/ISSUE_TEMPLATE/case-study.yml and .github/ISSUE_TEMPLATE/adoption-blocker.yml
- Prove impact with metrics – track
denied_invalid_transition, onboarding lead time, and CI catch rate before/after adoption
Roadmap
We’re actively expanding x-openapi-flow to support multiple platforms and SDKs. Check our progress:
-
🗂 Roadmap Overview – #2
See planned features and high-level goals -
🐍 Python SDK MVP – #3
Enable Python developers to use flow-aware SDKs -
🏎 Go SDK MVP – #4
Bring lifecycle-aware SDKs to Go projects -
☕ Kotlin SDK MVP – #5
Support Android and JVM developers with flow-aware SDKs
Changelog
Keep track of updates and improvements in x-openapi-flow:
-
Latest Version (v1.7.0) – CHANGELOG.md#170---2026-04-02
See what shipped in the current release -
Version History – CHANGELOG.md
Review the full version history and past updates -
Release Notes – GitHub Release v1.7.0
See detailed notes for the latest release, including new features and fixes
Documentation Language Policy
To ensure clarity and accessibility for the global developer community, all project documentation should be written in English. This helps contributors, users, and AI agents understand and use x-openapi-flow consistently.
来源:x-openapi-flow/README.md,提交 76bd26e
工具
0版本历史
1- v1.7.4最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分