{"id":29155360,"url":"https://github.com/constellation39/openapi-to-mcp","last_synced_at":"2025-07-22T16:08:48.211Z","repository":{"id":300579760,"uuid":"1006513598","full_name":"constellation39/openapi-to-mcp","owner":"constellation39","description":"`openapi-to-mcp` is a Go language implementation that converts OpenAPI specifications into MCP (Model Context Protocol) tools.","archived":false,"fork":false,"pushed_at":"2025-06-22T14:33:05.000Z","size":102,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-22T14:40:43.232Z","etag":null,"topics":["mcp","mcp-server","openapi"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/constellation39.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-22T12:48:48.000Z","updated_at":"2025-06-22T14:33:08.000Z","dependencies_parsed_at":"2025-06-22T14:53:16.911Z","dependency_job_id":null,"html_url":"https://github.com/constellation39/openapi-to-mcp","commit_stats":null,"previous_names":["constellation39/openapi-to-mcp"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/constellation39/openapi-to-mcp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/constellation39%2Fopenapi-to-mcp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/constellation39%2Fopenapi-to-mcp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/constellation39%2Fopenapi-to-mcp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/constellation39%2Fopenapi-to-mcp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/constellation39","download_url":"https://codeload.github.com/constellation39/openapi-to-mcp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/constellation39%2Fopenapi-to-mcp/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261658078,"owners_count":23191057,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mcp","mcp-server","openapi"],"created_at":"2025-07-01T02:39:33.847Z","updated_at":"2025-07-01T02:39:35.166Z","avatar_url":"https://github.com/constellation39.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# openapi-to-mcp\n\n[简体中文](README_zh.md)\n\n`openapi-to-mcp` is a Go implementation for converting OpenAPI specifications into MCP (Model Context Protocol) tools.\n\n## Overview\n\nThis 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.\n\n## Features\n\n- **OpenAPI to MCP Tool Conversion**: Automatically parses OpenAPI specifications and creates corresponding MCP tools based on the definitions.\n- **Multiple Transport Support**: Supports `stdio` (Standard I/O), `sse` (Server-Sent Events), and `stream` (HTTP Stream) as transport protocols for MCP communication.\n- **State Tracking \u0026 Authentication**: Supports cookie-based state tracking and JWT (JSON Web Token) handling.\n- **Rate Limiting**: Built-in rate limiting to prevent high-frequency calls to the Large Language Model (LLM).\n- **Environment Variable Configuration**: Flexible configuration via `.env` file or system environment variables.\n- **Stricter MCPTool Definition**: Defines tools more rigorously for better usability by LLMs.\n\n## Installation\n\nYou can install `openapi-to-mcp` in two ways.\n\n### Option 1: Using `go install` (Recommended)\n\nThe easiest way to install and run the tool is using `go install`. After installation, the `openapi-to-mcp` command will be available in your shell.\n\n```bash\ngo install github.com/constellation39/openapi-to-mcp@latest\n```\n\n### Option 2: From Source\n\nIf you want to modify the code or contribute, clone the repository and build the project.\n\n```bash\ngit clone https://github.com/constellation39/openapi-to-mcp\ncd openapi-to-mcp\ngo build .\n# The executable will be ./openapi-to-mcp\n```\n\n## Usage\n\nFollow these steps to configure and run the tool.\n\n### Step 1: Configure Environment Variables\n\nCreate a `.env` file in the project's root directory or set the following environment variables in your system. You can start by copying the example file:\n\n```bash\n# On Windows\ncopy .env.example .env\n\n# On macOS/Linux\ncp .env.example .env\n```\n\nThen, edit the `.env` file with your desired configuration:\n\n```dotenv\n# MCP transport: stdio, sse, stream (default: stdio)\nMCP_TRANSPORT=\"stdio\"\n# MCP BASE URL (used for sse and stream modes)\nMCP_BASE_URL=\"http://localhost:8080\"\n\n# OpenAPI specification file path (can be a local file path or a URL)\nOPENAPI_SRC=\"./example/openapi.yaml\"\n# Base URL for API requests\nOPENAPI_BASE_URL=\n\n# Extra HTTP headers (JSON format), e.g., '{\"X-API-Key\": \"your-api-key\"}'\nEXTRA_HEADERS='{\"X-API-Key\": \"your-api-key\"}'\n\n# Use cookies (true/false, default: true)\nUSE_COOKIE=true\n\n# Output logs to standard output (true/false, default: false)\nLOG_OUTPUT=false\n\n# Rate limit: allowed requests per second (default: 1)\nRATE_LIMIT_PER_SECOND=1\n\n# Authorization header, e.g., \"Basic xxxx\"\nAUTHORIZATION_HEADERS=\"Basic xxxx\"\n```\n\n### Step 2: Run the Application\n\nExecute the application from your terminal.\n\nIf you installed using `go install`:\n```bash\nopenapi-to-mcp\n```\n\nIf you built from source:\n```bash\n./openapi-to-mcp\n```\n\nFor development, you can also run directly using `go run`:\n```bash\ngo run main.go\n```\n\n### Step 3: Connect with an MCP Client\n\nConfigure your MCP client to connect to `openapi-to-mcp` based on the `MCP_TRANSPORT` you've chosen.\n\n**- Stdio Mode (Default)**:\nIf `MCP_TRANSPORT` is `stdio`, configure your client to execute the command directly. The `env` block can be used to pass or override environment variables.\n\n```json\n{\n    \"mcpServers\": {\n        \"openapi-to-mcp\": {\n            \"command\": \"openapi-to-mcp\",\n            \"env\": {\n                \"MCP_BASE_URL\": \"http://localhost:8080\",\n                \"OPENAPI_SRC\": \"./example/openapi.yaml\"\n            }\n        }\n    }\n}\n```\n*Note: If running from source, you might set `\"command\"` to `\"./openapi-to-mcp\"` or use `go run main.go`.*\n\n**- SSE Mode**:\nIf `MCP_TRANSPORT` is `sse`, the server will start on the `MCP_BASE_URL`. Configure your client to connect to the `/sse` endpoint.\n\n```json\n{\n    \"mcpServers\": {\n        \"openapi-to-mcp\": {\n            \"url\": \"http://localhost:8080/sse\"\n        }\n    }\n}\n```\n\n**- Stream Mode**:\nIf `MCP_TRANSPORT` is `stream`, the server will start on the `MCP_BASE_URL`. Configure your client to connect to the `/stream` endpoint.\n\n```json\n{\n    \"mcpServers\": {\n        \"openapi-to-mcp\": {\n            \"url\": \"http://localhost:8080/stream\"\n        }\n    }\n}\n```\n*Please ensure `http://localhost:8080` matches the `MCP_BASE_URL` in your configuration.*\n\n## Project Structure\n\n```\n.github/\ncore/\n  ├── openapi.go          # OpenAPI specification parsing and tool generation logic\n  ├── session/            # Session management\n  ├── middleware.go       # MCP middleware definitions\n  └── utils.go            # Common utility functions\nexample/\n  ├── openapi.yaml        # Example OpenAPI specification file\nmain.go                   # Main application entry point\nREADME.md\nREADME_zh.md\ngo.mod\ngo.sum\n```\n\n## Contributing\n\nContributions are welcome! Feel free to submit a Pull Request or report an Issue.\n\n## License\n\nThis project is released under the MIT License.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconstellation39%2Fopenapi-to-mcp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fconstellation39%2Fopenapi-to-mcp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconstellation39%2Fopenapi-to-mcp/lists"}