Get the FREE Ultimate OpenClaw Setup Guide →

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/

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
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
  1. Clone the repository (or install from PyPI):

  2. Install in editable/development mode (from source):

    • Using pip: pip install -e .
  3. Alternatively, install from PyPI:

    • Using pip: pip install openapi-mcp-generator
  4. Verify installation:

    • Run the CLI help to confirm it is available: mcp-generator --help
  5. 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

Sponsor this space

Reach thousands of developers