
Openapi Mcp
io.github.Asthanaji05由 GitHub 帳號 Asthanaji05 發布v0.1.1更新於 Oct 24, 2026
Turn any OpenAPI 3 spec into a working MCP server. One file, local (stdio) or remote (HTTP).
概覽
把任意 OpenAPI 3 規格轉成 MCP 伺服器,將每個 API 端點暴露為助理可呼叫的工具,支援 stdio 或 HTTP。
- 可以做什麼
- 從網址或本機檔案載入 OpenAPI 3 規格,依 operationId 為每個操作建立一個工具。
- 呼叫 API 端點:每次工具呼叫都會送出真實 HTTP 請求,回傳狀態碼與回應內容。
- 用正規表示式依工具名稱篩選要暴露的端點,例如只保留唯讀操作。
- 透過環境變數為上游呼叫提供驗證:bearer、basic、API key,或 OAuth2 用戶端憑證與更新權杖。
- 以 stdio 在本機提供工具,或自架 HTTP 端點供用戶端連線。
- 適用情境
- 當你已有某個 API 的 OpenAPI 3 規格,希望 AI 用戶端不必為每個端點寫程式就能呼叫時使用。適合小型公開 API 或內部服務,想要一個無相依套件的快速橋接;只有 HTML 文件的 API 也可以手寫一份簡短規格。
- 執行需求
- 需要 Node.js 18 或更新版本,伺服器是單一以 node 執行的腳本。需要一份規格,作為網址或本機 JSON 檔案(YAML 需安裝 yaml 套件)。API 需要驗證時透過環境變數提供憑證:API_TOKEN、OAUTH_CLIENT_ID、OAUTH_CLIENT_SECRET、OAUTH_REFRESH_TOKEN,可選 OAUTH_TOKEN_URL、OAUTH_SCOPE、API_HEADERS。HTTP 模式需要 MCP_AUTH_TOKEN 供用戶端存取。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Openapi Mcp,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
OpenAPI MCP
Turn any OpenAPI 3 spec into a working MCP server. One file, about 130 lines, no dependencies.
Every API endpoint becomes a tool that an AI client (Claude, Cursor, etc.) can call. There is no code generation and no per-endpoint files. The spec is read at startup, and the tools are built in memory.
Quick start
Requires Node 18 or newer.
It prints openapi-mcp: 4 tools from "Animechan" -> ... and then waits silently for an MCP client. That is normal: it talks JSON-RPC over stdin/stdout and is not meant to be read by humans.
Use it with an AI client
Claude Desktop (local mode)
Add this to ~/Library/Application Support/Claude/claude_desktop_config.json, then restart the app:
If the client can't find node, use the full path from which node.
Claude Code (remote mode)
Start the server, then register it:
Then ask in plain English: "give me a random quote from Naruto".
Two modes
In HTTP mode, clients send JSON-RPC messages as POST http://host:<port>/mcp. Put --http <port> last.
Test it by hand:
Options
Big APIs can have hundreds of endpoints. Too many tools makes the model choose worse, so use TOOL_FILTER to keep the useful ones.
Authentication
The server reads securitySchemes from the spec and puts your secret in the right place. You only supply the secret as an environment variable:
Example for Claude Desktop:
Notes:
- If the spec declares a security scheme but no credentials are set, a warning is printed to stderr at startup.
- If the spec lists several schemes, the first one in the top-level
securitylist is used (or the first one defined). Per-endpointsecurityoverrides are not applied, so the secret is sent on every call. - OAuth client credentials are sent as HTTP Basic auth to the token endpoint.
- The OAuth browser login (authorization-code flow) is not built in. Get a token or refresh token once with your provider's tools, then pass it in.
- If a provider rotates refresh tokens, the new one is kept in memory only, so it is lost on restart.
How it works
- Load the spec and resolve
$refpointers. - Build tools: each operation becomes one MCP tool.
operationIdis the name,summarythe description, and parameters plus request body the input schema. - Call: a tool call makes the real HTTP request and returns
HTTP <status>followed by the response body (cut at 50,000 characters). - Serve the tools over JSON-RPC 2.0, via stdio or HTTP.
APIs without an OpenAPI spec
Many small public APIs only have HTML docs. For those, write a small spec by hand (see sample/animechan.openapi.json, 4 tools in about 35 lines), then run it the same way.
Limitations
- OpenAPI 3 only. Convert Swagger 2.0 specs first.
- JSON request bodies only. No file uploads.
- Auth: bearer, basic, API keys, and OAuth2 client-credentials or refresh-token. There is no interactive OAuth login, and one scheme is used per API.
- HTTP mode speaks plain HTTP (put HTTPS in front when deploying) and has no streaming, batch requests, or OAuth for clients connecting to the server (it only supports the
MCP_AUTH_TOKENbearer token). Some remote clients may require these. - HTTP mode speaks plain HTTP (put HTTPS in front when deploying) and has no streaming, batch requests, or OAuth. Some remote clients may require these.
- If you deploy remotely, every user shares your server's IP, so upstream rate limits apply to all of them. Set
MCP_AUTH_TOKEN, or anyone who finds the URL can use your API key.
Contributing
Issues and pull requests are welcome. The goal is to stay small and readable, so please keep new features to a few lines each.
來源:README.md,提交 0990a08
工具
0版本歷史
1- v0.1.1最新Oct 12, 2026
評分
已滿足適用檢查項的 40%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分
請在儲存庫或註冊中心條目中宣告授權條款。