Labsco
constellation39 logo

OpenAPI to MCP

from constellation39

A Go tool for converting OpenAPI specifications into MCP tools.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedAccount requiredAdvanced setup

openapi-to-mcp

็ฎ€ไฝ“ไธญๆ–‡

openapi-to-mcp is a Go implementation for converting OpenAPI specifications into MCP (Model Context Protocol) tools.

Overview

This project aims to provide a flexible framework that allows developers to automatically expose existing OpenAPI interfaces as MCP tools through simple configuration, enabling AI models to call these interfaces directly.

Features

  • OpenAPI to MCP Tool Conversion: Automatically parses OpenAPI specifications and creates corresponding MCP tools based on the definitions.
  • Multiple Transport Support: Supports stdio (Standard I/O), sse (Server-Sent Events), and stream (HTTP Stream) as transport protocols for MCP communication.
  • State Tracking & Authentication: Supports cookie-based state tracking and JWT (JSON Web Token) handling.
  • Rate Limiting: Built-in rate limiting to prevent high-frequency calls to the Large Language Model (LLM).
  • Environment Variable Configuration: Flexible configuration via .env file or system environment variables.
  • Stricter MCPTool Definition: Defines tools more rigorously for better usability by LLMs.

Project Structure

.github/
core/
  โ”œโ”€โ”€ openapi.go          # OpenAPI specification parsing and tool generation logic
  โ”œโ”€โ”€ session/            # Session management
  โ”œโ”€โ”€ middleware.go       # MCP middleware definitions
  โ””โ”€โ”€ utils.go            # Common utility functions
example/
  โ”œโ”€โ”€ openapi.yaml        # Example OpenAPI specification file
main.go                   # Main application entry point
README.md
README_zh.md
go.mod
go.sum