home / mcp / openapi2mcp server

OpenAPI2MCP Server

openapi转mcp

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "jeweis-openapi2mcpserver": {
      "command": "uvx",
      "args": [
        "--from",
        "openapi2mcpserver"
      ],
      "env": {
        "BASE_URL": "YOUR_OPENAPI_HOST",
        "OPEN_API_DOC_JSON_URL": "YOUR_OPENAPI_DOC_JSON_URL"
      }
    }
  }
}

You can turn an OpenAPI specification into an MCP (Minecraft Contained Protocol) service, run it locally or in Docker, and then use MCP clients to access the generated MCP endpoints. This server supports forwarding HTTP headers, works with local stdio pipelines, and can be deployed as a Docker container for streamable HTTP access.

How to use

You run the MCP server locally and connect via an MCP client. The server translates your OpenAPI definition into MCP services, allowing you to query, call, and interact with the API through MCP-compatible tooling. Use the standard client connection flow: start the MCP server, then configure your client to point at the MCP runtime, and begin making calls that map to your OpenAPI endpoints.

How to install

# Prerequisites
- Python and pip
- Git
- Optional: uvx or Docker for deployment

# Step 1: Clone the repository
git clone <repository-url>
cd <repository-directory>

# Step 2: Install dependencies
pip install -r requirements.txt

# Step 3: Prepare environment variables
# Create a .env file in the project root with:
# BASE_URL=https://api.example.com
# OPEN_API_DOC_JSON_URL=https://api.example.com/api/v3/api-docs/default

# Step 4: Run the server locally via stdio (see next section for exact runtime command)

Configuration and run examples

You can run the server using a local stdio command or via Docker. The following examples show how to start the server using the provided runtime command and environment variables.

# Run via stdio runtime (example)
uvx --from openapi2mcpserver

Examples and deployment notes

Docker deployment is supported to run the MCP server as a container and expose a streamable HTTP endpoint. Use the environment variables to point to your OpenAPI host and API docs, and map the desired routes for MCP access.

docker run -d -p 9087:9087 \
  -e BASE_URL=http://your-openapi-host \
  -e OPEN_API_DOC_JSON_URL=http://your-openapi-host/api/v3/api-docs \
  -e SERVER_NAME=OpenAPI2MCP-Docker-Server \
  -e "ROUTE_MAPS=[{\"methods\": [\"GET\",\"POST\"],\"pattern\":\"^/tool/.*\"}]" \
  jeweis/openapi2mcp:latest

Configuration you’ll use in clients

Configure your MCP client with the server details. The standard approach is to register the MCP server by name, provide the command and arguments for local stdio execution, and specify any environment variables the server requires.

{
  "mcpServers": {
    "openapi2mcpserver": {
      "command": "uvx",
      "args": ["--from", "openapi2mcpserver"],
      "env": {
        "BASE_URL": "your_openapi3.0_host",
        "OPEN_API_DOC_JSON_URL": "your_openapi3.0_host_doc_json_url"
      }
    }
  }
}

Available tools

convertOpenApiToMcp

Converts an OpenAPI specification into MCP service definitions, generating the corresponding MCP endpoints and service interfaces.

headerPassthrough

Supports passing through HTTP headers from the client to the generated MCP services to preserve authentication and tracing information.

streamableHttp

Enables streamable HTTP access for the MCP server when deployed via Docker, allowing efficient, continuous data transfer.