OpenAPI MCP server

Dynamically exposes REST APIs defined by OpenAPI specifications as MCP tools, enabling seamless integration of external services into workflows.
Back to servers
Provider
Matthew Hand
Release date
Feb 12, 2025
Language
Python
Stats
52 stars

The MCP OpenAPI Proxy enables you to expose any REST API with an OpenAPI specification as a set of tools through the Model Context Protocol. It dynamically creates tools from API endpoints, making external services accessible for AI systems and automation workflows.

Installation

Install the package directly from PyPI:

uvx mcp-openapi-proxy

Configuration

MCP OpenAPI Proxy can be configured by environment variables. The minimal configuration requires only an OpenAPI specification URL:

OPENAPI_SPEC_URL="https://example.com/openapi.json" uvx mcp-openapi-proxy

To integrate with your MCP ecosystem, add the following to your configuration:

{
    "mcpServers": {
        "mcp-openapi-proxy": {
            "command": "uvx",
            "args": ["mcp-openapi-proxy"],
            "env": {
                "OPENAPI_SPEC_URL": "${OPENAPI_SPEC_URL}",
                "API_KEY": "${API_OPENAPI_KEY}"
            }
        }
    }
}

Modes of Operation

Low-Level Mode (Default)

In this mode, the proxy automatically registers all valid API endpoints from the OpenAPI specification as individual tools. Tool names are derived from normalized paths and methods.

FastMCP Mode (Simple Mode)

Enable this mode by setting OPENAPI_SIMPLE_MODE=true. It exposes a fixed set of tools derived from specific OpenAPI endpoints rather than creating tools for every endpoint.

Environment Variables

The proxy can be customized with several environment variables:

  • OPENAPI_SPEC_URL: (Required) URL to the OpenAPI specification JSON file
  • API_KEY: Authentication token for the API
  • TOOL_WHITELIST: Comma-separated list of endpoint paths to expose as tools
  • TOOL_NAME_PREFIX: Prefix to prepend to all tool names
  • API_AUTH_TYPE: Overrides the default Bearer Authorization header type
  • EXTRA_HEADERS: Additional HTTP headers to attach to outgoing API requests
  • SERVER_URL_OVERRIDE: Overrides the base URL from the OpenAPI specification
  • DEBUG: Enables verbose debug logging when set to "true"

Usage Examples

Minimal Example (Glama)

OPENAPI_SPEC_URL="https://glama.ai/api/mcp/openapi.json" uvx mcp-openapi-proxy

Fly.io API Example

OPENAPI_SPEC_URL="https://raw.githubusercontent.com/abhiaagarwal/peristera/refs/heads/main/fly-machines-gen/fixed_spec.json" API_KEY="your_flyio_token_here" API_AUTH_TYPE="Api-Key" uvx mcp-openapi-proxy

Slack API Example

OPENAPI_SPEC_URL="https://raw.githubusercontent.com/slackapi/slack-api-specs/master/web-api/slack_web_openapi_v2.json" TOOL_WHITELIST="/chat,/bots,/conversations,/reminders,/files,/users" API_KEY="your_slack_bot_token" STRIP_PARAM="token" TOOL_NAME_PREFIX="slack_" uvx mcp-openapi-proxy

Virustotal API Example

OPENAPI_SPEC_URL="https://raw.githubusercontent.com/matthewhand/mcp-openapi-proxy/refs/heads/main/examples/virustotal.openapi.yml" EXTRA_HEADERS="x-apikey: your_virustotal_api_key" OPENAPI_SPEC_FORMAT="yaml" uvx mcp-openapi-proxy

Testing Your Configuration

After starting the proxy, you can test it by sending JSON-RPC messages:

  1. Initialization:
{"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"claude-ai","version":"0.1.0"}},"jsonrpc":"2.0","id":0}
  1. List available resources and tools:
{"method":"notifications/initialized","jsonrpc":"2.0"}
{"method":"resources/list","params":{},"jsonrpc":"2.0","id":1}
{"method":"tools/list","params":{},"jsonrpc":"2.0","id":2}

Troubleshooting

  • Ensure the OPENAPI_SPEC_URL points to a valid OpenAPI specification
  • Verify your API key and authentication settings
  • Enable debug logging with DEBUG=true for detailed output
  • Check that your TOOL_WHITELIST matches the desired endpoints

How to add this MCP server to 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 > MCP and click "Add new global MCP server".

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

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

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 explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

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