
mcp generator
基于OpenAPI规范生成Model Context Protocol (MCP)服务器的工具。
Repository Info
About This Server
基于OpenAPI规范生成Model Context Protocol (MCP)服务器的工具。
Model Context Protocol (MCP) - This server can be integrated with AI applications to provide additional context and capabilities, enabling enhanced AI interactions and functionality.
Documentation
MCP Generator
A web application that generates Model Context Protocol (MCP) servers from OpenAPI specifications.
Description
This project provides a FastAPI-based Generator Server that accepts an OpenAPI v2 (Swagger) or OpenAPI v3 specification and generates a Python MCP server. The generated MCP server exposes MCP functions corresponding to the API operations defined in the input specification, making actual HTTP requests to the target API when these functions are called.
Features
- Accepts OpenAPI specifications via URL or direct content
- Supports both OpenAPI v2 and v3 formats
- Generates a fully functional Python MCP server
- Maps OpenAPI paths to MCP functions
- Handles path, query, and header parameters
- Supports request bodies and response schemas
- Maps HTTP error codes to MCP error codes
Installation
- Clone this repository
- Install the required dependencies:
pip install -r requirements.txt
Usage
Running the Generator Server
python run.py
The server will start at http://localhost:8000.
Generating an MCP Server
Send a POST request to the /generate endpoint with the following payload:
{
"source": "url",
"value": "https://example.com/api-spec.yaml",
"server_name": "my_mcp_server"
}
Or with direct content:
{
"source": "content",
"value": "openapi: 3.0.0\ninfo:\n title: Example API\n version: 1.0.0\n...",
"server_name": "my_mcp_server"
}
The server will respond with a ZIP file containing the generated MCP server code.
Running the Generated MCP Server
- Unzip the generated code
- Install the dependencies:
pip install -r requirements.txt
- Configure the target API URL if needed:
export TARGET_API_BASE_URL="https://api.example.com"
- Run the MCP server:
python main.py
The MCP server will start at http://localhost:8888 and can be used by MCP clients.
API Reference
POST /generate
Generates an MCP server from an OpenAPI specification.
Request Body:
source: Either "url" or "content"value: The URL of the OpenAPI spec or the spec content itselfserver_name(optional): Name for the generated server (defaults to "generated_mcp_server")
Responses:
- 200: ZIP file containing the generated MCP server code
- 400: Invalid request or OpenAPI specification
- 500: Internal server error
License
MIT
Quick Start
Clone the repository
git clone https://github.com/ttotenberg-ld/mcp-generatorInstall dependencies
cd mcp-generator
npm installFollow the documentation
Check the repository's README.md file for specific installation and usage instructions.
Repository Details
Recommended MCP Servers
Discord MCP
Enable AI assistants to seamlessly interact with Discord servers, channels, and messages.
Knit MCP
Connect AI agents to 200+ SaaS applications and automate workflows.
Apify MCP Server
Deploy and interact with Apify actors for web scraping and data extraction.
BrowserStack MCP
BrowserStack MCP Server for automated testing across multiple browsers.
Zapier MCP
A Zapier server that provides automation capabilities for various apps.