Swagger Reader
FreeNot checkedEnables reading and parsing Swagger/OpenAPI specifications to list API endpoints, get detailed endpoint info, search APIs, and generate TypeScript types for req
About
Enables reading and parsing Swagger/OpenAPI specifications to list API endpoints, get detailed endpoint info, search APIs, and generate TypeScript types for request/response.
README
MCP工具,用于读取和解析Swagger/OpenAPI规范,帮助你快速查看项目接口信息。
功能
- 支持配置多个项目的Swagger地址(支持URL和本地文件)
- 获取所有API接口列表
- 获取指定接口的详细信息
- 获取数据模型/Schemas
- 搜索API接口
- 根据接口路径和方法生成TypeScript类型(请求参数、Body、响应)
安装
cd mcp-swagger-reader
npm install
npm run build
MCP配置
Cursor/Claude Desktop配置
在 ~/.cursor/mcp.json 或 ~/Library/Application Support/Claude/mcp.json 中添加:
{
"mcpServers": {
"swagger-reader": {
"command": "node",
"args": [
"/Users/momei/code/my_project/mcp-swagger-reader/dist/index.mjs"
],
"env": {}
}
}
}
环境变量预置项目
可以通过 SWAGGER_PROJECTS 环境变量预置项目:
{
"mcpServers": {
"swagger-reader": {
"command": "node",
"args": ["/path/to/dist/index.mjs"],
"env": {
"SWAGGER_PROJECTS": "[{\"name\":\"my-api\",\"swaggerUrl\":\"http://example.com/swagger.json\"}]"
}
}
}
}
支持多个项目:
"SWAGGER_PROJECTS": "[{\"name\":\"api1\",\"swaggerUrl\":\"http://...\"},{\"name\":\"api2\",\"swaggerUrl\":\"http://...\"}]"
数据存储
项目配置保存在 ~/.mcp-swagger-reader/projects.json,重启后自动加载。
工具列表
add_swagger_project
添加一个项目的Swagger配置。
参数:
name: 项目名称swaggerUrl: Swagger/OpenAPI JSON文件的URL地址或本地文件路径
示例:
await add_swagger_project({
name: "my-project",
swaggerUrl: "https://api.example.com/v2/api-docs",
});
list_swagger_projects
列出所有已配置的Swagger项目。
get_api_endpoints
获取指定项目的所有API接口列表。
参数:
projectName: 项目名称
get_api_detail
获取指定接口的详细信息。
参数:
projectName: 项目名称path: API路径,如/users/{id}method: HTTP方法,如GET,POST
get_schemas
获取指定项目的所有数据模型/Schemas。
参数:
projectName: 项目名称
search_apis
根据关键词搜索API接口。
参数:
projectName: 项目名称keyword: 搜索关键词
reload_swagger
重新加载项目的Swagger规范。
参数:
projectName: 项目名称
generate_ts_by_endpoint
根据 API 接口路径和方法生成 TypeScript 类型(请求参数、Body、响应)。
参数:
projectName: 项目名称path: API路径,如/access/packageUnit/queryListmethod: HTTP方法,如GET,POST,PUT,DELETE
返回:
T{Endpoint}Params- 请求参数接口T{Endpoint}Response- 响应类型接口
使用示例
- 首先添加项目配置:
await add_swagger_project({
name: "user-service",
swaggerUrl: "https://petstore.swagger.io/v2/swagger.json",
});
- 查看所有接口:
await get_api_endpoints({ projectName: "user-service" });
- 获取某个接口详情:
await get_api_detail({
projectName: "user-service",
path: "/pet/{petId}",
method: "GET",
});
- 搜索接口:
await search_apis({
projectName: "user-service",
keyword: "user",
});
Installing Swagger Reader
This server has no published package — it is built from source. Open the repository and follow its README.
▸ github.com/momei-LJM/mcp-swagger-readerFAQ
Is Swagger Reader MCP free?
Yes, Swagger Reader MCP is free — one-click install via Unyly at no cost.
Does Swagger Reader need an API key?
No, Swagger Reader runs without API keys or environment variables.
Is Swagger Reader hosted or self-hosted?
Self-hosted: the server runs locally on your machine via the install command above.
How do I install Swagger Reader in Claude Desktop, Claude Code or Cursor?
Open Swagger Reader on unyly.org, pick your client tab (Claude Desktop, Claude Code, Cursor) and press Install — the config is generated automatically, no JSON editing.
Related MCPs
GitHub
PRs, issues, code search, CI status
by GitHubFilesystem
Secure file operations with configurable access controls.
Memory
Knowledge graph-based persistent memory system.
Template MCP Server
A CLI tool to create a new Model Context Protocol server project with TypeScript support, dual transport options, and an extensible structure
by mcpdotdirectCompare Swagger Reader with
Not sure what to pick?
Find your stack in 60 seconds
Author?
Embed badge for your README
Browse similar
All development MCPs
