CM

christopherdond/mcp-generator

API 开发

本页由 AI 翻译,技术细节请以原文为准。 查看原文

20 stars 1 forks 质量 80 趋势 30MIT

宽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-gen 2.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-gen 2.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/anyOf variants become synthetic union members with expanded properties instead of warnings; discriminator stays advisory-only.
  • Nested inline allOf members expand recursively; requestBody.$ref to schemas/* resolves as the body param (to parameters/* warns instead of dropping silently).
  • $ref parameters via components.parameters are resolved; unresolvable ones warn; pnpm-lock.yaml and bun.lock/bun.lockb are 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 pinned ubuntu-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=dev clean.

What’s new in 2.3.7

What’s new in 2.5.0

(Minor release — no breaking changes.)

  • Remote URL watch retries transient fetch failures instead of dropping the polling cycle: network errors and 408/425/429/500/502/503/504 responses are retried with exponential backoff, while other 4xx responses fail immediately.
  • New --retries (default 2) and --retry-delay (default 500) flags control the retry budget and the base backoff, which doubles on each attempt. --retries 0 keeps 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 operationId when present, with fallback to method_path.
  • allOf with $ref merges referenced properties; requestBody resolves via components.requestBodies; trace is a supported method.
  • security --json prints pure JSON on stdout for CI parsing; --plugin accepts a directory or a module file.
  • URL watch validates the URL, enforces a 30s timeout and content checks, and compares by SHA-256 hash.
  • security-lint has fewer false positives (anchored base64 regex, lockfiles skipped, all specs scanned).
  • CI adds generated-Python smoke and production dependency audit.
在 GitHub 查看完整 README

安装

npx tsc --noEmit
新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "my-server": { "command": "node", "args": ["/absolute/path/to/my-server/dist/server.js"] } } }