mcp-openapi-swagger
An MCP server that crawls and parses OpenAPI JSON or Swagger UI URLs to provide concise endpoint summaries. It enables LLMs to discover and interact with API interfaces by extracting methods, paths, and operation IDs from documentation sources.
README
mcp-openapi-swagger
一个基于 NodeJS 的 MCP Server:输入 OpenAPI JSON URL 或 Swagger UI URL,自动抓取/解析文档并返回接口清单(summary 级),供 Cursor 的提示词继续处理。
你会得到什么
- 支持两种输入:
- OpenAPI JSON URL(例如
/openapi.json、/v3/api-docs) - Swagger UI URL(例如
/swagger-ui/index.html),会自动发现其背后的 spec URL
- OpenAPI JSON URL(例如
- 输出:
method + path + summary + tags + operationId
安装依赖与构建
npm install
npm run build
构建产物在 dist/,并且已配置 bin,可以被 npx 直接执行。
在 Cursor 配置 MCP(npx 启动本地目录)
项目内已提供示例配置:.cursor/mcp.json。
关键配置如下(示例):
{
"mcpServers": {
"openapi-swagger": {
"transport": "stdio",
"command": "npx",
"args": ["-y", "E:/API-MCP"],
"env": {
"OPENAPI_SOURCE_URL": "https://example.com/v3/api-docs"
}
}
}
}
把
E:/API-MCP替换成你本机的项目根目录路径。你也可以把
OPENAPI_SOURCE_URL配成 Swagger UI 地址(例如https://example.com/swagger-ui/index.html)。
工具(Tools)
openapi_setSource
缓存一个文档地址,后续 openapi_listEndpoints 可省略入参。
输入:
{ "sourceUrl": "https://example.com/swagger-ui/index.html" }
openapi_listEndpoints
抓取并解析 OpenAPI,然后返回接口清单(summary 级)。
输入(两种用法二选一):
{ "sourceUrl": "https://example.com/v3/api-docs" }
或(使用已缓存的 source):
{}
如果你在
.cursor/mcp.json里配置了OPENAPI_SOURCE_URL,那么第一次调用openapi_listEndpoints直接传{}就能生效。
输出示例:
{
"ok": true,
"source": {
"inputUrl": "https://example.com/swagger-ui/index.html",
"resolvedSpecUrl": "https://example.com/v3/api-docs",
"openapiVersion": "3.0.3"
},
"endpoints": [
{
"method": "GET",
"path": "/pets/{id}",
"operationId": "getPetById",
"summary": "Get a pet",
"tags": ["pets"]
}
]
}
失败时输出示例(便于提示词分支处理):
{
"ok": false,
"stage": "fetch/parse/extract",
"inputUrl": "https://example.com/swagger-ui/index.html",
"details": {
"name": "Error",
"message": "Failed to discover spec URL from Swagger UI page"
}
}
运行/调试
npm run dev
如果你要验证 npx 启动(Cursor 同款):
npx -y E:/API-MCP
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。