MCPGen

v1.0.0Developer Toolsstable

Generates safe-by-default MCP servers from OpenAPI specs, exposing only low-risk GET tools and blocking write operations.

gogolangmcp-servermcp-server-generatoropenapi
Share:
90
Stars
0
Downloads
0
Weekly
0/5

What is MCPGen?

MCPGen is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to generates safe-by-default mcp servers from openapi specs, exposing only low-risk get tools and blocking write operations.

Generates safe-by-default MCP servers from OpenAPI specs, exposing only low-risk GET tools and blocking write operations.

This server falls under the Developer Tools category on MCPgee, the world's largest MCP server directory with 33,000+ servers.

Features

  • Generates safe-by-default MCP servers from OpenAPI specs, ex

Use Cases

Generate safe MCP servers from OpenAPI specs.
Automatically block write operations for security.
breezykalama

Maintainer

LicenseMIT
Languagego
Versionv1.0.0
UpdatedMay 7, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

Manual Installation

npx mcpgen

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

How to Set Up and Use MCPGen

MCPGen is a code generator that takes an OpenAPI specification (YAML or JSON) and produces a safe-by-default MCP server that exposes only low-risk GET endpoints as callable tools, automatically blocking POST, PUT, PATCH, and DELETE operations. It outputs either a FastAPI server or an MCP stdio server, complete with an audit log, safety report, tool catalog, and optional semantic routing. API platform teams and security-conscious developers use it to rapidly expose existing REST APIs to AI agents without the risk of accidental write operations.

Prerequisites

  • Python 3.9+ installed
  • pip or uv package manager
  • An OpenAPI 3.x specification file (YAML or JSON) for the API you want to expose
  • The target API base URL accessible from your environment
  • Optional: sentence-transformers Python package for semantic tool routing
1

Install MCPGen from PyPI

Install the openapi-mcpgen package. Add the optional semantic extra if you want AI-powered tool routing.

pip install openapi-mcpgen
# Optional: semantic routing support
pip install "openapi-mcpgen[semantic]"
2

Initialize a starter project

Use the mcpgen init command to scaffold a demo project with example files.

mcpgen init --directory my_mcp_project
3

Generate an MCP stdio server from your OpenAPI spec

Point MCPGen at your OpenAPI spec file and a config YAML. It produces a ready-to-run MCP server in the output directory.

mcpgen generate \
  --from openapi.yaml \
  --config mcpgen.yaml \
  --mode mcp \
  --output generated_mcp
4

Set environment variables and run the generated server

Export the API_BASE_URL for your upstream API and start the generated MCP stdio server.

cd generated_mcp
export API_BASE_URL="https://api.example.com"
python server.py
5

Add the generated server to your MCP client configuration

Register the generated server in claude_desktop_config.json so your AI client can call the exposed GET tools.

{
  "mcpServers": {
    "mcpgen": {
      "command": "python",
      "args": ["/absolute/path/to/generated_mcp/server.py"],
      "env": {
        "API_BASE_URL": "https://api.example.com",
        "API_KEY": "your-api-key"
      }
    }
  }
}
6

Inspect the safety report and tool catalog

Review the generated safety_report.json and tool_catalog.md to confirm which tools are exposed and which write operations are blocked. Use 'mcpgen inspect' to preview without generating.

mcpgen inspect --from openapi.yaml --config mcpgen.yaml

MCPGen Examples

Client configuration

Example claude_desktop_config.json for a MCPGen-generated MCP server exposing JSONPlaceholder GET endpoints.

{
  "mcpServers": {
    "mcpgen": {
      "command": "python",
      "args": ["/Users/yourname/generated_mcp/server.py"],
      "env": {
        "API_BASE_URL": "https://jsonplaceholder.typicode.com"
      }
    }
  }
}

Prompts to try

Example prompts once a MCPGen-generated server is connected to your AI assistant.

- "List all available tools exposed by this API"
- "Get user with ID 1 from the API"
- "Fetch all posts by user 3"
- "Show me the safety report — which endpoints are blocked and why"
- "Run a dry-run of the create_post tool and show me what request it would make"

Troubleshooting MCPGen

mcpgen command not found after pip install

Ensure the Python scripts directory is on your PATH. On macOS/Linux run: export PATH="$HOME/.local/bin:$PATH". On Windows, add the Python Scripts folder to your system PATH. Alternatively, run as: python -m mcpgen.

OpenAPI spec fails to parse or $ref resolution errors

MCPGen supports local $ref resolution for #/components/schemas/* but not remote $ref URLs. Bundle your spec into a single file first using: npx @redocly/cli bundle openapi.yaml -o bundled.yaml, then pass bundled.yaml to mcpgen generate.

API_BASE_URL connection refused or 404 from generated server

Verify that API_BASE_URL is set correctly and the upstream API is reachable. Run 'mcpgen doctor --from openapi.yaml --config mcpgen.yaml' to diagnose connectivity and spec validation issues before generating the server.

Frequently Asked Questions about MCPGen

What is MCPGen?

MCPGen is a Model Context Protocol (MCP) server that generates safe-by-default mcp servers from openapi specs, exposing only low-risk get tools and blocking write operations. It connects AI assistants to external tools and data sources through a standardized interface.

How do I install MCPGen?

Follow the installation instructions on the MCPGen GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.

Which AI clients work with MCPGen?

MCPGen works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.

Is MCPGen free to use?

Yes, MCPGen is open source and available under the MIT license. You can use it freely in both personal and commercial projects.

Browse More Developer Tools MCP Servers

Explore all developer tools servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.

Quick Config Preview

{ "mcpServers": { "mcpgen": { "command": "npx", "args": ["-y", "mcpgen"] } } }

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide →

Ready to use MCPGen?

Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.

33,000+ ServersFree & Open SourceStep-by-Step Guides