Swagger MCP 工具

siglestep/swagger-mcp-tool
0 Stars 60 次浏览 更新于 2026-08-23

一个MCP(模型上下文协议)服务器,加载Swagger/OpenAPI文档,并为AI助手和MCP客户端提供查询工具,支持直接生成与API相关的代码及TypeScript定义。

MCP 服务配置

复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用

{
  "mcpServers": {
    "swagger-orders": {
      "args": [
        "-y",
        "swagger-mcp-tool",
        "./openapi/orders.yaml"
      ],
      "command": "npx"
    },
    "swagger-petstore": {
      "args": [
        "-y",
        "swagger-mcp-tool",
        "https://example.com/petstore.json"
      ],
      "command": "npx"
    }
  }
}

服务介绍

swagger-mcp-tool

GitHub

简体中文

What is swagger-mcp-tool

An MCP (Model Context Protocol) server that loads Swagger/OpenAPI documents and exposes query tools for AI assistants and MCP clients.

Features

  • Generate API-related code directly through an agent using Swagger docs.
  • Generate response types and interface definitions for TypeScript projects.

Installation

Prerequisites

  • Node.js >= 18
  • npm or npx (for running the CLI)
  • Bun >= 1.0.0 (optional, for development/build)

Install

npm install -g swagger-mcp-tool

Usage

Add one or more server entries to your MCP client config (example for Cursor: ~/.cursor/mcp.json). Use a separate server name per Swagger/OpenAPI document to support multiple projects in parallel.

{
  "mcpServers": {
    "swagger-petstore": {
      "command": "npx",
      "args": ["-y", "swagger-mcp-tool", "https://example.com/petstore.json"]
    },
    "swagger-orders": {
      "command": "npx",
      "args": ["-y", "swagger-mcp-tool", "./openapi/orders.yaml"]
    }
  }
}

Chat panel examples

After the server is configured, describe what you want to add in the chat panel. Start with "View the Swagger doc" to help the agent trigger this tool, for example:

"View the Swagger doc and complete the refund API for the order domain."

API

Tool Description Parameters Output
list_api_groups List all API groups (tags) None JSON array of tag objects
search_apis Search APIs by tag or keyword tag (optional), keyword (optional) JSON array of API summaries
get_api_detail Get full operation detail path, method JSON operation object
get_schema Get schema by $ref or name ref JSON schema object

License

This project is licensed under the MIT License - see the LICENSE file for details.

相关 MCP 服务