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
Metadata
Release files for swagger-mcp-python 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| swagger_mcp_python-1.0.0.tar.gz | 13.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| swagger_mcp_python-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 28.3 kB
Release files / swagger_mcp_python-1.0.0.tar.gz
| Download URL | swagger_mcp_python-1.0.0.tar.gz |
|---|---|
| Size | 13.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
236066f6254b7b6e285f1f8cc6de9883aa7ed32cc2adeee607609a09113d48b9
|
|
BLAKE2b-256 checksum How to use checksums |
dcfec4b62368faf888d5bb2b6d1856d6cf3a026a4f75cc3e271bd9347885ef91
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Release files / swagger_mcp_python-1.0.0-py3-none-any.whl
| Download URL | swagger_mcp_python-1.0.0-py3-none-any.whl |
|---|---|
| Size | 14.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1bcc9af614e6d4bc5d28852167086af1fe7e8879a94d38e7cad4b6ba3bea8587
|
|
BLAKE2b-256 checksum How to use checksums |
69b165f0e98c1ecac474ef014ecfe1af90a7d27d368103243d67c99a51cfa96d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Security for swagger-mcp-python 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.