SuperAPI AI Directory

openapi-mcp

Access any API through its existing OpenAPI documentation.

Open website

About this tool

Purpose: OpenAPI-MCP is used to let AI agents access arbitrary APIs through existing API documentation. It is a containerized MCP server that reads a swagger.json or openapi.yaml file and generates a corresponding set of MCP tools, thereby enabling MCP-compatible clients such as Cursor to interact with APIs described by the standard OpenAPI specification without additional coding.

Main capabilities:

  • Standards compliance: Existing OpenAPI/Swagger documents can be reused directly.
  • Automatic tool generation: MCP tools can be created without manually configuring each endpoint.
  • Flexible API key handling: Securely manage API key authentication for proxied APIs without exposing keys to the MCP client.
  • Local and remote specifications: Supports local specification files or remote URLs.
  • Dockerized tool: Can be easily deployed via Docker and run as a containerized service.
  • Supports OpenAPI v2 (Swagger) and v3: Can parse standard specification formats.
  • Schema generation: Generates MCP tool schemas based on OpenAPI operation parameters and request/response definitions.
  • Secure key management: API keys can be injected into request headers, query, path, or cookies based on command-line configuration; keys can come from the --api-key flag, the --api-key-env environment variable, or a .env file located next to the local specification, and are hidden from the final MCP client (such as an AI assistant).
  • Server URL detection: Uses the server URL in the specification as the basis for tool interaction (can be overridden).
  • Filtering: Specific operations or tags can be included or excluded via the --include-tag, --exclude-tag, --include-op, and --exclude-op options.
  • Request header injection: Custom request headers can be passed via the REQUEST_HEADERS environment variable (for example, for additional authentication or tracing).

Usage: Running via Docker is recommended.

  1. Use a prebuilt Docker Hub image (recommended): Run docker pull ckanthony/openapi-mcp:latest to pull the image, then run the container according to the docker run example, replacing openapi-mcp:latest with ckanthony/openapi-mcp:latest.
  2. Local build (optional): After entering the repository root directory, run docker build -t openapi-mcp:latest . When running the container, you need to provide the OpenAPI specification and the necessary API key configuration. Example 1 (local specification file and .env file): Create a directory containing openapi.json or swagger.yaml (for example, ./my-api); if the API requires a key, create .env in the same directory (for example, ./my-api/.env) and write API_KEY=your_actual_key (replace API_KEY if --api-key-env is different). Run the command: docker run -p 8080:8080 --rm
    -v $(pwd)/my-api:/app/spec
    --env-file $(pwd)/my-api/.env
    openapi-mcp:latest
    --spec /app/spec/openapi.json
    --api-key-env API_KEY
    --api-key-name X-API-Key
    --api-key-loc header Adjust --spec, --api-key-env, --api-key-name, --api-key-loc, and -p as needed. Example 2 (remote specification URL and direct environment variable): docker run -p 8080:8080 --rm
    -e SOME_API_KEY="your_actual_key"
    openapi-mcp:latest
    --spec https://petstore.swagger.io/v2/swagger.json
    --api-key-env SOME_API_KEY
    --api-key-name api_key
    --api-key-loc header Key Docker run options:
  • -p <host_port>:8080: Map the host port to the container's default port 8080.
  • --rm: Automatically delete the container when it exits.
  • -v <host_path>:<container_path>: Mount a local directory containing the specification to the container, using an absolute path or $(pwd)/..., with the common container path being /app/spec.
  • --env-file <path_to_host_env_file>: Load environment variables from a local file (for API keys, etc.), with the path located on the host.
  • -e <VAR_NAME>="<value>": Pass a single environment variable directly.
  • openapi-mcp:latest: The name of the locally built image.
  • --spec ...: Required. The path to the specification file inside the container (such as /app/spec/openapi.json) or a public URL.
  • --port 8080: (Optional) Change the internal port the server listens on (must match the container port in -p).
  • --api-key-env, --api-key-name, --api-key-loc: Required when the target API needs a key. You can run docker run --rm openapi-mcp:latest --help to view all command-line options.

Run the Weatherbit example (step by step):

  1. Find the OpenAPI specification (optional knowledge): OpenAPI/Swagger specifications for many public APIs are available online, and APIs.guru is a good resource for discovering them; the Weatherbit specification used in this example (weatherbitio-swagger.json) comes from there.
  2. Get a Weatherbit API key: Go to Weatherbit.io to register an account (a free tier is available), and find the API key in the account dashboard.
  3. Clone the repository: git clone https://github.com/ckanthony/openapi-mcp.git Then cd openapi-mcp.
  4. Prepare the environment file: Enter the example directory cd example/weather; copy the example environment file cp .env.example .env; edit the new .env file and replace YOUR_WEATHERBIT_API_KEY_HERE with your actual API key.
  5. Run the Docker container: From the openapi-mcp root directory, execute: docker run -p 8080:8080 --rm
    -v $(pwd)/example/weather:/app/spec
    --env-file $(pwd)/example/weather/.env
    ckanthony/openapi-mcp:latest
    --spec /app/spec/weatherbitio-swagger.json
    --api-key-env API_KEY
    --api-key-name key
    --api-key-loc query Here, -v mounts the local example/weather directory (containing the specification and .env) to the container's /app/spec; --env-file lets Docker load environment variables from .env (especially API_KEY); ckanthony/openapi-mcp:latest uses the public image; --spec points to the specification file inside the container; the --api-key-* flags configure how the tool injects the API key (read from the API_KEY environment variable, named key, placed in the query string).
  6. Access the MCP server: The server should be running at http://localhost:8080 and accessible to compatible clients.

Using Docker Compose (example): The example/ directory provides docker-compose.yml to demonstrate running the Weatherbit API example using a locally built image. Prepare the environment file: Copy example/weather/.env.example to example/weather/.env, and add your actual Weatherbit API key:

example/weather/.env

API_KEY = YOUR_ACTUAL_WEATHERBIT_KEY Run: After entering the example directory, execute cd example, then docker-compose up --build. --build forces Compose to build the image from the Dockerfile in the project root before starting the service. Compose will read example/docker-compose.yml, build the image, mount ./weather, read ./weather/.env, and start the openapi-mcp container with the specified command-line arguments; the MCP server will be available at http://localhost:8080 Access. Stopping the service: press Ctrl+C in the terminal running Compose, or run docker-compose down in the example directory in another terminal.

Command-line options: this part of the material is incomplete; it only shows "Command-Line Options" followed by "T", and a complete list of options is not yet provided.

Use cases: scenarios where an MCP-compatible client such as Cursor needs to access an API described by existing OpenAPI/Swagger documentation; scenarios where you want to avoid manually writing tool code for each endpoint; scenarios where you need to access an API protected by a key through a proxy without exposing the API key to the AI assistant; local specification files or remote specification URLs can be used.

Limitations: the material does not provide other limitation descriptions such as performance, pricing, or platform support scope; the relevant content is not yet provided.