MCPSERV.CLUB
LostInBrittany

OpenAPI to MCP Generator

MCP Server

Convert Swagger specs into LLM-friendly MCP servers

Stale(50)
17stars
1views
Updated 11 days ago

About

A Java utility that transforms OpenAPI/Swagger specifications into fully functional Model Context Protocol (MCP) servers, enabling large language models to interact with any REST API via standardized tools.

Capabilities

Resources
Access data sources
Tools
Execute functions
Prompts
Pre-built templates
Sampling
AI model interactions

OpenAPI to MCP Generator in Action

Overview

The OpenAPI to MCP Generator is a specialized tool that bridges the gap between conventional REST APIs and the Model Context Protocol (MCP). By automatically converting an OpenAPI/Swagger specification into a fully‑functional MCP server, it lets large language models (LLMs) such as Claude interact with any external HTTP service through a unified, tool‑based interface. This eliminates the need for developers to write custom MCP wrappers for each API they wish to expose, dramatically speeding up integration and reducing boilerplate.

At its core, the generator parses a Swagger or OpenAPI document and produces an MCP server that exposes each endpoint as a distinct tool. It handles the full spectrum of HTTP verbs—GET, POST, PUT, DELETE, PATCH—and maps path parameters, query strings, and request bodies to the corresponding MCP arguments. The resulting server also supports common authentication schemes (API keys, bearer tokens, basic auth) by reading environment variables, making it ready for production use without additional configuration.

Key capabilities include:

  • Automatic tool creation: Every defined operation becomes an MCP tool with clear parameter descriptions, default values, and valid ranges.
  • Robust error handling: The generated server translates HTTP errors into structured MCP responses, preserving meaningful status codes and messages.
  • Readable JSON formatting: Responses are pretty‑printed for easier consumption by both developers and LLMs.
  • Server selection logic: When an OpenAPI spec defines multiple servers, the generator exposes constants and environment variables to switch between them at runtime.

Real‑world scenarios where this MCP server shines include:

  • Rapid prototyping: Quickly expose a third‑party API to an LLM for exploratory data analysis or automated testing.
  • Microservice orchestration: Enable a single LLM to orchestrate calls across multiple internal services, each defined by its own OpenAPI spec.
  • Documentation‑driven development: Keep the MCP interface in sync with API changes by regenerating the server whenever the OpenAPI file is updated.

Integration into AI workflows is straightforward. Once generated, the MCP server can be launched as a standalone service; LLMs then discover its tools through standard MCP discovery mechanisms. The server’s environment‑variable configuration allows seamless deployment in containerized or cloud environments, while its adherence to OpenAPI ensures that developers familiar with Swagger can immediately understand the available tools and parameters.

In summary, the OpenAPI to MCP Generator transforms any documented REST API into an AI‑ready service with minimal effort, offering a powerful and repeatable pattern for connecting LLMs to external data sources.