Mcp Swagger Server
@zaizaizhao
MCP Swagger Server 将任何符合 OpenAPI/Swagger 规范的 REST API 转换为 Model Context Protocol (MCP) 格式,让 AI 助手能够理解和调用您的 API。
概要
What is Mcp Swagger Server?
Mcp Swagger Server (MSS) is a tool that converts OpenAPI/Swagger specifications into tools compatible with the Model Context Protocol (MCP). It enables AI assistants to call REST APIs by automatically generating MCP tool definitions from an OpenAPI document. The tool is intended for developers who want to expose existing REST APIs to MCP‑based AI clients without manual integration.
How to use Mcp Swagger Server?
Install via npm: npm i mcp-swagger-server -g. Run the interactive CLI with mss, or use command-line flags for non‑interactive startup, e.g., mss --openapi <url> --transport stdio. Configuration can be provided via CLI options, a .env file, or a JSON config file (--config).
Key features of Mcp Swagger Server
- Zero‑configuration conversion from OpenAPI to MCP tools
- Interactive CLI for step‑by‑step setup
- Supports SSE, Streamable, and Stdio transports
- Bearer token authentication for secured APIs
- Operation filtering by HTTP method, path, operation ID, and parameters
Use cases of Mcp Swagger Server
- Connecting a Swagger‑defined REST API to Claude Desktop as a set of MCP tools
- Converting a private API with Bearer token authentication for use with MCP clients
- Rapidly prototyping AI‑tool interfaces from existing OpenAPI 2.0/3.x documents
FAQ from Mcp Swagger Server
What are the runtime requirements?
Node.js ≥ 20.0.0 and pnpm ≥ 8.0.0 (recommended).
What transport protocols are supported?
Stdio, SSE, and Streamable. Interactive mode does not support STDIO; use mss --openapi ... --transport stdio for STDIO.
How do I authenticate API calls with Bearer token?
Use --auth-type bearer and either --bearer-token (direct token) or --bearer-env (environment variable). Tokens can also be placed in a .env file.
Can I filter which operations are exposed as tools?
Yes. Use flags such as --operation-filter-methods, --operation-filter-paths, --operation-filter-operation-ids, and --operation-filter-parameters to limit the generated tools.
Does the tool support OpenAPI 2.0 (Swagger)?
Yes. Swagger 2.0 documents are automatically converted to OpenAPI 3.x at startup, including mapping of host/basePath.