MCP API Translator

io.github.krishgokv0.4.1更新於 Oct 11, 2026

Turn OpenAPI / Postman specs into runnable MCP servers, or serve any API as live MCP tools.

已驗證STDIO僅桌面Developer ToolsAI & ML

概覽

AI 產生的概覽

把 OpenAPI 或 Postman 介面定義轉成可執行的 MCP 伺服器專案,或直接把 API 當成即時 MCP 工具提供。

功能
解析 OpenAPI 3.0/3.1 或 Postman v2.1 規格,並為該 API 產生完整的 TypeScript 或 Python MCP 伺服器專案。其工具可在寫入前預覽即將產生的工具清單(analyze_spec)、產生專案(generate_mcp_server)、把另一份規格的介面附加到既有專案(extend_mcp_server),以及回報支援的格式、驗證方式和限制(list_supported_features)。也可執行執行期代理,不必產生程式碼就把一個或多個 API 暴露成 MCP 工具。
適用情境
當你希望助理透過 MCP 呼叫某個 REST API,而且想自己擁有產生的伺服器程式碼、篩選哪些介面成為工具,或把多個 API 合併成一個伺服器時,適合使用。也適合用 serve 模式快速臨時暴露一個 API。
執行需求
透過 npx 以 stdio 在本機執行,需要 Node 20+,也可使用 Docker 映像。規格可內嵌提供或使用本機路徑。產生的伺服器和 serve 代理需要透過環境變數提供 API 基礎網址與憑證(依 API 加命名空間,實際名稱見產生的 .env.example);轉換器本身未宣告需要憑證。
安裝前請注意
產生的伺服器和 serve 代理會從 _API_KEY、 _API_BASE_URL 等環境變數讀取 API 憑證,這些密鑰會出現在產生專案的執行環境中。產生的工具可能呼叫目標 API 的寫入、傳送或刪除操作,建議篩選介面而不是暴露整份規格。規格與 API 回應會經過本機程序,README 也說明不支援互動式 OAuth 授權流程。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 MCP API Translator,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

mcp-api-translator

[npm] [CI] [License: AGPL-3.0] [Commercial license available] [MCP]

An MCP server that generates MCP servers. Give it an API definition — OpenAPI 3.0/3.1 or a Postman collection — and it scaffolds a complete, runnable, ownable TypeScript or Python MCP server for that API.

[Curate a spec, aggregate a second one, run the generated server, and let an agent call it]

Above: curating Firecrawl's 20 operations down to 6, appending the Gmail API to the same server, then an agent calling the self-hosted result. Counts, tool names and paths come from real runs against the published Firecrawl and Gmail descriptions; the API responses are illustrative — the recording runs against a local stub, not live Firecrawl or Gmail accounts.

Why this and not a 1:1 generator

Turning an OpenAPI spec into MCP "tool stubs" is not novel — FastMCP's from_openapi, Speakeasy/Gram, and several openapi-mcp-generator projects already do the mechanical part. A naive endpoint→tool generator has no real advantage. This project focuses on the parts those tools skip:

1. Curation, not just generation. A 200-endpoint API naively becomes 200 tools, which wrecks a model's tool-selection accuracy and blows out context. analyze_spec previews the tool list before anything is written, every command takes includeTags / methods / pathGlob / excludeOperations, and you get a warning when a server grows past 40 tools.

2. Aggregation via append. extend_mcp_server adds another API's tools to an existing project, so you can build one MCP server spanning Firecrawl + Gmail + your internal API. Credentials stay separate: each API also reads namespaced env vars derived from its title.

3. An artifact you own. Output is a normal project, not a hosted black box — readable per-tool files, env-based auth, a Dockerfile, and a server.json plus client snippets for publishing to the official MCP Registry.

If you only need throwaway, in-memory exposure of one API and don't care about owning the code, FastMCP's runtime mode may suit you better — that's a deliberate non-goal here.

Install

No install step. npx fetches and runs the latest published version — cross-platform, Node 20+.

Claude Code

Claude Code does not read claude_desktop_config.json — it keeps its own MCP config:

bash
claude mcp add api-translator -- npx -y mcp-api-translator

That registers it at local scope. Use -s user for all your projects, or commit a project-scoped .mcp.json to share it. Verify with claude mcp list.

Claude Desktop

Add to claude_desktop_config.json (macOS: ~/Library/Application Support/Claude/claude_desktop_config.json, Windows: %APPDATA%\Claude\claude_desktop_config.json):

json
{  "mcpServers": {    "api-translator": {      "command": "npx",      "args": ["-y", "mcp-api-translator"]    }  }}
Cursor, Cline, Continue.dev, Docker

Cursor — ~/.cursor/mcp.json (or project-scoped .cursor/mcp.json), same mcpServers shape as Claude Desktop above.

Cline (VS Code) — sidebar → MCP Servers → Configure, same shape plus "disabled": false.

Continue.dev — ~/.continue/config.json, under experimental.modelContextProtocolServers, as a { transport: { type: "stdio", command, args } } entry.

Docker (no Node required):

