Dev.to AI πŸ€– Ai πŸ‘ 0 πŸ“– 1 min read

mcpgen: Turn any OpenAPI spec into an MCP server in seconds

I got tired of manually writing MCP tools for every REST endpoint I wanted to expose to an LLM. So I automated it. mcpgen reads an OpenAPI JSON or YAML file and generates a complete, ready‑to‑run MCP server in Python.

I got tired of manually writing MCP tools for every REST endpoint I wanted
to expose to an LLM. So I automated it.

mcpgen reads an OpenAPI JSON or YAML file and generates a complete,
ready‑to‑run MCP server in Python.

πŸ”§ What it does

  • Parses OpenAPI 3.0 / 3.1 specs
  • Creates one MCP tool per endpoint (with snake_case names)
  • Handles auth automatically (API key, Bearer, etc.)
  • Outputs a clean, human‑readable Python script
  • Zero runtime surprises – just mcp and httpx

πŸš€ Quick start


bash
pip install mcpgen
mcpgen my-api.json -o my-mcp-server
python my-mcp-server/server.py
The generated server runs over stdio – ready to plug into Claude Desktop
or any MCP client.

πŸ§ͺ Real‑world test
Recently a contributor added an OpenAPI 3.1 fixture (Xquik API) with
lookupTweet and getUser endpoints. The tool generated the correct
tools, including path parameters and x-api-key auth, on the first try.

All 18 tests pass. It works.

πŸ€” Why you might want it
If you’re building LLM agents that need to interact with APIs,
mcpgen eliminates the boilerplate. You don’t have to write a single
@app.tool() decorator by hand.

It also makes it dead simple to experiment – change your API spec,
regenerate the server, and you’re done.

πŸ“¦ Links
GitHub: JnanaSrota/mcpgen

PyPI: pip install mcpgen

MIT licensed, open to contributions

πŸ™ Feedback
If you try it with your own API spec and something breaks (or works
beautifully), I’d love to hear about it. Drop a comment or open an issue.

Thanks for reading!
πŸ“° Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.