Fire in da houseTop Tip:Paying $100+ per month for Perplexity, MidJourney, Runway, ChatGPT and other tools is crazy - get all your AI tools in one site starting at $15 per month with Galaxy AI Fire in da houseCheck it out free

swagger-mcp

MCP.Pizza Chef: danishjsheikh

swagger-mcp is an MCP server that extracts swagger.json from Swagger UI and dynamically generates MCP tools at runtime. It enables MCP clients to discover and use API tools automatically, streamlining integration with RESTful APIs defined by Swagger specifications. This server simplifies connecting LLMs to live API endpoints by converting Swagger definitions into actionable MCP tools.

Use This MCP server To

Automatically generate MCP tools from Swagger API definitions Enable MCP clients to call REST APIs dynamically Integrate LLMs with live Swagger-documented APIs Simplify API tool discovery for MCP clients Facilitate runtime tool creation from Swagger JSON

README

swagger-mcp

Overview

swagger-mcp is a tool designed to scrape Swagger UI by extracting the swagger.json file and dynamically generating well-defined mcp tools at runtime. These tools can be utilized by the MCP client for further tool selection.

📽️ Demo Video

Check out demo video showcasing the project in action:
Watch the Demo

🙌 Support

If you find this project valuable, please support me on LinkedIn by:

  • 👍 Liking and sharing our demo post
  • 💬 Leaving your thoughts and feedback in the comments
  • 🔗 Connecting with me for future updates

Your support on LinkedIn will help me reach more people and improve the project!

Prerequisites

To use swagger-mcp, ensure you have the following dependencies:

  1. LLM Model API Key / Local LLM: Requires access to OpenAI, Claude, or Ollama models.
  2. Any MCP Client: (Used mark3labs - mcphost)

Installation and Setup

Follow these steps to install and run swagger-mcp:

go install github.com/danishjsheikh/swagger-mcp@latest
swagger-mcp

Run Configuration

To run swagger-mcp directly, use:

swagger-mcp --specUrl=https://your_swagger_api_docs.json

Main flags:

  • --specUrl: Swagger/OpenAPI JSON URL (required)
  • --sseMode: Run in SSE mode (default: false, if true runs as SSE server, otherwise uses stdio)
  • --sseAddr: SSE server listen address in IP:Port or :Port format (if empty, will use IP:Port from --sseUrl)
  • --sseUrl: SSE server base URL (if empty, will use sseAddr to generate, e.g. http://IP:Port or http://localhost:Port)
  • If both --sseAddr and --sseUrl are set, they are used as-is without auto-complement.
  • --baseUrl: Override base URL for API requests
  • --security: API security type (basic, apiKey, or bearer)
  • --basicAuth: Basic auth in user:password format
  • --bearerAuth: Bearer token for Authorization header
  • --apiKeyAuth: API key(s), format passAs:name=value (e.g. header:token=abc,query:user=foo,cookie:sid=xxx)
  • See main.go for all supported flags and options.

MCP Configuration

To integrate with mcphost, include the following configuration in .mcp.json:

{
    "mcpServers":
    {
        "swagger_loader": {
            "command": "swagger-mcp",
            "args": ["--specUrl=<swagger/doc.json_url>"]
        }
    }
}

Demo Flow

  1. Some Backend:

    go install github.com/danishjsheikh/go-backend-demo@latest 
    go-backend-demo
  2. Ollama

    ollama run llama3.2
  3. MCP Client

    go install github.com/mark3labs/mcphost@latest
    mcphost -m ollama:llama3.2 --config <.mcp.json_file_path>

Flow Diagram

Flow Diagram

🛠️ Need Help

I am working on improving tool definitions to enhance:
Better error handling for more accurate responses
LLM behavior control to ensure it relies only on API responses and does not use its own memory
Preventing hallucinations and random data generation by enforcing strict data retrieval from APIs

If you have insights or suggestions on improving these aspects, please contribute by:

  • Sharing your experience with similar implementations
  • Suggesting modifications to tool definitions
  • Providing feedback on current limitations

Your input will be invaluable in making this tool more reliable and effective! 🚀

swagger-mcp FAQ

How does swagger-mcp generate tools?
It scrapes the swagger.json file from Swagger UI and dynamically creates MCP tools at runtime based on the API definitions.
What types of APIs does swagger-mcp support?
It supports RESTful APIs documented with Swagger/OpenAPI specifications.
Can swagger-mcp handle API changes automatically?
Yes, since it generates tools dynamically at runtime, it can adapt to updated Swagger definitions without manual intervention.
How do I integrate swagger-mcp with an MCP client?
The MCP client can query swagger-mcp to discover and invoke generated tools representing the API endpoints.
Is swagger-mcp compatible with multiple LLM providers?
Yes, it works with any MCP client regardless of the underlying LLM provider, including OpenAI, Claude, and Gemini.
What prerequisites are needed to run swagger-mcp?
You need access to a Swagger UI endpoint exposing a swagger.json file and a compatible MCP client to consume the generated tools.
Does swagger-mcp support authentication for APIs?
swagger-mcp can include authentication details if specified in the Swagger definition, enabling secure API calls through generated tools.
Where can I see a demo of swagger-mcp?
A demo video is available on LinkedIn showcasing swagger-mcp in action, linked in the project README.