I turned a real OpenAPI into an MCP server in 5 min (without losing custom code on regen)
说明与用途
MCP 生成器现在按标签分组操作,生成可管理的工具数量,支持过滤、增量生成并保留自定义代码。
问题
Generating an MCP server from a large OpenAPI spec produced too many tools (one per operation), making the server unusable.
结果
The generator now produces a manageable number of tools, supports selective generation, preserves custom code across regenerations, and offers improved language support and validation.
工作流
- 1. Run generator with grouping:
node dist/cli/index.js generate -i api.yaml -o ./out --group-by tag - 2. Optionally filter by tags or paths:
--include-tags pets --group-by tagor--path-prefix "/users/" - 3. Add custom code between markers (
// @@mcp-gen:start:…and// @@mcp-gen🔚…) to survive regeneration - 4. Regenerate incrementally:
node dist/cli/index.js generate -i api.yaml -o ./out --incremental - 5. Validate spec:
node dist/cli/index.js validate -i examples/petstore.yaml
证据
200 operations across 8 tags become ~8 tools. Each group routes internally by action.
Your code lives between markers and survives regen with a 3‑way merge
- 记录日期: 2026-09-22T07:30:31.296Z