
Openapi
io.github.Docat0209由 GitHub 账号 Docat0209 发布v0.2.3更新于 Oct 24, 2026
Turn any OpenAPI/Swagger spec into MCP tools. Zero config, zero code.
概览
把任意 OpenAPI 3.x 或 Swagger 2.0 规范转成 MCP 工具,让助手直接调用该规范描述的 REST API 接口。
- 可以做什么
- 根据 URL 或本地文件中的 OpenAPI/Swagger 规范生成 MCP 工具,每个接口对应一个工具
- 调用底层 REST API 接口,路径、查询、请求头和请求体参数被合并为单一扁平参数结构
- 按 operationId 筛选要暴露的接口,并为工具名添加前缀
- 通过搜索操作、按标签列出、查看工具详情等元工具浏览大型 API
- 支持 Bearer 令牌、API Key 或 OAuth2 客户端凭据认证,并对 429/5xx 自动重试
- 适用场景
- 当你已有文档化的 REST API,希望助手直接调用它,而不必编写自定义 MCP 服务器或手写工具定义时适用。适合规范较完整的公开或内部 API,也适合接口数量庞大、需要动态发现来控制工具列表的场景。
- 运行要求
- 需要 Node.js 18 或更高版本,通过 npx 本地运行或作为库使用。需要一个 OpenAPI 3.x 或 Swagger 2.0 规范,可为远程 URL 或本地文件。需要能访问该规范以及 API 本身的网络。凭据通过命令行参数或配置文件传入,可引用 GITHUB_TOKEN、MCP_OPENAPI_LICENSE_KEY 等环境变量。
安装
在 SourceWeft 中
- 打开 控制台中的 Openapi,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
mcp-openapi
Turn any OpenAPI/Swagger spec into MCP tools — so Claude and other AI assistants can call your REST APIs.
[npm version] [License: MIT] [npm downloads]
Point mcp-openapi at any OpenAPI 3.x or Swagger 2.0 spec URL and it generates Model Context Protocol (MCP) tools automatically. No code generation, no config files, no boilerplate. Your AI assistant gets callable tools for every API endpoint in seconds.
Quick Start
1. Run it (no install required):
2. Add it to Claude Desktop (claude_desktop_config.json):
3. Ask Claude to use it:
"List all available pets in the store"
Claude sees MCP tools like find_pets_by_status, get_pet_by_id, add_pet and calls them directly.
Why mcp-openapi?
Most MCP-to-API bridges require you to write tool definitions by hand or generate code from a spec. mcp-openapi skips all of that.
Flat parameter schemas are the key differentiator. Instead of passing nested JSON objects (which LLMs frequently get wrong), mcp-openapi flattens path, query, header, and body parameters into a single flat object. This dramatically improves tool-calling accuracy.
How It Works
Each API endpoint becomes one MCP tool:
- Tool name is derived from
operationId(converted tosnake_case) or frommethod + path - Parameters are flattened into a single input schema (path, query, header, and body params merged)
- Responses are truncated to ~50KB to stay within LLM context limits
- Errors (429, 5xx) trigger automatic retries with exponential backoff (up to 3 retries)
Claude Desktop Integration
Add any API to Claude Desktop by editing your config file:
Location:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
Public API (no auth)
API with Bearer Token
API with API Key
CLI Reference
General Options
Auth Options
Bearer token:
API key:
OAuth2 client credentials:
CLI Examples
Config File Format
Instead of CLI flags, you can use a JSON config file:
CLI arguments take precedence over config file values.
Supported Specs
Specs can be loaded from:
- Remote URLs (
https://...) - Local file paths (
./api.yaml,/absolute/path/spec.json)
v0.3.0 Features
Doc Quality Warnings
On startup, mcp-openapi checks each tool's documentation quality. If endpoints have sparse descriptions (under 50 characters), you'll see a warning:
This helps you identify which API endpoints might cause poor LLM tool-calling accuracy. Suppress with --no-doc-warnings.
Server Filtering
OpenAPI specs can define multiple servers (production, staging, dev). Select which one to use:
If the selector doesn't match, you'll see all available servers listed.
Dynamic Tool Discovery
For large APIs with 100+ endpoints, registering all tools at once can overwhelm the LLM's context. Dynamic discovery solves this by registering 3 meta-tools instead:
The LLM explores the API through these meta-tools, then calls specific endpoints by name.
Or via config file:
Pro Features (v0.2.0+)
mcp-openapi includes optional Pro features for teams and power users, gated by a license key.
Custom Response Transforms
Shape API responses with JMESPath expressions before they reach the LLM — reducing token usage and improving accuracy:
Smart Response Handling
Instead of hard-truncating large responses at 50KB, Pro enables intelligent truncation:
- Array slicing: Large arrays show first N items + metadata (
"showing 10 of 847 items") - Depth pruning: Deep nested objects are summarized beyond a configurable depth
- Structure preservation: You always see the shape of the data, never a mid-JSON cut
Coming Soon
- Multi-API Composition — Load multiple OpenAPI specs into one MCP session
- Usage Analytics — Track tool calls, latency, and error rates
Interested in Pro? Star the repo and open an issue to get early access.
Programmatic Usage
You can also use mcp-openapi as a library in your own MCP server:
Requirements
- Node.js 18 or later
- An OpenAPI 3.x or Swagger 2.0 spec (URL or local file)
Contributing
Contributions are welcome. Here is how to get started:
Before submitting a PR:
- Add tests for new features
- Run
pnpm lintand fix any issues - Follow Conventional Commits for commit messages
Related
- graphql-to-mcp — Same zero-config approach for GraphQL APIs
License
MIT
Keywords
mcp, model-context-protocol, openapi, swagger, claude, ai, llm, api, tools, rest-api, ai-tools, mcp-server
来源:README.md,提交 fff16ab
工具
0版本历史
1- v0.2.3最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分