swagger-mcp
Integrates with Ollama to allow running local LLMs as an alternative to cloud-based models for processing API interactions.
Connects with OpenAI models to process API definitions and interact with Swagger-documented endpoints.
Automatically extracts Swagger UI definitions from API endpoints to dynamically generate MCP tools at runtime, enabling AI agents to interact with any Swagger-documented API without manual tool implementation.
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., "@swagger-mcpscrape the Swagger UI from https://api.example.com/docs and generate tools"
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.
swagger-mcp
Overview
swagger-mcp is a tool that reads a Swagger 2.0 or OpenAPI 3.0 specification and dynamically generates MCP tools at runtime — one tool per API endpoint. These tools can be used by any MCP client for LLM-driven API interaction.
Supported spec formats:
Swagger 2.0 (
swagger: "2.0") — path/query/header parameters andin: bodyrequest bodiesOpenAPI 3.0 (
openapi: "3.0.x") — path/query/header parameters andrequestBodywith inline or$refschemas
Required and optional fields are read from the schema's required array and honoured in the generated tool definitions.
Related MCP server: MCP Swagger Server
📽️ Demo Video
Check out demo video showcasing the project in action:
🙌 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:
LLM Model API Key / Local LLM: Requires access to OpenAI, Claude, or Ollama models.
Any MCP Client: (Used mark3labs - mcphost)
Installation and Setup
go install github.com/danishjsheikh/swagger-mcp@latestRun Configuration
Stdio mode (default)
swagger-mcp --specUrl=https://your_swagger_api_docs.jsonSSE mode
swagger-mcp --specUrl=https://your_swagger_api_docs.json --sse --sseAddr=:8080StreamableHTTP mode
swagger-mcp --specUrl=https://your_swagger_api_docs.json --http --httpAddr=:8080All flags
Flag | Description |
| URL or |
| Override the base URL for API requests |
| Run in SSE mode instead of stdio |
| SSE listen address, |
| SSE base URL (auto-derived from |
| Comma-separated request headers to forward from SSE to API (e.g. |
| Run in StreamableHTTP mode instead of stdio |
| StreamableHTTP listen address, |
| StreamableHTTP endpoint path (default |
| Comma-separated request headers to forward from HTTP to API |
| Comma-separated paths or regex patterns to include |
| Comma-separated paths or regex patterns to exclude |
| Comma-separated HTTP methods to include (e.g. |
| Comma-separated HTTP methods to exclude |
| Auth type: |
| Basic auth credentials in |
| Bearer token for the |
| API key(s): |
| Additional static headers for every request, |
Xquik OpenAPI Example
Xquik publishes a remote OpenAPI document for its X/Twitter automation API.
Because it uses an API key header, pass the key with --security=apiKey and
--apiKeyAuth:
export XQUIK_API_KEY="your-xquik-api-key"
swagger-mcp \
--specUrl=https://xquik.com/openapi.json \
--baseUrl=https://xquik.com \
--security=apiKey \
--apiKeyAuth=header:x-api-key=$XQUIK_API_KEYThe same arguments can be used in an MCP client config:
{
"mcpServers": {
"xquik": {
"command": "swagger-mcp",
"args": [
"--specUrl=https://xquik.com/openapi.json",
"--baseUrl=https://xquik.com",
"--security=apiKey",
"--apiKeyAuth=header:x-api-key=<XQUIK_API_KEY>"
]
}
}
}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>"]
}
}
}With bearer auth and path filtering:
{
"mcpServers": {
"swagger_loader": {
"command": "swagger-mcp",
"args": [
"--specUrl=https://api.example.com/openapi.json",
"--security=bearer",
"--bearerAuth=your-token-here",
"--includeMethods=GET,POST"
]
}
}
}Request Body Support
Both Swagger 2.0 and OpenAPI 3.0 request bodies are supported:
Swagger 2.0:
parameterswithin: bodyand a$refor inline schema underdefinitionsOpenAPI 3.0:
requestBody.content.<media-type>.schema— resolved fromcomponents/schemasif a$ref, or used inline if an object schema
Fields listed in the schema's required array are marked as required in the MCP tool. All other fields are optional and are omitted from the request if not provided.
Demo Flow
Some Backend:
go install github.com/danishjsheikh/go-backend-demo@latest go-backend-demoOllama
ollama run llama3.2MCP Client
go install github.com/mark3labs/mcphost@latest mcphost -m ollama:llama3.2 --config <.mcp.json_file_path>
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! 🚀
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- 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/danishjsheikh/swagger-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server