openapi -generator
A Python tool that automatically converts OpenAPI(Swagger, ETAPI) compatible 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. https://pypi.org/project/openapi-mcp-generator/
claude mcp add --transport stdio abutbul-openapi-mcp-generator python -m openapi_mcp_generator.cli openapi.yaml --output-dir ./output --api-url https://api.example.com
How to use
OpenAPI to MCP Server Generator is a Python-based tool that translates OpenAPI specifications into fully functional MCP servers. It preserves a modular CLI and can be installed as a package, allowing you to generate server stubs, docker-ready configurations, and transport options (SSE or IO) from your OpenAPI files. After generation, you can build and run the resulting MCP server using the included Docker scripts or by running the server directly via the generated project templates. The tool supports multiple authentication methods and includes logging, rate limiting, and error handling baked into the generated code. To use it, install the package, run the modular CLI (mcp-generator) with your OpenAPI spec, and point the output to a desired directory. You can also invoke the Python module directly if you prefer to integrate it into custom Python workflows.
How to install
Prerequisites:
- Python 3.10 or newer
- Docker (for running generated servers)
- pip (or uv) as Python package manager
-
Clone the repository (or install from PyPI):
- From source: git clone https://github.com/abutbul/openapi-mcp-generator.git cd openapi-mcp-generator
-
Install in editable/development mode (from source):
- Using pip: pip install -e .
-
Alternatively, install from PyPI:
- Using pip: pip install openapi-mcp-generator
-
Verify installation:
- Run the CLI help to confirm it is available: mcp-generator --help
-
Run generation:
- Example: mcp-generator samples/TriliumNext/etapi.openapi.yaml --output-dir ./output --api-url https://api.example.com
Note: If you prefer the original entry point, you can still run: python generator.py openapi.yaml --output-dir ./output --api-url https://api.example.com
Additional notes
Tips and common considerations:
- The generator creates Docker-ready projects with multi-stage builds by default. Use the provided docker.sh script in the generated output to build, start, stop, and manage containers.
- You can switch authentication types (bearer, token, basic) via the CLI options when generating the server.
- The environment for running the generated MCP server (in production) typically requires Docker and appropriate network configuration; ensure ports are exposed as needed (default 8000 for the generated server).
- If you encounter generator template mismatches, ensure you are using a compatible OpenAPI specification (OpenAPI 3.x) and that your templates directory is intact in the source repository.
- The tool can be used programmatically by importing the generator module and invoking its API from Python code for automation workflows.
Related MCP Servers
mcpo
A simple, secure MCP-to-OpenAPI proxy server
PPTAgent
An Agentic Framework for Reflective PowerPoint Generation
mcp-aktools
📈 提供股票、加密货币的数据查询和分析功能MCP服务器
mcp -odoo
A Model Context Protocol (MCP) server that enables AI assistants to securely interact with Odoo ERP systems through standardized resources and tools for data retrieval and manipulation.
mcp-cyberbro
Using MCP is fun with Cyberbro!
the -company
TheMCPCompany: Creating General-purpose Agents with Task-specific Tools