OpenAPI to MCP Server Converter logo

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

TypeScript Version

TypeScript Version

License: MIT

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