πŸš€ OpenAPI to MCP Server Code Generator

by cnoe-io

39 stars
594 downloads
Not rated
GitHub Website

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

Author
cnoe-io
GitHub stars
39
Downloads
594
Categories
Developer Tools, AI, API

- Automatic MCP server generation from OpenAPI specs
- Supports JSON and YAML input formats
- Tool modules created for each API endpoint
- API client code generation (httpx-based)
- Logging, error handling, and configuration files included
- Optional LangGraph ReAct agent and A2A server generation
- Optional evaluation mode with LangFuse tracing
- Optional SLIM transport bridging for A2A servers

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

Run uvx --from git+https://github.com/cnoe-io/openapi-mcp-codegen.git openapi_mcp_codegen --spec-file <path> --output-dir <path> with optional flags such as --generate-agent, --generate-eval, or --enable-slim. For enhanced documentation, use python -m openapi_mcp_codegen.enhance_and_generate.

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",
            "\\"
        ]
    }
}

πŸš€ OpenAPI to MCP Server Code Generator

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.