mcp-openapi MCP Server

Turn any OpenAPI/Swagger spec into MCP tools

README.md

mcp-openapi

Turn any OpenAPI/Swagger spec into MCP tools — so Claude and other AI assistants can call your REST APIs.

Point mcp-openapi at any OpenAPI 3.x or Swagger 2.0 spec URL and it generates Model Context Protocol (MCP) tools automatically. No code generation, no config files, no boilerplate. Your AI assistant gets callable tools for every API endpoint in seconds.


Quick Start

1. Run it (no install required):

npx mcp-openapi --spec https://petstore3.swagger.io/api/v3/openapi.json

2. Add it to Claude Desktop (claude_desktop_config.json):

{
  "mcpServers": {
    "petstore": {
      "command": "npx",
      "args": [
        "mcp-openapi",
        "--spec", "https://petstore3.swagger.io/api/v3/openapi.json"
      ]
    }
  }
}

3. Ask Claude to use it:

"List all available pets in the store"

Claude sees MCP tools like find_pets_by_status, get_pet_by_id, add_pet and calls them directly.


Why mcp-openapi?

Most MCP-to-API bridges require you to write tool definitions by hand or generate code from a spec. mcp-openapi skips all of that.

Feature mcp-openapi Hand-written MCP servers Generic HTTP tools
Zero config setup Yes No Partial
OpenAPI 3.x + Swagger 2.0 Yes N/A N/A
Flat parameter schemas (LLM-optimized) Yes Manual No
Smart tool naming from operationId Yes Manual No
Auth (API key, Bearer, OAuth2) Built-in DIY DIY
Retry with exponential backoff Built-in DIY DIY
Response truncation for LLM context Built-in DIY No

Flat parameter schemas are the key differentiator. Instead of passing nested JSON objects (which LLMs frequently get wrong), mcp-openapi flattens path, query, header, and body parameters into a single flat object. This dramatically improves tool-calling accuracy.


How It Works

OpenAPI/Swagger Spec          mcp-openapi               AI Assistant
     (URL or file)                                      (Claude, etc.)
          |                         |                         |
          |   1. Parse & validate   |                         |
          |------------------------>|                         |
          |                         |                         |
          |   2. Generate MCP tools |                         |
          |   (one per endpoint)    |                         |
          |------------------------>|                         |
          |                         |                         |
          |                         |   3. Register tools     |
          |                         |   via stdio transport   |
          |                         |------------------------>|
          |                         |                         |
          |                         |   4. AI calls a tool    |
          |                         |<------------------------|
          |                         |                         |
          |   5. Build & execute    |                         |
          |   HTTP request          |                         |
          |<------------------------|                         |
          |                         |                         |
          |   6. Return truncated   |                         |
          |   response to AI        |                         |
          |------------------------>|------------------------>|

Each API endpoint becomes one MCP tool:

  • Tool name is derived from operationId (converted to snake_case) or from method + path
  • Parameters are flattened into a single input schema (path, query, header, and body params merged)
  • Responses are truncated to ~50KB to stay within LLM context limits
  • Errors (429, 5xx) trigger automatic retries with exponential backoff (up to 3 retries)

Claude Desktop Integration

Add any API to Claude Desktop by editing your config file:

Location:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json

Public API (no auth)

{
  "mcpServers": {
    "petstore": {
      "command": "npx",
      "args": [
        "mcp-openapi",
        "--spec", "https://petstore3.swagger.io/api/v3/openapi.json"
      ]
    }
  }
}

API with Bearer Token

{
  "mcpServers": {
    "github": {
      "command": "npx",
      "args": [
        "mcp-openapi",
        "--spec", "https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github

Tools 1

dynamic-api-toolsGenerates tools dynamically based on the provided OpenAPI/Swagger specification endpoints.

Try it

List all available pets in the store using the petstore API.
Find the pet with ID 123 and return its details.
Add a new pet to the store with the name 'Buddy'.
Fetch the latest repository information from the GitHub API.

Frequently Asked Questions

What are the key features of mcp-openapi?

Zero-config generation of MCP tools from OpenAPI 3.x and Swagger 2.0 specs. Flattens nested parameters into a single object for improved LLM accuracy. Built-in support for Bearer, API-key, and OAuth2 authentication. Automatic response truncation to stay within LLM context limits. Automatic retries with exponential backoff for 429 and 5xx errors.

What can I use mcp-openapi for?

Connecting Claude to internal REST APIs without writing custom MCP server code. Interacting with public APIs like GitHub or Petstore directly from an AI assistant. Standardizing API interactions by flattening complex nested JSON schemas for better LLM performance. Rapidly prototyping AI-driven workflows by turning existing API documentation into callable tools.

How do I install mcp-openapi?

Install mcp-openapi by running: npx mcp-openapi --spec <url>

What MCP clients work with mcp-openapi?

mcp-openapi works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep mcp-openapi docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Open Conare