{"id":18630,"library":"openapi-mcp-generator","title":"OpenAPI MCP Generator","description":"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.","status":"active","version":"3.3.0","language":"javascript","source_language":"en","source_url":"https://github.com/harsha-iiiv/openapi-mcp-generator","tags":["javascript","openapi","mcp","model-context-protocol","generator","llm","ai","api","typescript"],"install":[{"cmd":"npm install openapi-mcp-generator","lang":"bash","label":"npm"},{"cmd":"yarn add openapi-mcp-generator","lang":"bash","label":"yarn"},{"cmd":"pnpm add openapi-mcp-generator","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required to generate MCP server code using the protocol SDK","package":"@modelcontextprotocol/sdk","optional":false},{"reason":"Converts OpenAPI JSON schema definitions to Zod schemas for runtime validation","package":"json-schema-to-zod","optional":false},{"reason":"Runtime validation library used for input validation in generated server","package":"zod","optional":false}],"imports":[{"note":"ESM-only since v3; CommonJS require not supported.","wrong":"const generateServer = require('openapi-mcp-generator');","symbol":"generateServer","correct":"import { generateServer } from 'openapi-mcp-generator';"},{"note":"The package also exports a default function (same as generateServer) for convenience.","wrong":"import { default as generateMCPServer } from 'openapi-mcp-generator';","symbol":"default","correct":"import generateMCPServer from 'openapi-mcp-generator';"},{"note":"The primary usage is via CLI. Programmatic API available but less documented; use the CLI for typical workflows.","wrong":"openapi-mcp-generator --help","symbol":"generateServer (CLI)","correct":"npx openapi-mcp-generator --input spec.yaml --output ./server"}],"quickstart":{"code":"// Install globally or use npx\n// Generate a stdio-based MCP server from a local OpenAPI file\n// Command:\nnpx openapi-mcp-generator --input petstore.yaml --output ./mcp-server --server-name petstore-api --server-version 1.0.0\n\n// Then run the generated server:\ncd ./mcp-server\nnpm start\n","lang":"javascript","description":"Shows how to generate a stdio MCP server from an OpenAPI specification using the CLI, then run it."},"warnings":[{"fix":"Use import syntax or switch to CommonJS via dynamic import().","message":"ESM-only since v3.0.0 – require() will throw an error.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Upgrade Node.js to 20+.","message":"Node.js <20 support dropped. Use Node 20+ or older versions of the package.","severity":"deprecated","affected_versions":">=3.0.0"},{"fix":"Use a tool like swagger-cli bundle --dereference to produce a single, self-contained spec before generating.","message":"If your OpenAPI spec uses relative file references ($ref), they may not resolve correctly. Always provide a fully dereferenced spec or a single file.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"If validation fails, check the Zod error messages; you may need to adjust your OpenAPI spec.","message":"The generated server uses Zod schemas for validation; ensure your OpenAPI schema adheres to JSON Schema draft-07 or later for best compatibility.","severity":"gotcha","affected_versions":">=3.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run npm install in the generated output directory or globally install the peer dep: npm install @modelcontextprotocol/sdk","cause":"Missing or mismatched peer dependency.","error":"Error: Cannot find module '@modelcontextprotocol/sdk'"},{"fix":"Validate your spec with a linter (e.g., npx @apidevtools/swagger-cli validate).","cause":"Invalid format or malformed spec file.","error":"Error: Unable to parse OpenAPI specification. Ensure the file is valid JSON or YAML."},{"fix":"Add a --base-url URL argument to the CLI command.","cause":"OpenAPI spec lacks servers field or has empty list.","error":"Error: servers array is empty or missing. Provide --base-url option."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}