json
{  "mcpServers": {    "api-translator": {      "command": "docker",      "args": ["run", "--rm", "-i", "ghcr.io/krishgok/mcp-api-translator:latest"]    }  }}

To read specs from disk or write projects to a host path, mount the directory with -v ${PWD}:/workspace and pass /workspace/... as specPath / outputDir.

MCP config is read at startup, so restart your client — quit and reopen Claude Desktop, Cursor, …, or start a new session in Claude Code.

The four tools

ToolWhat it does
analyze_specParse a spec and preview the tools that would be generated — no files written.
generate_mcp_serverGenerate a complete MCP-server project into outputDir.
extend_mcp_serverAppend another spec's tools to an existing project (idempotent).
list_supported_featuresReport supported formats, auth schemes, transports, and limits.

All spec inputs accept inline text (spec) or a local path (specPath), JSON or YAML.

Usage

You don't call the tools by hand — you ask your agent, and it drives them.

1. Preview, then curate. See what a spec becomes before writing anything:

"Analyze ./petstore.yaml and show me the proposed tools." "Only the GET endpoints under /pets."

js
analyze_spec({ specPath: "./petstore.yaml" });// → proposed tool list, auth scheme, and the env vars the server will need
analyze_spec({ specPath: "./petstore.yaml", methods: ["GET"], pathGlob: "/pets/**" });// also: includeTags: ["pets"], excludeOperations: ["deletePet"]

2. Generate, with the same filters plus an output directory:

js
generate_mcp_server({ specPath: "./petstore.yaml", outputDir: "./petstore-mcp" });// options: language: "python", transport: "http", auth: {...}, force: true

3. Aggregate — add more APIs to the same server:

js
// any second API — the sources don't have to share a format or a vendorextend_mcp_server({  projectDir: "./petstore-mcp",  specPath: "./billing.postman.json",  includeTags: ["invoices"],});// idempotent; hand-edited tool files are preserved

Aggregated APIs don't share credentials: each also reads namespaced env vars (<NAMESPACE>_API_BASE_URL, <NAMESPACE>_API_KEY, … — namespace derived from the API title) before falling back to the bare ones. The extend summary and .env.example list the exact names.

4. Run it. The output is a normal project you own:

bash
cd petstore-mcp && npm install && npm run buildcp .env.example .env   # set API_BASE_URL + credentials (never embedded in code)npm start

Register it with your client using the generated client-config.md, and your agent can call the APIs directly.

Full walkthrough with sample outputs and troubleshooting: docs/usage-workflow.md.

Generate, or serve

  • Generate ownable code when you want a project you can hand-edit, self-host, and own — in TypeScript (default) or Python (language: "python").

  • Serve a live runtime proxy when you just want an API exposed to an agent now, with no generated files to build or maintain:

    bash
    mcp-api-translator serve --spec ./api.yamlmcp-api-translator serve --spec ./a.yaml --spec ./b.yaml --methods GET,POST   # aggregate

serve runs the same request plan and env-based auth the generator emits, so behavior matches generated output exactly — it just skips the codegen step. It speaks stdio by default, or stateless Streamable HTTP with --transport http --port 3000. Logs are structured JSON lines on stderr in containers, readable text on a TTY (LOG_LEVEL, LOG_FORMAT).

Documentation

DocWhat's in it
usage-workflow.mdEnd-to-end walkthrough, curation loop, auth setup, troubleshooting.
design.mdTech stack, generated project layout, limitations, security model.
deploy-serve.mdDocker/compose recipes for serve, logging and observability.
serve-api-proposal.mdDesign of the runtime proxy and the roadmap.
market-analysis.mdWhy both generate and serve models exist.
CONTRIBUTING.mdDev setup, PR conventions, DCO sign-off.

Known limits at a glance: OpenAPI 3.0/3.1 and Postman v2.1 (Swagger 2.0 best-effort), no GraphQL/gRPC; no interactive OAuth consent flows; no upstream streaming or auto-pagination; output quality tracks spec quality. Details and the security model: docs/design.md.

Development

bash
npm installnpm test          # unit + integration (parsers, curation, emit, append)npm run typechecknpm run buildnpm run e2e       # generate a sample project from the fixtures into build/e2e-out

Contributions welcome — see CONTRIBUTING.md. All commits must be signed off under the Developer Certificate of Origin (git commit -s).

License

mcp-api-translator is dual-licensed — © 2026 krishgok. Full details in LICENSING.md.

  • Open source: GNU AGPL-3.0-or-later. Running a modified version as a network service requires offering that version's complete source to its users.
  • Commercial: a separate license is available for embedding in proprietary products without AGPL obligations.
  • Your generated output is yours. Projects produced by this tool are covered by a generated-output exception and are not subject to the AGPL.

Redistributions must retain LICENSE and NOTICE. The licenses do not grant the right to use the "mcp-api-translator" name to endorse or promote forked or derivative works without prior written permission.

來源:README.md,提交 f117273

工具

0
工具後設資料尚未被收錄。

版本歷史

1
  1. v0.4.1最新Oct 11, 2026