OpenAPI to MCP Generator logo

OpenAPI to MCP Generator

by harsha-iiiv

This CLI tool automates the generation of MCP-compatible servers that proxy requests to existing REST APIs. It enables AI agents and other MCP clients to seamlessly interact with your APIs using either standard input/output or HTTP-based transport.

View on GitHub

Last updated: N/A

What is OpenAPI to MCP Generator?

The OpenAPI to MCP Generator is a command-line tool that generates Model Context Protocol (MCP) servers from OpenAPI specifications. It allows AI agents and other MCP clients to interact with existing REST APIs.

How to use OpenAPI to MCP Generator?

Install the tool globally using npm: npm install -g openapi-mcp-generator. Then, use the CLI to generate an MCP server: openapi-mcp-generator --input path/to/openapi.json --output path/to/output/dir. You can also generate a web server with --transport=web.

Key features of OpenAPI to MCP Generator

  • OpenAPI 3.0 Support

  • Proxy Behavior with request validation

  • Authentication Support (API keys, Bearer tokens, Basic auth, OAuth2)

  • Zod Validation schema generation

  • Typed TypeScript code output

  • Stdio & Web Transport (beta, SSE support)

  • Project Scaffold generation

  • Built-in HTML Test Client (Web mode)

Use cases of OpenAPI to MCP Generator

  • Enabling AI agents to interact with REST APIs

  • Creating MCP-compatible servers from existing OpenAPI specifications

  • Validating request structure and security when proxying API calls

  • Generating typed TypeScript code for maintainable servers

  • Providing both stdio and web transport options for different environments

FAQ from OpenAPI to MCP Generator

What is MCP?

MCP stands for Model Context Protocol. It is a protocol that allows AI agents and other clients to interact with APIs.

What OpenAPI versions are supported?

OpenAPI 3.0 and later versions are supported.

What authentication methods are supported?

API keys, Bearer tokens, Basic auth, and OAuth2 are supported via environment variables.

What transport modes are available?

Stdio (default) and Web Server (beta) modes are available.

What are the requirements to run the generated server?

Node.js v18 or later is required.