MCP cover image
See in Github
2025-04-14

Una herramienta que convierte las especificaciones de OpenAPI en MCP Server

2

Github Watches

7

Github Forks

14

Github Stars

OpenAPI to MCP Generator (openapi-mcp-generator)

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 either standard input/output or HTTP-based transport.


✨ 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.
  • 💬 Stdio & Web Transport: Communicate over stdio or HTTP (beta, SSE support).
  • 🧰 Project Scaffold: Generates a complete Node.js project with tsconfig.json, package.json, and entry point.
  • 🧪 Built-in HTML Test Client (Web mode): Test API interactions visually in your browser.

🚀 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

# Generate an MCP server (stdio)
openapi-mcp-generator --input path/to/openapi.json --output path/to/output/dir

# Generate an MCP web server (beta)
openapi-mcp-generator --input path/to/openapi.json --output path/to/output/dir --transport=web --port=3000

CLI Options

Option Alias Description Default
--input -i Path or URL to OpenAPI specification (YAML or JSON) Required
--output -o Directory to output the generated MCP project Required
--server-name -n Name of the MCP server (package.json:name) OpenAPI title or mcp-api-server
--server-version -v Version of the MCP server (package.json:version) OpenAPI version or 1.0.0
--base-url -b Base URL for API requests. Required if OpenAPI servers missing or ambiguous. Auto-detected if possible
--transport -t Transport mode: "stdio" (default) or "web" (beta) "stdio"
--port -p Port for web server mode 3000
--force Overwrite existing files in the output directory without confirmation false

🧱 Project Structure

The generated project includes:

<output_directory>/
├── .gitignore
├── package.json
├── tsconfig.json
└── src/
    └── index.ts
  • Uses axios, zod, @modelcontextprotocol/sdk, and json-schema-to-zod
  • Secure API key/tokens via environment variables
  • Tool generation for each endpoint

📡 Transport Modes

Stdio (Default)

Communicates with MCP clients via standard input/output. Ideal for local development or integration with LLM tools.

Web Server Mode (Beta)

Launches a fully functional HTTP server with:

  • Server-Sent Events (SSE) for bidirectional messaging
  • REST endpoint for client → server communication
  • In-browser test client UI
  • Multi-connection support

⚠️ Note: Web mode is experimental and may have breaking changes in future updates.


🔐 Environment Variables for Authentication

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>

▶️ Running the Generated Server

cd path/to/output/dir
npm install

# Run in stdio mode
npm start

# Run in web server mode (if generated with --transport=web)
npm run start:web

⚠️ Requirements

  • Node.js v18 or later

🤝 Contributing

Contributions are welcome!

  1. Fork the repo
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m "Add amazing feature"
  4. Push and open a PR

📌 Repository: github.com/harsha-iiiv/openapi-mcp-generator


📄 License

MIT License — see LICENSE for full details.

相关推荐

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • NiKole Maxwell
  • I craft unique cereal names, stories, and ridiculously cute Cereal Baby images.

  • Yusuf Emre Yeşilyurt
  • I find academic articles and books for research and literature reviews.

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • Carlos Ferrin
  • Encuentra películas y series en plataformas de streaming.

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • Contraband Interactive
  • Emulating Dr. Jordan B. Peterson's style in providing life advice and insights.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • rustassistant.com
  • Your go-to expert in the Rust ecosystem, specializing in precise code interpretation, up-to-date crate version checking, and in-depth source code analysis. I offer accurate, context-aware insights for all your Rust programming questions.

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • apappascs
  • Descubra la colección más completa y actualizada de servidores MCP en el mercado. Este repositorio sirve como un centro centralizado, que ofrece un extenso catálogo de servidores MCP de código abierto y propietarios, completos con características, enlaces de documentación y colaboradores.

  • Mintplex-Labs
  • La aplicación AI de escritorio todo en uno y Docker con trapo incorporado, agentes de IA, creador de agentes sin código, compatibilidad de MCP y más.

  • modelcontextprotocol
  • Servidores de protocolo de contexto modelo

  • ShrimpingIt
  • Manipulación basada en Micrypthon I2C del expansor GPIO de la serie MCP, derivada de AdaFruit_MCP230xx

  • n8n-io
  • Plataforma de automatización de flujo de trabajo de código justo con capacidades de IA nativas. Combine el edificio visual con código personalizado, auto-anfitrión o nube, más de 400 integraciones.

  • OffchainLabs
  • Implementación de la prueba de estaca Ethereum

  • WangRongsheng
  • 🧑‍🚀 全世界最好的 llM 资料总结(数据处理、模型训练、模型部署、 O1 模型、 MCP 、小语言模型、视觉语言模型) | Resumen de los mejores recursos del mundo.

    Reviews

    3 (1)
    Avatar
    user_Zpr8oSMF
    2025-04-15

    As a dedicated MCP application user, I am thoroughly impressed with the PostgreSQL Model Context Protocol (PG-MCP) Server by tanster1234. This server has significantly improved my database management efficiency and offered seamless integration with PostgreSQL. The setup process was straightforward, and the performance has been outstanding. Highly recommended for anyone looking to enhance their PostgreSQL experience!