A Python tool that automatically converts OpenAPI specifications into fully functional Model Context Protocol (MCP) servers. Generates Docker-ready implementations with support for SSE/IO communication protocols, authentication, and comprehensive error handling.
- 🔄 OpenAPI to MCP tools/resources conversion
- 🐳 Docker-ready with multi-stage builds
- 🔐 Multiple authentication methods
- ⚡ Async operations & rate limiting
- 📡 SSE/IO communication protocols
This generator creates a fully functional MCP server implementation that exposes API operations defined in an OpenAPI specification as MCP tools and resources. The generated server is packaged with Docker for easy deployment and supports both SSE and IO communication protocols.
- Convert OpenAPI specifications to MCP servers
- Docker-ready implementation with multi-stage builds
- Support for multiple authentication methods
- Choice of SSE or IO communication protocols
- Comprehensive error handling and logging
- Built-in rate limiting and security features
- Async operations for optimal performance
- Extensive test suite with coverage reporting
- Python 3.10+
- Docker (for running the generated server)
- uv (Python package manager)
# Clone the repository
git clone https://github.com/abutbul/openapi-mcp-generator.git
cd openapi-mcp-generator
# Install dependencies using uv
uv venv
source .venv/bin/activate
uv pip install -r requirements.txt
python generator.py openapi.yaml --output-dir ./output --api-url https://api.example.com
openapi_file
: Path to the OpenAPI YAML file (required)--output-dir
: Output directory for the generated project (default: '.')--api-url
: Base URL for the API--auth-type
: Authentication type (bearer, token, basic)--api-token
: API token for authentication--api-username
: Username for basic authentication--api-password
: Password for basic authentication
After generating the server, you can build and run it using Docker:
cd output/openapi-mcp-*
./docker.sh build
./docker.sh start --transport=sse --port=8000
The generated docker.sh
script supports the following commands:
build
: Build the Docker imagestart
: Start the container--port=PORT
: Set the port (default: 8000)--transport=TYPE
: Set transport type: 'sse' or 'io' (default: sse)--log-level=LEVEL
: Set logging level (default: info)
stop
: Stop the containerclean
: Remove the container and imagetest
: Run the test suite (TBD)logs
: View container logs
For more detailed information, see:
TBD
Check out our sample implementations to see the generator in action:
- Trilium Notes ETAPI Server - An MCP server for the Trilium Notes knowledge management system's ETAPI
- Fork the repository
- Create a feature branch
- Make your changes
- Run the test suite
- Submit a pull request
This project is licensed under the MIT License - see the (./LICENSE) file for details.