MCPGen
Generates safe-by-default MCP servers from OpenAPI specs, exposing only low-risk GET tools and blocking write operations.
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
Maintainer
Works with
Installation
Manual Installation
npx mcpgenConfiguration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
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
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]"Initialize a starter project
Use the mcpgen init command to scaffold a demo project with example files.
mcpgen init --directory my_mcp_projectGenerate 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_mcpSet 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.pyAdd 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"
}
}
}
}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.yamlMCPGen 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.
MCPGen Alternatives — Similar Developer Tools Servers
Looking for alternatives to MCPGen? Here are other popular developer tools servers you can use with Claude, Cursor, and VS Code.
Ecc
★ 188.2kThe agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.
Javaguide
★ 155.8kJava 面试 & 后端通用面试指南,覆盖计算机基础、数据库、分布式、高并发、系统设计与 AI 应用开发
Gemini CLI
★ 104.5kA secure MCP server that wraps the Google Gemini CLI, allowing clients to query Gemini models using local OAuth sessions without requiring an API key. It provides tools for model interaction and diagnostics with built-in protection against command in
Awesome MCP Servers
★ 87.3k⭐ Curated list of Model Context Protocol (MCP) servers - tools that extend Claude Desktop, Cursor, Windsurf, and other MCP clients with custom capabilities.
MCP Servers
★ 86.0kModel Context Protocol Servers
CC Switch
★ 77.5kA cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Gemini CLI & Hermes Agent. Only official website: ccswitch.io
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.
Set Up MCPGen in Your Editor
Choose your AI client for step-by-step setup instructions.
Quick Config Preview
Add this to your claude_desktop_config.json or .cursor/mcp.json
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.