OpenAPI to MCP Server Converter
by zxypro1
A tool for automatically converting OpenAPI specifications into Model Context Protocol (MCP) server instances. It simplifies the integration of OpenAPI definitions with MCP environments.
View on GitHub
Last updated: N/A
OpenAPI to MCP Server Converter
Node.js Version TypeScript Version License: MIT
A tool for automatically converting OpenAPI specifications into Model Context Protocol (MCP) server instance
Features
- š Automated Conversion: Auto-parses OpenAPI 3.0 specifications
- š Type Safety: TypeScript-based strong type validation
- š Request Proxy: Automatically handles tool call parameter mapping
Quick Start
Prerequisites
- Node.js 18+
- TypeScript 5.x
Basic Usage
Install the package:
npm install openapi-mcp-converter
Run a local stdio MCP server:
import { OpenApiMCPSeverConverter } from "openapi-mcp-converter";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import fs from "fs";
const openApiDoc = JSON.parse(fs.readFileSync("./openapi.json"));
const converter = new OpenApiMCPSeverConverter(openApiDoc);
const server = converter.getServer();
// Start MCP service
async function runServer() {
const transport = new StdioServerTransport();
await server.connect(transport);
console.log("GitHub MCP Server running on stdio");
}
runServer().catch((error) => {
console.error("Fatal error in main():", error);
process.exit(1);
});
Run Examples
npm run test # Execute sample test cases
Development Guide
Project Structure
/openapi-to-mcp
āāā dist/ # Compiled output
āāā src/ # Source code
ā āāā example/ # Example configurations
ā āāā index.ts # Core implementation
āāā package.json
āāā tsconfig.json
Build Commands
npm run build # Production build
npm run watch # Development mode watch