OpenAPI to MCP Generator (openapi-mcp-generator)

by harsha-iiiv

614 907 downloads Not rated yet MIT

About

A tool that converts OpenAPI specifications to MCP server

Details

License
MIT

Explore

- 🔧 OpenAPI 3.0 Support: Converts any OpenAPI 3.0+ spec into an MCP-compatible server.
- 🔁 Proxy Behavior: Proxies calls to your original REST API while validating request structure and security.
- 🔐 Authentication Support: API keys, Bearer tokens, Basic auth, and OAuth2 supported via environment variables.
- 🧪 Zod Validation: Automatically generates Zod schemas from OpenAPI definitions for runtime input validation.
- ⚙️ Typed Server: Fully typed, maintainable TypeScript code output.
- 🔌 Multiple Transports: Communicate over stdio, SSE via Hono, or StreamableHTTP.
- 🧰 Project Scaffold: Generates a complete Node.js project with tsconfig.json, package.json, and entry point.
- 🧪 Built-in HTML Test Clients: Test API interactions visually in your browser (for web-based transports).

---

npm install -g openapi-mcp-generator

> You can also use yarn global add openapi-mcp-generator or pnpm add -g openapi-mcp-generator

---


Configure auth credentials in your environment:

| Auth Type | Variable Format |
| ---------- | -------------------------------------------------------------------------------------------------- |
| API Key | API_KEY_<SCHEME_NAME> |
| Bearer | BEARER_TOKEN_<SCHEME_NAME> |
| Basic Auth | BASIC_USERNAME_<SCHEME_NAME>, BASIC_PASSWORD_<SCHEME_NAME> |
| OAuth2 | OAUTH_CLIENT_ID_<SCHEME_NAME>, OAUTH_CLIENT_SECRET_<SCHEME_NAME>, OAUTH_SCOPES_<SCHEME_NAME> |

---

bash
cd path/to/output/dir
npm install

npm version
License: MIT
GitHub repository

Generate Model Context Protocol (MCP) servers from OpenAPI specifications.

This CLI tool automates the generation of MCP-compatible servers that proxy requests to existing REST APIs—enabling AI agents and other MCP clients to seamlessly interact with your APIs using your choice of transport methods.

---

✨ Features

- 🔧 OpenAPI 3.0 Support: Converts any OpenAPI 3.0+ spec into an MCP-compatible server.
- 🔁 Proxy Behavior: Proxies calls to your original REST API while validating request structure and security.
- 🔐 Authentication Support: API keys, Bearer tokens, Basic auth, and OAuth2 supported via environment variables.
- 🧪 Zod Validation: Automatically generates Zod schemas from OpenAPI definitions for runtime input validation.
- ⚙️ Typed Server: Fully typed, maintainable TypeScript code output.
- 🔌 Multiple Transports: Communicate over stdio, SSE via Hono, or StreamableHTTP.
- 🧰 Project Scaffold: Generates a complete Node.js project with tsconfig.json, package.json, and entry point.
- 🧪 Built-in HTML Test Clients: Test API interactions visually in your browser (for web-based transports).

---

🚀 Installation

npm install -g openapi-mcp-generator

> You can also use yarn global add openapi-mcp-generator or pnpm add -g openapi-mcp-generator

---

🛠 Usage

```bash

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.