mcp-swagger-reader
Allows reading and parsing Swagger/OpenAPI specifications to explore API endpoints, get endpoint details, manage data models, search APIs, and generate TypeScript types for requests and responses.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-swagger-reader list all endpoints for the user-service project"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP Swagger Reader
MCP工具,用于读取和解析Swagger/OpenAPI规范,帮助你快速查看项目接口信息。
功能
支持配置多个项目的Swagger地址(支持URL和本地文件)
获取所有API接口列表
获取指定接口的详细信息
获取数据模型/Schemas
搜索API接口
根据接口路径和方法生成TypeScript类型(请求参数、Body、响应)
Related MCP server: Swagger MCP (Multi-API Edition)
安装
cd mcp-swagger-reader
npm install
npm run buildMCP配置
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",
});Available Tools
9 toolsadd_swagger_projectC
添加一个项目的Swagger/OpenAPI配置
Inputs: name (required), swaggerUrl (required).
clear_type_cacheA
清除指定项目的类型缓存,强制重新生成
Inputs: projectName.
generate_ts_by_endpointC
根据 API 接口路径和方法生成 TypeScript 类型(请求参数、Body、响应),作为模型输入,可以进一步调整并输出
Inputs: path (required), method (required), projectName (required).
get_api_detailC
获取指定接口的详细信息
Inputs: path (required), method (required), projectName (required).
get_api_endpointsA
获取指定项目的所有API接口列表
Inputs: projectName (required).
get_schemasB
获取指定项目的所有数据模型/Schemas
Inputs: projectName (required).
list_swagger_projectsA
列出所有已配置的Swagger项目
Inputs: no named parameters.
reload_swaggerB
重新加载项目的Swagger规范,同时清除类型缓存
Inputs: projectName (required).
search_apisB
根据关键词搜索API接口
Inputs: keyword (required), projectName (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 9 tools
Most tools target distinct resources and actions: endpoints, schemas, projects, and type generation are clearly separated. The only potential confusion is between reload_swagger and clear_type_cache, as reload also clears the type cache, but the descriptions clarify that reload additionally re-fetches the spec.
Tool names consistently follow a snake_case verb_noun pattern (get_, list_, add_, search_, clear_, generate_). Minor inconsistencies exist, such as 'get_schemas' missing an 'api' prefix and 'list_swagger_projects' plural versus 'add_swagger_project' singular, but the overall pattern is predictable.
With 9 tools, the server is well-scoped for its purpose. Each tool serves a distinct function within the Swagger/OpenAPI management and code generation workflow, without unnecessary redundancy or bloat.
Core workflows are well covered: project setup, listing, reloading, endpoint discovery, schema inspection, and TypeScript generation. The main gap is that projects can be added but not deleted or updated, which may be a minor limitation for full project lifecycle management.
Maintenance
Related MCP Connectors
Search Visa Developer docs and retrieve OpenAPI specs for Visa product APIs to build integrations.
Schema-aware API monitoring: diff OpenAPI specs for breaking changes, manage endpoints.
Validate OpenAPI and JSON Schema, convert specs, curl to code, JSONPath, and free test data.
Turn any task into the right API calls: discover, evaluate, and integrate public APIs.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to discover, search, and interact with REST APIs by parsing OpenAPI/Swagger specifications with intelligent fuzzy search across endpoints, supporting both local and remote API sources.8 npm2MIT
- AlicenseNot gradedqualityFmaintenanceEnables AI to interact with multiple Swagger/OpenAPI specifications by listing endpoints, exploring models, and generating TypeScript code. It centralizes the management of various APIs through a configuration file, allowing for seamless integration of documentation into AI workflows.MIT
- AlicenseNot gradedqualityDmaintenanceLoads and queries OpenAPI/Swagger documents, providing tools to list APIs, get details, search endpoints, and manage schemas for efficient API exploration.4MIT
- AlicenseAqualityDmaintenanceParses Swagger 2.0 and OpenAPI 3.x specifications, exposing API endpoints, schemas, and authentication through MCP tools with local caching to reduce token usage.1113 npm1MIT