OpenAPI Swagger Converter MCP server

Automatically converts Swagger/OpenAPI specifications into toolsets, enabling interaction with any API without additional coding through secure key management and dynamic request construction.
Back to servers
Setup instructions
Provider
Anthony WK Chan
Release date
Apr 23, 2025
Language
Go
Stats
100 stars

OpenAPI-MCP is a dockerized server that transforms standard OpenAPI/Swagger specifications into Model Context Protocol (MCP) toolsets. This enables AI agents to interact with any API that has OpenAPI documentation without requiring custom code - simply provide the API specification and your agent can access the API through the MCP interface.

Installation and Setup

Using Docker (Recommended)

The easiest way to run OpenAPI-MCP is using the pre-built Docker image:

docker pull ckanthony/openapi-mcp:latest

Then run the container with your API specification:

docker run -p 8080:8080 --rm \
    -e API_KEY="your_actual_key" \
    ckanthony/openapi-mcp:latest \
    --spec https://petstore.swagger.io/v2/swagger.json \
    --api-key-env API_KEY \
    --api-key-name api_key \
    --api-key-loc header

Using a Local API Specification

If you have a local OpenAPI specification file:

  1. Create a directory containing your specification file
  2. Optionally add a .env file with your API key in the same directory
  3. Run the container with a volume mount:
docker run -p 8080:8080 --rm \
    -v $(pwd)/my-api:/app/spec \
    --env-file $(pwd)/my-api/.env \
    ckanthony/openapi-mcp:latest \
    --spec /app/spec/openapi.json \
    --api-key-env API_KEY \
    --api-key-name X-API-Key \
    --api-key-loc header

Weather API Example

Here's a step-by-step example using the Weatherbit API:

  1. Get a Weatherbit API key from Weatherbit.io

  2. Create an environment file for your API key:

    # Create a directory and .env file
    mkdir -p weatherbit
    echo "API_KEY=your_weatherbit_api_key" > weatherbit/.env
    
  3. Download the Weatherbit OpenAPI specification:

    curl -o weatherbit/weatherbitio-swagger.json https://raw.githubusercontent.com/ckanthony/openapi-mcp/main/example/weather/weatherbitio-swagger.json
    
  4. Run the OpenAPI-MCP container:

    docker run -p 8080:8080 --rm \
        -v $(pwd)/weatherbit:/app/spec \
        --env-file $(pwd)/weatherbit/.env \
        ckanthony/openapi-mcp:latest \
        --spec /app/spec/weatherbitio-swagger.json \
        --api-key-env API_KEY \
        --api-key-name key \
        --api-key-loc query
    
  5. Your MCP server is now running at http://localhost:8080 and ready to be used with compatible MCP clients like Cursor.

Configuration Options

Command-Line Flags

Flag Description Default
--spec Required. Path or URL to OpenAPI specification none
--port Port to run the MCP server on 8080
--api-key-env Environment variable containing the API key none
--api-key-name Name of the API key parameter none
--api-key-loc Location of API key: header, query, path, or cookie none
--include-tag Tag to include (can be repeated) none
--exclude-tag Tag to exclude (can be repeated) none
--include-op Operation ID to include (can be repeated) none
--exclude-op Operation ID to exclude (can be repeated) none
--base-url Override the target API server base URL none

Environment Variables

You can set custom headers for all API requests by setting the REQUEST_HEADERS environment variable:

docker run -p 8080:8080 --rm \
    -e API_KEY="your_key" \
    -e REQUEST_HEADERS='{"X-Custom": "Value"}' \
    ckanthony/openapi-mcp:latest \
    --spec https://api.example.com/openapi.json \
    --api-key-env API_KEY \
    --api-key-name api_key \
    --api-key-loc header

Filtering API Operations

You can include or exclude specific operations:

docker run -p 8080:8080 --rm \
    -e API_KEY="your_key" \
    ckanthony/openapi-mcp:latest \
    --spec https://api.example.com/openapi.json \
    --api-key-env API_KEY \
    --api-key-name api_key \
    --api-key-loc header \
    --include-tag weather \
    --exclude-op getForecastDaily

This will only expose operations with the "weather" tag, except for the "getForecastDaily" operation.

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "openapi-mcp" '{"command":"docker","args":["run","--rm","-p","8080:8080","ckanthony/openapi-mcp:latest","--spec","https://petstore.swagger.io/v2/swagger.json"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "openapi-mcp": {
            "command": "docker",
            "args": [
                "run",
                "--rm",
                "-p",
                "8080:8080",
                "ckanthony/openapi-mcp:latest",
                "--spec",
                "https://petstore.swagger.io/v2/swagger.json"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

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

2. Add this to your configuration file:

{
    "mcpServers": {
        "openapi-mcp": {
            "command": "docker",
            "args": [
                "run",
                "--rm",
                "-p",
                "8080:8080",
                "ckanthony/openapi-mcp:latest",
                "--spec",
                "https://petstore.swagger.io/v2/swagger.json"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later