mcpgen
About
CLI tool that generates MCP servers from OpenAPI/Postman specs — pip install mcpgen-cli
Details
- Author
- jnanasrota
- Categories
- Developer Tools, API
Jump to
Setup
Install mcpgen in your MCP client (Claude Desktop, Cursor, Windsurf, and others).
Repository: https://github.com/jnanasrota/mcpgen
Follow the installation instructions in the repository README, then restart your MCP client.
Turn any API into an MCP server in 30 seconds.
Pointmcpgenat an OpenAPI spec or Postman collection. Get back acomplete Python MCP server you own— no runtime dependency on mcpgen, no proxy, no lock-in. Read it. Modify it. Ship it.
# From a URL mcpgen https://petstore3.swagger.io/api/v3/openapi.json # From a local OpenAPI file (JSON or YAML) mcpgen stripe.yaml # From a Postman collection mcpgen postman_collection.json # Preview without writing anything mcpgen openapi.json --dry-run # Custom output directory and server name mcpgen openapi.json --output ~/my-mcp-servers --name "My API"
That's it.mcpgenreads your spec and writes a Python MCP server to disk.
A self-contained directory with source code you own:
stripe_api_mcp/ ├── server.py ← the MCP server (read it, edit it, it's yours) └── requirements.txt ← httpx, mcp
cd stripe_api_mcp pip install -r requirements.txt export STRIPE_API_TOKEN="sk_live_..." python server.py
The generatedserver.pylooks like this:
#!/usr/bin/env python3 """ Stripe API MCP Server Generated by mcpgen — https://github.com/JnanaSrota/mcpgen This file is yours. Modify it freely. """ import os, asyncio, httpx from mcp.server import Server from mcp.server.stdio import stdio_server from mcp import types BASE_URL = "https://api.stripe.com" AUTH_TOKEN = os.environ.get("STRIPE_API_TOKEN", "") app = Server("stripe-api") @app.call_tool() async def _handle_get_customers(name: str, arguments: dict): if name != "get_customers": raise ValueError(f"Unknown tool: {name}") url = BASE_URL + "/v1/customers" query_params = {} if "limit" in arguments: query_params["limit"] = arguments["limit"] async with httpx.AsyncClient(timeout=30.0) as client: response = await client.get(url, params=query_params, headers={"Authorization": f"Bearer {AUTH_TOKEN}"}) response.raise_for_status() return [types.TextContent(type="text", text=response.text)] # ... one function per API endpoint @app.list_tools() async def list_tools(): ... if __name__ == "__main__": asyncio.run(stdio_server(app))
No black box. No dependencies at runtime. Just Python.
mcpgenprints the exact config snippet to paste into yourclaude_desktop_config.json:
{ "mcpServers": { "stripe-api-mcp": { "command": "python", "args": ["/path/to/stripe_api_mcp/server.py"], "env": { "STRIPE_API_TOKEN": "your-key-here" } } } }
- macOS:~/Library/Application Support/Claude/claude_desktop_config.json
- Windows:%APPDATA%\Claude\claude_desktop_config.json
Most API-to-MCP tools areruntime proxies— they sit between Claude and your API forever, and you depend on them to stay running.
mcpgengeneratessource code you own. The output is a plain Python file. You can:
- Read every line of what's happening
- Modify auth logic, add retries, adjust error handling
- Deploy it anywhere without any dependency onmcpgen
- Commit it to your own repo, version it, review it in PRs
mcpgenis a build tool. Needed once, at generation time. Never at runtime.
mcpgenauto-detects your API's auth scheme from the spec:
OAuth2 flows are approximated as bearer token — you supply the token manually.
Usage: mcpgen [OPTIONS] INPUT Turn any API into an MCP server in 30 seconds. Arguments: INPUT OpenAPI JSON/YAML file, Postman collection, or URL [required] Options: -o, --output PATH Output directory (default: current directory) -n, --name TEXT Override the generated server name --dry-run Print generated code without writing files --no-color Disable colored output -v, --version Show version and exit --help Show this message and exit
- TypeScript output (--lang ts) using@modelcontextprotocol/sdk
- Swagger 2.x support (auto-detected, separate parser)
- Auto-detect OpenAPI URL from base domain (/.well-known/openapi.json,/api-docs, etc.)
- --update-claude-configflag to patchclaude_desktop_config.jsonautomatically
- Recursive$refresolution for deeply nested schemas
git clone https://github.com/JnanaSrota/mcpgen cd mcpgen pip install -e ".[dev]" pytest tests/ -v
Input (file / URL) ↓ loader.py ← detects format, routes to correct parser ↓ openapi.py / postman.py ← parse to MCPSpec (internal IR) ↓ generator/python.py ← renders Jinja2 templates → server.py
To add a new input format: write a parser that returnsMCPSpec. Nothing else changes. To add a new output language: write a generator that consumesMCPSpec. Nothing else changes.
MIT — the generated code is yours to do whatever you want with.
This is a web browser that enables your coding agent, such as Claude Code, to visit websites on your behalf and assist you in identifying bugs or creating UI test cases.
A server that dynamically creates MCP endpoints from any OpenAPI specification URL.
Turn any OpenAPI 3.0 spec into an MCP server with zero code — deploy to Cloudflare Workers, Node.js, Docker, or run locally via npx, with a built-in OAuth 2.1 server for MCP clients that require custom connector authentication.
An MCP server for any web application with an OpenAPI specification, connecting AI models to external tools and data services.
A zero-configuration tool to automatically expose FastAPI endpoints as MCP tools.
An MCP server that enables Large Language Models to make HTTP requests and interact with web APIs. It supports automatic tool generation from OpenAPI/Swagger specifications.
A secure MCP-to-OpenAPI proxy server that converts MCP tools into OpenAPI compatible HTTP servers, with support for multiple server types and automatic API documentation.
Turn any OpenAPI/Swagger spec into Claude tools. Zero config, zero code.
Connect to any OpenAPI-based API with built-in OAuth2 authentication management.
Converts OpenAPI/Swagger specifications to Model Context Protocol (MCP) format, providing a modern Web UI and a backend service.
Converts OpenAPI specifications into MCP tools, enabling AI clients to interact with external APIs seamlessly.
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.





