A Python MCP server that turns Swagger/OpenAPI documentation into AI-callable tools
Project description
Swagger MCP Server (Python)
A Python implementation of a Model Context Protocol (MCP) server that transforms Swagger/OpenAPI documentation into AI-callable tools. This enables AI assistants (like Claude, Gemini) to interact with REST APIs through Swagger documentation.
Features
- 7 MCP Tools: Same functionality as the TypeScript version
- Multi-service Support: Configure multiple Swagger endpoints simultaneously
- Auto-authentication: Cache tokens from 401 responses and auto-inject
- Smart Parameter Completion: Fill required fields with reasonable defaults
- Network Auto-correction: Handle localhost vs 127.0.0.1 connectivity issues
- Caching: 5-minute TTL for Swagger documents with automatic refresh
Installation
pip install -e .
Usage
As an MCP Server
Configure in your MCP client (Claude Desktop, Windsurf, etc.):
{
"mcpServers": {
"swagger-python": {
"command": "python",
"args": [
"-m",
"swagger_mcp",
"http://localhost:8090/v3/api-docs"
]
}
}
}
Command Line Arguments
- Single service:
http://localhost:8090/v3/api-docs - Multiple services:
user=http://localhost:8090/v3/api-docs order=http://localhost:8091/v3/api-docs - Authentication:
auth=admin:123456orauth=/login/path:user:pass
Available Tools
list_services- List configured Swagger servicesrefresh_docs- Force refresh cached Swagger documentationlist_endpoints- List all available API endpointssearch_apis- Intelligent fuzzy search with weighted matchingget_endpoint_details- Get complete endpoint definition with parameters and schemasdebug_endpoint- Execute real HTTP requests with auto-authentication and smart parameter completiongenerate_curl- Generate cURL commands for API calls
Development
# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Format code
black src/
# Lint code
ruff check src/
Project Structure
src/swagger_mcp/
├── __main__.py # Entry point
├── server.py # MCP server implementation
├── services/
│ └── loader.py # Swagger document loading, caching, auth management
├── tools/
│ └── __init__.py # All MCP tool implementations
├── utils/
│ └── schema.py # JSON Schema resolution utilities
└── types/
└── swagger.py # Pydantic models for Swagger documents
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file swagger_mcp_python-1.0.0.tar.gz.
File metadata
- Download URL: swagger_mcp_python-1.0.0.tar.gz
- Upload date:
- Size: 13.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
236066f6254b7b6e285f1f8cc6de9883aa7ed32cc2adeee607609a09113d48b9
|
|
| MD5 |
950a51b3aa99a651d5f39ae66437ac9d
|
|
| BLAKE2b-256 |
dcfec4b62368faf888d5bb2b6d1856d6cf3a026a4f75cc3e271bd9347885ef91
|
File details
Details for the file swagger_mcp_python-1.0.0-py3-none-any.whl.
File metadata
- Download URL: swagger_mcp_python-1.0.0-py3-none-any.whl
- Upload date:
- Size: 14.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1bcc9af614e6d4bc5d28852167086af1fe7e8879a94d38e7cad4b6ba3bea8587
|
|
| MD5 |
9ebed0d6f9bd77fd987139c4a34d52da
|
|
| BLAKE2b-256 |
69b165f0e98c1ecac474ef014ecfe1af90a7d27d368103243d67c99a51cfa96d
|