
宽MCP生成器,简单快捷
概览
根据OpenAPI规范生成MCP服务器。 : @christopher_dondici/mcp-gen 2.3.7 是 npm 上最新发布的版本;2.4.0 已准备好(发布待完成)。详见发布说明(PT-BR)。 mcp-gen 将 OpenAPI v3 或 Swagger 2.0 规范转换为 、 或 的 MCP 服务器。它将每条路由映射到工具,生成类型模型(包括枚举、oneOf/任一),并在重新生成时保留自定义代码。 (小规模发布——无破坏性更改。准备就绪,待发布。包含未发布的2.3.8版本内容。) - 内联 oneOf/anyOf 变体成为合成的联合成员,带有扩展属性而非警告;鉴别器仅保留为顾问。- 嵌套的内联 allOf 成员递归展开;requestBody.$ref 映射为 schema/* 解析,作为正体参数(对参数/* 警告而非静默丢弃)。- 通过 components.parameters 解决$ref参数;无法解析的参数警告;pnpm-lock.yaml 和 bun.lock/bun.lockb 被凭证扫描跳过。- 另见:SDK 1.30.0 → 1.32。
概述(AI 翻译)
也可用于: Português (Versão em Português)
根据OpenAPI规范生成MCP服务器。
状态:
@christopher_dondici/mcp-gen2.3.7 是 npm 上最新发布的版本;2.4.0 已准备好(发布待定)。详见发布说明(PT-BR)。
mcp-gen 将 OpenAPI v3 或 Swagger 2.0 规范转换为 TypeScript、**Python ** 或 Go 的 MCP 服务器。它将每条路由映射到工具,生成类型模型(包括枚举、oneOf/任一),并在重新生成时保留自定义代码。
2.4.0 有什么新内容
(小规模发布——无破坏性更改。准备就绪,待发布。包含未发布的2.3.8版本内容。)
- 内联
oneOf/anyOf变体成为合成联合成员,并扩展属性而非警告;discriminator仅为建议性。 - 嵌套的内联
allOf成员递归展开;requestBody.$ref到schemas/*作为body参数(警告而非静默丢弃)来解析。 - 通过
components.parameters解决$ref参数;不可解析参数警告;pnpm-lock.yaml和bun.lock/bun.lockb被凭证扫描跳过。 - 此外:SDK 1.30.0 → 1.32.1、
proxy-addr→ 2.0.8、handlebars→ 4.7。
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
MCP-Generator
Also available in: Português (Versão em Português)
Generate MCP servers from OpenAPI specs.
Status:
@christopher_dondici/mcp-gen2.3.7 is the latest published version on npm; 2.4.0 is prepared (publication pending). See release notes (PT-BR).
mcp-gen turns an OpenAPI v3 or Swagger 2.0 spec into an MCP server in TypeScript, Python, or Go. It maps each route to a tool, generates typed models (including enums, oneOf/anyOf), and keeps custom code when you regenerate.
What’s new in 2.4.0
(Minor release — no breaking changes. Prepared, publication pending. Includes the unreleased 2.3.8 content.)
- Inline
oneOf/anyOfvariants become synthetic union members with expanded properties instead of warnings;discriminatorstays advisory-only. - Nested inline
allOfmembers expand recursively;requestBody.$reftoschemas/*resolves as thebodyparam (toparameters/*warns instead of dropping silently). $refparameters viacomponents.parametersare resolved; unresolvable ones warn;pnpm-lock.yamlandbun.lock/bun.lockbare skipped by the credential scan.- Also: SDK 1.30.0 → 1.32.1,
proxy-addr→ 2.0.8,handlebars→ 4.7.10 (prod audit clean); streamed remote reads with 50MB cap; CI on Node 22 with pinnedubuntu-24.04; 4 Wave 1 lows. - Local verification: 19 Jest suites / 265 tests, CLI exit-code smoke 4/4, TypeScript/Python/Go generated-server smokes,
npm audit --omit=devclean.
What’s new in 2.3.7
What’s new in 2.5.0
(Minor release — no breaking changes.)
- Remote URL
watchretries transient fetch failures instead of dropping the polling cycle: network errors and408/425/429/500/502/503/504responses are retried with exponential backoff, while other4xxresponses fail immediately. - New
--retries(default2) and--retry-delay(default500) flags control the retry budget and the base backoff, which doubles on each attempt.--retries 0keeps the previous single-attempt behaviour. - Fetch failures now carry the HTTP status code, so callers can branch on it without parsing error messages.
- Local verification: 19 Jest suites / 272 tests, HTTPS retry smoke against a live TLS server (503, 503, 200 → success), lint + typecheck clean.
(Patch release — no breaking changes.)
- Tool names use the sanitized
operationIdwhen present, with fallback tomethod_path. allOfwith$refmerges referenced properties;requestBodyresolves viacomponents.requestBodies;traceis a supported method.security --jsonprints pure JSON on stdout for CI parsing;--pluginaccepts a directory or a module file.- URL
watchvalidates the URL, enforces a 30s timeout and content checks, and compares by SHA-256 hash. security-linthas fewer false positives (anchored base64 regex, lockfiles skipped, all specs scanned).- CI adds generated-Python smoke and production dependency audit.
安装
npx tsc --noEmit配置
{
"mcpServers": {
"my-server": {
"command": "node",
"args": ["/absolute/path/to/my-server/dist/server.js"]
}
}
}