πŸš€ OpenAPI to MCP Server Code Generator

by cnoe-io

39 594 downloads Not rated yet Apache-2.0

About

This tool generates Model Context Protocol (MCP) servers from OpenAPI specifications, producing Python packages that AI assistants can use to interact with APIs. It parses paths, operations, and schemas from OpenAPI specs (JSON or YAML) and renders Jinja2 templates into a…

Details

License
Apache-2.0

Explore

- ⚑ Automatic MCP server generation from OpenAPI specs
- πŸ“ Supports JSON and YAML formats
- πŸ› οΈ Tool modules for each API endpoint
- πŸ€– API client code generation
- πŸ“‹ Logging & error handling setup
- βš™οΈ Configuration files (pyproject.toml, .env.example)
- πŸ“š Comprehensive documentation generation
- πŸš€ --generate-agent flag – additionally produces a LangGraph
React agent (with A2A server, Makefile, README and .env.example)
alongside the generated MCP server
- πŸ“Š --generate-eval: adds interactive eval mode and automated evaluation suite
- 🧠 --generate-system-prompt: generates a SYSTEM prompt for the agent using your configured LLM
- πŸ”Œ Optional SLIM transport support is available (see Experimental section)

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name πŸš€ OpenAPI to MCP Server Code Generator
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

- Install uv
- Generate server (and optionally agent/eval):

  uvx --from git+https://github.com/cnoe-io/openapi-mcp-codegen.git openapi_mcp_codegen \
--spec-file examples/petstore/openapi_petstore.json \
--output-dir examples/petstore \
--generate-agent \
--generate-eval

uv venv && source .venv/bin/activate

uv sync


LLM_PROVIDER=openai
OPENAI_API_KEY=<your-openai-api-key>
OPENAI_ENDPOINT=https://api.openai.com/v1
OPENAI_MODEL_NAME=gpt-5

- Each example requires config.yaml with metadata such as authorization headers
- Generated pyproject.toml includes agent-specific dependencies
- .env.example templates include agent-specific environment variables

bash

```bash

The A2A Inspector is a utility for inspecting and debugging A2A servers. It provides a visual interface to explore agent cards and invoke the agent. Follow the instructions on the project page to build and run the inspector, which should be available at localhost:8080. You can then connect to the agent running on localhost:8000/.well-known/agent.json.

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "\ud83d\ude80 openapi to mcp server code generator": {
            "openapi-mcp-codegen": {
                "command": "uvx",
                "args": [
                    "--from",
                    "git+https://github.com/cnoe-io/openapi-mcp-codegen.git",
                    "openapi_mcp_codegen",
                    "\\"
                ]
            }
        }
    }
}

McpServers

{
    "openapi-mcp-codegen": {
        "command": "uvx",
        "args": [
            "--from",
            "git+https://github.com/cnoe-io/openapi-mcp-codegen.git",
            "openapi_mcp_codegen",
            "\\"
        ]
    }
}

Python
License
Conventional Commits
Ruff Linter
Super Linter
Unit Tests
Dependabot Updates

Overview

This tool generates Model Context Protocol (MCP) servers from OpenAPI specifications, creating Python packages that can be used by AI assistants to interact with APIs. The core architecture transforms OpenAPI specs into structured MCP servers with tools, models, and client code.

Quick Start

- Install uv
- Generate server (and optionally agent/eval):

  uvx --from git+https://github.com/cnoe-io/openapi-mcp-codegen.git openapi_mcp_codegen \
--spec-file examples/petstore/openapi_petstore.json \
--output-dir examples/petstore \
--generate-agent \
--generate-eval

✨ Features

- ⚑ Automatic MCP server generation from OpenAPI specs
- πŸ“ Supports JSON and YAML formats
- πŸ› οΈ Tool modules for each API endpoint
- πŸ€– API client code generation
- πŸ“‹ Logging & error handling setup
- βš™οΈ Configuration files (pyproject.toml, .env.example)
- πŸ“š Comprehensive documentation generation
- πŸš€ --generate-agent flag – additionally produces a LangGraph
React agent (with A2A server, Makefile, README and .env.example)
alongside the generated MCP server
- πŸ“Š --generate-eval: adds interactive eval mode and automated evaluation suite
- 🧠 --generate-system-prompt: generates a SYSTEM prompt for the agent using your configured LLM
- πŸ”Œ Optional SLIM transport support is available (see Experimental section)

How It Works

- You provide an OpenAPI spec (JSON or YAML).
- The generator parses paths, operations, and schemas, then renders Jinja2 templates into a structured Python MCP server.
- Optionally, it generates an accompanying LangGraph agent and A2A server wrapper that can call the generated MCP tools.
- Also supports tracing and evaluation using LangFuse.

Development

Local Development Commands

```bash

No reviews yet β€” be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.