CLI tool that generates Model Context Protocol (MCP) server code from OpenAPI 3.0+ specifications. v3.3.0 released March 2025. Generates a complete, typed TypeScript project with Zod validation, proxy behavior to the original REST API, and support for multiple transports (stdio, SSE via Hono, StreamableHTTP). Key differentiators: automates full scaffolding including package.json, tsconfig.json, and entry point; built-in HTML test clients for web transports; supports API key, Bearer, Basic, and OAuth2 auth via environment variables. Requires Node >=20 and peer deps @modelcontextprotocol/sdk, json-schema-to-zod, zod. Ships TypeScript types.
npm install openapi-mcp-generatorVerified import paths — ran on the pinned version, not inferred.
Shows how to generate a stdio MCP server from an OpenAPI specification using the CLI, then run it.
Use import syntax or switch to CommonJS via dynamic import().
Upgrade Node.js to 20+.
Use a tool like swagger-cli bundle --dereference to produce a single, self-contained spec before generating.
If validation fails, check the Zod error messages; you may need to adjust your OpenAPI spec.
Run npm install in the generated output directory or globally install the peer dep: npm install @modelcontextprotocol/sdk
Validate your spec with a linter (e.g., npx @apidevtools/swagger-cli validate).
Add a --base-url URL argument to the CLI command.