SwaggerMcp
Dynamically generates MCP tools from Swagger/OpenAPI documentation (versions 2.0, 3.0, 3.1), enabling direct access to any REST API defined in a Swagger specification with support for various authentication methods.
Click on "Install 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., "@SwaggerMcpget the latest user profile for user ID 12345"
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.
@yuuzu/swagger-mcp
基於 TypeScript SDK MCP 的 Swagger/OpenAPI MCP 服務器。此工具能夠從 Swagger/OpenAPI 文檔動態生成 MCP 工具,讓 Claude Desktop 可以直接調用 REST API。
功能特色
✅ 支援所有 Swagger/OpenAPI 版本(2.0、3.0、3.1)
✅ 從 URL 或本地文件載入 Swagger 文檔
✅ 動態生成 MCP 工具
✅ 優化的工具命名格式:使用
method-path-group-endpoint格式(如:post-api-auth-signin)✅ 支援多種認證方式(Bearer Token、API Key、Basic Auth)
✅ 自動參數驗證(使用 Zod)
✅ 請求/回應日誌記錄
✅ 自動重新載入 Swagger 文檔
✅ 完整的錯誤處理
Related MCP server: Swagger MCP
系統需求
Node.js >= 20.14
安裝
# Clone 專案
# 使用 npx(推薦)
npx @yuuzu/swagger-mcp
# 或全域安裝
npm install -g @yuuzu/swagger-mcp
# 或從源碼安裝
git clone https://github.com/nakiriyuuzu/swagger-mcp.git
cd swagger-mcp
# 安裝依賴
npm install
# 建構專案
npm run build設定
1. 環境變數設定
複製 .env.sample 並重新命名為 .env:
cp .env.sample .env編輯 .env 檔案,設定您的 Swagger 文檔來源和認證資訊:
# Swagger 文檔來源(擇一)
SWAGGER_URL=https://api.example.com/swagger.json
# 或使用本地檔案
# SWAGGER_PATH=/path/to/swagger.json
# 認證設定
AUTH_TYPE=bearer
AUTH_TOKEN=your-jwt-token-here
# 其他選項
LOG_LEVEL=info2. Claude Desktop 設定
在 Claude Desktop 的設定檔中加入 SwaggerMcp 服務器:
Windows: %APPDATA%\Claude\claude_desktop_config.json
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json
{
"mcpServers": {
"swagger-mcp": {
"command": "npx",
"args": ["@yuuzu/swagger-mcp"],
"env": {
"SWAGGER_URL": "https://api.example.com/swagger.json",
"AUTH_TYPE": "bearer",
"AUTH_TOKEN": "your-jwt-token-here"
}
}
}
}使用方式
重新啟動 Claude Desktop
在對話中,您可以看到從 Swagger 文檔生成的工具
使用工具時,Claude 會自動調用對應的 API
範例對話
User: 使用 API 登入,帳號是 test@example.com,密碼是 password123
Claude: 我會使用 post-api-auth-signin 工具來幫您登入。
[調用工具 post-api-auth-signin]
登入成功!這是您的認證資訊:
- Token: eyJhbGciOiJIUzI1NiIs...
- 過期時間: 2024-01-25T12:00:00Z環境變數說明
必要設定
變數 | 說明 | 範例 |
| Swagger 文檔來源 |
|
認證設定
變數 | 說明 | 預設值 |
| 認證類型:bearer、apikey、basic、none | none |
| 認證 token 或憑證 | - |
| 認證標頭名稱 | Authorization |
| API Key 標頭名稱(apikey 類型) | X-API-Key |
進階設定
變數 | 說明 | 預設值 |
| 覆蓋 Swagger 中的 base URL(重要:如果 Swagger 使用相對 URL,必須設定此項) | - |
| 請求超時時間(毫秒) | 30000 |
| Swagger 文檔重新載入間隔(毫秒) | 3600000 |
| 日誌等級:debug、info、warn、error | info |
| 啟用請求/回應日誌 | false |
API_BASE_URL 設定說明
某些 Swagger 文檔使用相對 URL 作為服務器地址(例如 /api)。在這種情況下,您需要設定 API_BASE_URL 來指定完整的 API 基礎 URL:
# 使用相對 URL 的 API 範例
SWAGGER_URL=https://example.com/api/swagger.json
API_BASE_URL=https://example.com/api支援的認證方式
Bearer Token
AUTH_TYPE=bearer
AUTH_TOKEN=eyJhbGciOiJIUzI1NiIs...API Key
AUTH_TYPE=apikey
AUTH_TOKEN=your-api-key
API_KEY_HEADER=X-API-KeyBasic Auth
AUTH_TYPE=basic
AUTH_TOKEN=username:password開發
開發模式
npm run dev執行測試
npm test程式碼檢查
npm run lint
npm run typecheck專案結構
SwaggerMcp/
├── src/
│ ├── index.ts # 入口點
│ ├── SwaggerMcpServer.ts # 主服務器類
│ ├── parsers/ # Swagger 解析器
│ │ ├── SwaggerParser.ts # 基礎解析器
│ │ ├── OpenApi2Parser.ts # OpenAPI 2.0 解析器
│ │ └── OpenApi3Parser.ts # OpenAPI 3.x 解析器
│ ├── generators/ # 工具生成器
│ │ ├── ToolGenerator.ts # MCP 工具生成
│ │ └── SchemaConverter.ts # Schema 轉換
│ ├── proxy/ # API 代理
│ │ ├── ApiProxy.ts # 請求代理
│ │ └── AuthManager.ts # 認證管理
│ └── utils/ # 工具函數
│ ├── config.ts # 設定管理
│ └── logger.ts # 日誌工具
├── package.json
├── tsconfig.json
└── README.md疑難排解
無法載入 Swagger 文檔
確認 URL 或檔案路徑正確
檢查網路連線
確認 Swagger 文檔格式正確
認證失敗
確認 AUTH_TYPE 設定正確
檢查 token 是否過期
確認認證標頭名稱正確
工具未出現在 Claude Desktop
確認 SwaggerMcp 服務器正在執行
檢查 Claude Desktop 設定檔路徑
重新啟動 Claude Desktop
授權
MIT License
Available Tools
5 toolsexecute_api_requestC
Execute an API request to a specific endpoint
| Name | Required | Description | Default |
|---|---|---|---|
| method | Yes | HTTP method (GET, POST, PUT, DELETE, etc.) | |
| path | Yes | The endpoint path (e.g., '/users/123') | |
| params | No | Query parameters as key-value pairs | |
| body | No | Request body as a JSON object (for POST/PUT/PATCH) | |
| headers | No | Custom headers as key-value pairs |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries full burden but only states the basic action without disclosing behavioral traits. It doesn't mention authentication needs, rate limits, error handling, or what the response looks like (especially since there's no output schema), which are critical for a general API tool.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, efficient sentence with zero waste—it directly states the tool's purpose without fluff. It's appropriately sized and front-loaded, making it easy for an agent to parse quickly.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the complexity of a general API execution tool with 5 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain return values, error cases, or how to interpret results, leaving significant gaps for the agent to navigate.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the schema fully documents all 5 parameters. The description adds no additional meaning beyond what's in the schema, such as examples or constraints, but the baseline is 3 since the schema does the heavy lifting.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description 'Execute an API request to a specific endpoint' states a clear verb ('Execute') and resource ('API request'), but it's vague about scope and doesn't distinguish from siblings like 'fetch_swagger_info' or 'validate_api_response'. It lacks specificity about what type of API or what makes this tool unique.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance is provided on when to use this tool versus alternatives like 'list_endpoints' or 'get_endpoint_details'. The description implies general API execution but doesn't specify contexts, prerequisites, or exclusions, leaving the agent to guess based on tool names alone.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
fetch_swagger_infoC
Fetch Swagger/OpenAPI documentation to discover available API endpoints
| Name | Required | Description | Default |
|---|---|---|---|
| url | No | URL to the swagger.json or swagger.yaml file. If not provided, will try to use the base URL with common Swagger paths. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden. It states the tool fetches documentation but doesn't disclose behavioral traits such as whether it requires authentication, how it handles errors, if it caches results, or what format the output is in. This leaves significant gaps for an agent to understand how to use it effectively.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, clear sentence that efficiently conveys the core purpose. It's appropriately sized and front-loaded with the main action, though it could be slightly more structured by separating purpose from behavior.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's complexity (fetching external documentation) and lack of annotations or output schema, the description is incomplete. It doesn't explain what the tool returns, how to interpret the results, or any prerequisites like network access, making it inadequate for an agent to use confidently.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the schema already documents the 'url' parameter fully. The description adds no additional meaning beyond what the schema provides, such as examples of common Swagger paths or clarification on the fallback behavior. Baseline 3 is appropriate when the schema does the heavy lifting.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose with a specific verb ('Fetch') and resource ('Swagger/OpenAPI documentation'), and explains what it does ('to discover available API endpoints'). It doesn't explicitly differentiate from siblings like 'list_endpoints' or 'get_endpoint_details', but the focus on documentation discovery is reasonably distinct.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus alternatives. With siblings like 'list_endpoints' and 'get_endpoint_details' that might overlap in functionality, there's no indication of when this tool is preferred or what its specific use case is compared to them.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_endpoint_detailsC
Get detailed information about a specific API endpoint
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | The endpoint path to get details for (e.g., '/users/{id}') | |
| method | Yes | The HTTP method (GET, POST, PUT, DELETE, etc.) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool 'gets' information, implying a read-only operation, but doesn't clarify if it requires authentication, has rate limits, returns structured data (e.g., JSON), or handles errors. For a tool with no annotation coverage, this leaves significant gaps in understanding how it behaves beyond basic functionality.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It's front-loaded with the core action ('Get detailed information'), making it easy to parse. Every part of the sentence earns its place by specifying the resource ('API endpoint') and scope ('specific'), achieving optimal conciseness.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's moderate complexity (2 required parameters, no output schema, and no annotations), the description is incomplete. It doesn't explain what 'detailed information' includes (e.g., response formats, error codes, or usage examples), which is critical for an API tool. Without annotations or output schema, the agent lacks context on return values and operational constraints, making this inadequate for effective use.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema has 100% description coverage, with clear documentation for both 'path' and 'method' parameters. The description adds no additional semantic context beyond what the schema provides (e.g., it doesn't explain how the path and method combine to identify an endpoint or give examples beyond the schema's '/users/{id}'). Baseline 3 is appropriate since the schema does the heavy lifting.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose with a specific verb ('Get') and resource ('detailed information about a specific API endpoint'). It distinguishes from siblings like 'list_endpoints' (which likely lists multiple) and 'execute_api_request' (which performs the request rather than getting metadata). However, it doesn't explicitly mention what 'detailed information' includes (e.g., parameters, schemas, examples), which prevents a perfect score.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when to choose this over 'fetch_swagger_info' (which might provide broader API documentation) or 'validate_api_response' (which might check responses). There's no context about prerequisites, such as needing an endpoint path and method from 'list_endpoints' first, leaving the agent to guess usage scenarios.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
list_endpointsB
List all available API endpoints after fetching Swagger documentation
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden. It mentions that endpoints are listed 'after fetching Swagger documentation', which adds some context about dependencies, but it doesn't disclose behavioral traits like whether this is a read-only operation, what the output format is, or if there are rate limits. The description is minimal and lacks essential operational details.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, efficient sentence that states the purpose clearly without unnecessary words. It's appropriately sized for a simple tool, though it could be slightly more front-loaded by emphasizing the core action first.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's simplicity (0 parameters, no output schema), the description is incomplete. It lacks details on what the output looks like (e.g., list format, fields), how it relates to siblings, and behavioral aspects like safety or dependencies. Without annotations or output schema, the description should provide more context to be fully helpful.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The tool has 0 parameters, and schema description coverage is 100%, so there's no need for parameter details in the description. The description doesn't add parameter semantics, but this is acceptable given the lack of parameters, warranting a baseline score of 4 for adequate handling.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the action ('List all available API endpoints') and the resource ('API endpoints'), which is specific and unambiguous. However, it doesn't explicitly distinguish this tool from its sibling 'fetch_swagger_info' or 'get_endpoint_details', which likely have related but different purposes.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage by mentioning 'after fetching Swagger documentation', but it doesn't provide explicit guidance on when to use this tool versus alternatives like 'fetch_swagger_info' or 'get_endpoint_details'. No exclusions or prerequisites are stated, leaving the agent to infer context.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
validate_api_responseB
Validate an API response against the schema from Swagger documentation
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | The endpoint path | |
| method | Yes | The HTTP method | |
| statusCode | Yes | The HTTP status code | |
| responseBody | Yes | The response body to validate |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool validates responses against Swagger schemas, implying a read-only, non-destructive operation, but doesn't describe what happens on validation failure (e.g., error messages, partial validation), performance characteristics, or any authentication needs. For a tool with no annotations, this leaves significant behavioral gaps.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It is front-loaded and wastes no space, making it highly concise and well-structured for quick understanding.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's moderate complexity (4 required parameters, nested objects, no output schema), the description is minimally adequate. It explains what the tool does but lacks details on validation outcomes, error handling, or integration with sibling tools. Without annotations or an output schema, more context on behavior and results would improve completeness, but it meets a basic threshold.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema description coverage is 100%, with all parameters documented in the input schema (path, method, statusCode, responseBody). The description adds no additional parameter semantics beyond what the schema provides, such as format examples or constraints. With high schema coverage, the baseline score of 3 is appropriate, as the description doesn't compensate but doesn't need to heavily.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: 'Validate an API response against the schema from Swagger documentation.' It specifies the verb ('validate') and resource ('API response'), but doesn't explicitly differentiate from sibling tools like 'execute_api_request' or 'fetch_swagger_info' beyond the validation focus. This makes it clear but not fully sibling-distinctive.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing Swagger documentation loaded), exclusions, or how it relates to siblings like 'execute_api_request' (which might produce responses to validate) or 'fetch_swagger_info' (which might provide schemas). Usage is implied from the purpose but not explicitly stated.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
5 tool updates
- First observed
execute_api_request - First observed
fetch_swagger_info - First observed
get_endpoint_details - First observed
list_endpoints - First observed
validate_api_response
TDQS
Each tool has a clearly distinct purpose with no overlap: fetching documentation, listing endpoints, getting endpoint details, executing requests, and validating responses. The descriptions make it easy to differentiate between discovery, execution, and validation phases.
All tools follow a consistent verb_noun pattern (e.g., fetch_swagger_info, list_endpoints, execute_api_request). The naming is predictable and follows the same convention throughout the set.
Five tools is well-scoped for a Swagger/OpenAPI documentation server, covering the essential workflow from discovery to execution and validation. Each tool earns its place without feeling thin or bloated.
The tool set provides complete coverage for the domain: it supports fetching documentation, discovering endpoints, getting details, executing requests, and validating responses. There are no obvious gaps in the API interaction lifecycle.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Discover and call 10,000+ production APIs from one MCP server. Pay-per-call billing for AI agents.
MCP server for AI access to Swagger by SmartBear.
The OpenRouter for tools. One MCP connection gives any AI agent 254 hosted tools, pay per call.
MCP server unifying ERPs, CRMs, APIs and knowledge base for Claude, ChatGPT and Gemini.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA service that converts OpenAPI specifications into MCP tools, enabling AI assistants to interact with your API endpoints through natural language.-
- -licenseNot gradedqualityNot gradedmaintenanceDynamically generates MCP tools from Swagger/OpenAPI specifications by extracting swagger.json files at runtime. Enables natural language interaction with any REST API that has Swagger documentation.-
- FlicenseNot gradedqualityDmaintenanceDynamically converts any REST service's OpenAPI specification into MCP tools, enabling interaction with REST endpoints through natural language. Supports Spring Boot services and includes auto-discovery for common API configurations.-
- AlicenseNot gradedqualityDmaintenanceDynamically generates MCP tools from OpenAPI specifications, enabling AI assistants to interact with any REST API through natural language. Supports multiple APIs with authentication, parameter validation, and integration with Claude Desktop and LangChain.1MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/NakiriYuuzu/SwaggerMcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server