harsha-iiiv/openapi-mcp-generator
A tool that converts OpenAPI specifications to MCP server
OpenAPI → MCP Generator
What it is – A command‑line tool (and library) that reads an OpenAPI 3.x specification and scaffolds a ready‑to‑run Node.js server that speaks the Model Context Protocol (MCP). The generated server proxies calls to the original REST API while exposing the endpoints as MCP “tools”, so AI agents or other MCP clients can invoke your API without needing to understand OpenAPI.
Key capabilities
- OpenAPI 3+ support – any valid spec (JSON or YAML) can be turned into an MCP server.
- Proxy behaviour – the server forwards requests to the real API, handling authentication and request validation.
- Authentication – API‑key, Bearer, Basic and OAuth2 are wired up via environment variables.
- Runtime validation – Zod schemas are auto‑generated from the OpenAPI definitions.
- Typed output – the scaffolded project is fully TypeScript‑typed.
- Multiple transports –
stdio(default) – JSON‑RPC over standard input/output, ideal for local LLM tool integration.web– an HTTP server with Server‑Sent Events and a built‑in HTML test client.streamable‑http– stateful JSON‑RPC over HTTP POST with full HTTP status handling.cloudflare‑worker– a deployable Cloudflare Workers project using the MCP Streamable‑HTTP transport.
- Project scaffold – generates
package.json,tsconfig.json, source files, and a sample test client. - Filtering – use the
x-mcpOpenAPI extension (or the--default-includeflag) to decide which operations become MCP tools.
How to get it
npm install -g openapi-mcp-generator # or yarn/pnpm globally
Typical CLI workflow
# Basic stdio server
openapi-mcp-generator -i ./petstore.json -o ./my-mcp-server
# Web server with SSE on port 3000
openapi-mcp-generator -i ./petstore.json -o ./my-mcp-web -t web -p 3000
# Cloudflare Worker deployment
openapi-mcp-generator -i ./petstore.json -o ./my-worker -t cloudflare-worker
After generation, cd into the output folder, run npm install, then npm start (or the transport‑specific npm scripts) to launch the server.
Programmatic API – The package also exports helpers such as getToolsFromOpenApi that return MCP tool definitions without writing files, useful for custom tooling.
Why it matters – MCP is a lightweight protocol designed for AI agents to call external services safely. By turning any existing OpenAPI spec into an MCP‑compatible proxy, this generator removes the manual work of writing adapters, lets developers reuse their current REST APIs, and makes those APIs instantly callable from LLM‑driven agents, Claude Desktop, or any MCP client.
License – MIT.
Related
- Project
- Project
- Project
- Project