Cover image
Try Now
2025-04-14

Servidor MCP Dockerized para permitir que su agente de IA acceda a cualquier API con los documentos de API existentes

3 years

Works with Finder

1

Github Watches

0

Github Forks

1

Github Stars

OpenAPI-MCP: Dockerized MCP Server to allow your AI agent to access any API with existing api docs

Go Reference CI codecov

openapi-mcp logo

Generate MCP tool definitions directly from a Swagger/OpenAPI specification file.

OpenAPI-MCP is a dockerized MCP server that reads a swagger.json or openapi.yaml file and generates a corresponding Model Context Protocol (MCP) toolset. This allows MCP-compatible clients like Cursor to interact with APIs described by standard OpenAPI specifications. Now you can enable your AI agent to access any API by simply providing its OpenAPI/Swagger specification - no additional coding required.

Table of Contents

Demo

Run the demo yourself: Running the Weatherbit Example (Step-by-Step)

demo

Why OpenAPI-MCP?

  • Standard Compliance: Leverage your existing OpenAPI/Swagger documentation.
  • Automatic Tool Generation: Create MCP tools without manual configuration for each endpoint.
  • Flexible API Key Handling: Securely manage API key authentication for the proxied API without exposing keys to the MCP client.
  • Local & Remote Specs: Works with local specification files or remote URLs.
  • Dockerized Tool: Easily deploy and run as a containerized service with Docker.

Features

  • OpenAPI v2 (Swagger) & v3 Support: Parses standard specification formats.
  • Schema Generation: Creates MCP tool schemas from OpenAPI operation parameters and request/response definitions.
  • Secure API Key Management:
    • Injects API keys into requests (header, query, path, cookie) based on command-line configuration.
      • Loads API keys directly from flags (--api-key), environment variables (--api-key-env), or .env files located alongside local specs.
      • Keeps API keys hidden from the end MCP client (e.g., the AI assistant).
  • Server URL Detection: Uses server URLs from the spec as the base for tool interactions (can be overridden).
  • Filtering: Options to include/exclude specific operations or tags (--include-tag, --exclude-tag, --include-op, --exclude-op).
  • Request Header Injection: Pass custom headers (e.g., for additional auth, tracing) via the REQUEST_HEADERS environment variable.

Installation

Docker

The recommended way to run this tool is via Docker.

Using the Pre-built Docker Hub Image (Recommended)

Alternatively, you can use the pre-built image available on Docker Hub.

  1. Pull the Image:
    docker pull ckanthony/openapi-mcp:latest
    
  2. Run the Container: Follow the docker run examples above, but replace openapi-mcp:latest with ckanthony/openapi-mcp:latest.

Building Locally (Optional)

  1. Build the Docker Image Locally:

    # Navigate to the repository root
    cd openapi-mcp
    # Build the Docker image (tag it as you like, e.g., openapi-mcp:latest)
    docker build -t openapi-mcp:latest .
    
  2. Run the Container: You need to provide the OpenAPI specification and any necessary API key configuration when running the container.

    • Example 1: Using a local spec file and .env file:

      • Create a directory (e.g., ./my-api) containing your openapi.json or swagger.yaml.
      • If the API requires a key, create a .env file in the same directory (e.g., ./my-api/.env) with API_KEY=your_actual_key (replace API_KEY if your --api-key-env flag is different).
      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: Using a remote spec 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 a port on your host to the container's default port 8080.
      • --rm: Automatically remove the container when it exits.
      • -v <host_path>:<container_path>: Mount a local directory containing your spec into the container. Use absolute paths or $(pwd)/.... Common container path: /app/spec.
      • --env-file <path_to_host_env_file>: Load environment variables from a local file (for API keys, etc.). Path is on the host.
      • -e <VAR_NAME>="<value>": Pass a single environment variable directly.
      • openapi-mcp:latest: The name of the image you built locally.
      • --spec ...: Required. Path to the spec file inside the container (e.g., /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 if the target API needs an API key.
      • (See --help for all command-line options by running docker run --rm openapi-mcp:latest --help)

Running the Weatherbit Example (Step-by-Step)

This repository includes an example using the Weatherbit API. Here's how to run it using the public Docker image:

  1. Find OpenAPI Specs (Optional Knowledge): Many public APIs have their OpenAPI/Swagger specifications available online. A great resource for discovering them is APIs.guru. The Weatherbit specification used in this example (weatherbitio-swagger.json) was sourced from there.

  2. Get a Weatherbit API Key:

    • Go to Weatherbit.io and sign up for an account (they offer a free tier).
    • Find your API key in your Weatherbit account dashboard.
  3. Clone this Repository: You need the example files from this repository.

    git clone https://github.com/ckanthony/openapi-mcp.git
    cd openapi-mcp
    
  4. Prepare Environment File:

    • Navigate to 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 the actual API key you obtained from Weatherbit.
  5. Run the Docker Container: From the openapi-mcp root directory (the one containing the example folder), run the following command:

    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
    
    • -v $(pwd)/example/weather:/app/spec: Mounts the local example/weather directory (containing the spec and .env file) to /app/spec inside the container.
    • --env-file $(pwd)/example/weather/.env: Tells Docker to load environment variables (specifically API_KEY) from your .env file.
    • ckanthony/openapi-mcp:latest: Uses the public Docker image.
    • --spec /app/spec/weatherbitio-swagger.json: Points to the spec file inside the container.
    • The --api-key-* flags configure how the tool should inject the API key (read from the API_KEY env var, named key, placed in the query string).
  6. Access the MCP Server: The MCP server should now be running and accessible at http://localhost:8080 for compatible clients.

Using Docker Compose (Example):

A docker-compose.yml file is provided in the example/ directory to demonstrate running the Weatherbit API example using the locally built image.

  1. Prepare 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
    
  2. Run with Docker Compose: Navigate to the example directory and run:

    cd example
    # This builds the image locally based on ../Dockerfile
    # It does NOT use the public Docker Hub image
    docker-compose up --build
    
    • --build: Forces Docker Compose to build the image using 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.
  3. Stop the service: Press Ctrl+C in the terminal where Compose is running, or run docker-compose down from the example directory in another terminal.

Command-Line Options

The openapi-mcp command accepts the following flags:

Flag Description Type Default
--spec Required. Path or URL to the OpenAPI specification file. string (none)
--port Port to run the MCP server on. int 8080
--api-key Direct API key value (use --api-key-env or .env file instead for security). string (none)
--api-key-env Environment variable name containing the API key. If spec is local, also checks .env file in the spec's directory. string (none)
--api-key-name Required if key used. Name of the API key parameter (header, query, path, or cookie name). string (none)
--api-key-loc Required if key used. Location of API key: header, query, path, or cookie. string (none)
--include-tag Tag to include (can be repeated). If include flags are used, only included items are exposed. string slice (none)
--exclude-tag Tag to exclude (can be repeated). Exclusions apply after inclusions. string slice (none)
--include-op Operation ID to include (can be repeated). string slice (none)
--exclude-op Operation ID to exclude (can be repeated). string slice (none)
--base-url Manually override the target API server base URL detected from the spec. string (none)
--name Default name for the generated MCP toolset (used if spec has no title). string "OpenAPI-MCP Tools"
--desc Default description for the generated MCP toolset (used if spec has no description). string "Tools generated from OpenAPI spec"

Note: You can get this list by running the tool with the --help flag (e.g., docker run --rm ckanthony/openapi-mcp:latest --help).

Environment Variables

  • REQUEST_HEADERS: Set this environment variable to a JSON string (e.g., '{"X-Custom": "Value"}') to add custom headers to all outgoing requests to the target API.

相关推荐

  • av
  • Ejecute sin esfuerzo LLM Backends, API, frontends y servicios con un solo comando.

  • 1Panel-dev
  • 🔥 1Panel proporciona una interfaz web intuitiva y un servidor MCP para administrar sitios web, archivos, contenedores, bases de datos y LLM en un servidor de Linux.

  • rulego
  • ⛓️Rulego es un marco de motor de regla de orquestación de componentes de alta generación de alto rendimiento, de alto rendimiento y de alto rendimiento para GO.

  • WangRongsheng
  • 🧑‍🚀 全世界最好的 llM 资料总结(数据处理、模型训练、模型部署、 O1 模型、 MCP 、小语言模型、视觉语言模型) | Resumen de los mejores recursos del mundo.

  • Byaidu
  • Traducción de papel científico en PDF con formatos preservados - 基于 Ai 完整保留排版的 PDF 文档全文双语翻译 , 支持 支持 支持 支持 支持 支持 支持 支持 支持 支持 支持 支持 等服务 等服务 等服务 提供 提供 提供 提供 提供 提供 提供 提供 提供 提供 提供 提供 cli/mcp/docker/zotero

  • hkr04
  • SDK liviano C ++ MCP (Protocolo de contexto del modelo)

  • sigoden
  • Cree fácilmente herramientas y agentes de LLM utilizando funciones Plain Bash/JavaScript/Python.

  • RockChinQ
  • 😎简单易用、🧩丰富生态 - 大模型原生即时通信机器人平台 | 适配 Qq / 微信(企业微信、个人微信) / 飞书 / 钉钉 / Discord / Telegram / Slack 等平台 | 支持 Chatgpt 、 Deepseek 、 DiFy 、 Claude 、 Gemini 、 Xai 、 PPIO 、 Ollama 、 LM Studio 、阿里云百炼、火山方舟、 Siliconflow 、 Qwen 、 Moonshot 、 Chatglm 、 SillyTraven 、 MCP 等 LLM 的机器人 / Agente | Plataforma de bots de mensajería instantánea basada en LLM, admite Discord, Telegram, WeChat, Lark, Dingtalk, QQ, Slack

  • lasso-security
  • Una puerta de enlace basada en complementos que orquesta otros MCP y permite a los desarrolladores construir sobre agentes de grado empresarial de TI.

  • modelscope
  • Iniciar aplicaciones de múltiples agentes empoderadas con Building LLM de manera más fácil.

    Reviews

    3.1 (16)
    Avatar
    user_n94jBUJg
    2025-04-26

    As a dedicated user of the openapi-mcp application, I am thoroughly impressed with its functionality and ease of use. Developed by ckanthony, it provides an efficient way to interact with APIs seamlessly. The user-friendly interface and comprehensive features make it an invaluable tool for developers. It's a must-have for anyone looking to streamline their workflow. Highly recommended!

    Avatar
    user_EU3L3q0D
    2025-04-26

    I've been using openapi-mcp by ckanthony and it's been a game changer! The user-friendly interface and robust features make it an essential tool for developers. The seamless integration and comprehensive documentation enhance productivity. Highly recommend for anyone looking for a reliable openapi solution!

    Avatar
    user_VSoZs1dZ
    2025-04-26

    As a dedicated user of openapi-mcp, I must say that this product created by ckanthony is truly a game-changer. It streamlines API integration effortlessly and its user-friendly interface makes it accessible for developers of all levels. The seamless experience and robust performance have significantly boosted my productivity. Highly recommend!

    Avatar
    user_8rr9zzRX
    2025-04-26

    I've been using openapi-mcp by ckanthony and I'm thoroughly impressed. The interface is intuitive and easy to navigate, making it a pleasure to work with. The performance is top-notch and it has significantly streamlined my workflow. Kudos to the developer for creating such a robust and reliable application! Highly recommend to anyone in need of a powerful MCP tool.

    Avatar
    user_kq7JUQiu
    2025-04-26

    As a loyal user of openapi-mcp, I must say this product by ckanthony has been a game-changer for me. Its seamless integration and robust features make it an essential tool for any developer. The intuitive interface and comprehensive documentation are impressive, and the responsiveness of the support is outstanding. Highly recommended!

    Avatar
    user_xc8bfCvG
    2025-04-26

    I've been using openapi-mcp by ckanthony, and I must say it's been a game-changer for my projects. The comprehensive documentation and intuitive design make it easy to integrate and utilize its features. This tool has significantly streamlined my workflow, and I'm highly impressed with its performance and reliability. Highly recommended for any developer looking to enhance their API management experience!

    Avatar
    user_tjUsavhJ
    2025-04-26

    As a loyal user of openapi-mcp, I am thoroughly impressed with its seamless integration capabilities and user-friendly interface. Created by ckanthony, this tool has significantly enhanced my workflow efficiency. Highly recommend it to anyone looking for a reliable and powerful application!

    Avatar
    user_O2BCNkuC
    2025-04-26

    I'm a huge fan of openapi-mcp by ckanthony. This application has significantly streamlined my development processes. The ease of integration and the robust functionality it offers are unparalleled. I highly recommend it to any developer looking to enhance their workflow. It’s a game-changer!

    Avatar
    user_CnHOFQM0
    2025-04-26

    Openapi-mcp by ckanthony is truly impressive! As a loyal user of mcp applications, I find it incredibly user-friendly and efficient. The seamless integration and robust features make it an absolute must-have for anyone looking to streamline their workflow. Highly recommend giving it a try!

    Avatar
    user_p2M9fIQS
    2025-04-26

    I've been using openapi-mcp and it's truly transformative. Developed by ckanthony, it's intuitive and has enhanced my productivity significantly. The start URL and welcoming information make onboarding seamless. Highly recommend for anyone in need of a robust MCP application!

    Avatar
    user_6S51FkYp
    2025-04-26

    As a dedicated user of openapi-mcp by ckanthony, I am thoroughly impressed with its capabilities and ease of integration. The seamless API functionality has significantly improved my workflow. Highly recommend for anyone looking to enhance their application performance!

    Avatar
    user_KoYiXvN7
    2025-04-26

    I have been using openapi-mcp by ckanthony for a while now, and it has significantly enhanced my workflow. The API is intuitive and well-documented, providing seamless integration with various applications. The author's attention to detail is evident in the robust design and functionality. Highly recommended for anyone in need of a reliable API solution!

    Avatar
    user_szbwoKFV
    2025-04-26

    openapi-mcp is a fantastic tool created by ckanthony! This application is user-friendly and integrates smoothly with your existing workflow. Whether you're a beginner or an experienced developer, you'll find it intuitive and reliable. The detailed documentation and welcoming support community make it even easier to get started. Highly recommended!

    Avatar
    user_poPSWp1N
    2025-04-26

    As a devoted user of openapi-mcp, I must say this product by ckanthony is a game-changer. The intuitive interface and seamless integration capabilities have significantly enhanced my workflow. The robust features and consistent performance make it stand out. Highly recommend to both beginners and advanced users alike.

    Avatar
    user_PNM42EJB
    2025-04-26

    As a devoted user of openapi-mcp, I must say it has significantly streamlined my workflow. Created by ckanthony, this tool is robust and user-friendly. The intuitive design and seamless integration have made a substantial difference in my daily tasks. Highly recommended for anyone in need of an efficient API management solution!

    Avatar
    user_gMg74njY
    2025-04-26

    As a dedicated user of openapi-mcp, I must say this product, crafted by ckanthony, is exceptional. Its seamless integration and robust functionality demonstrate the author's expertise. Highly recommended for anyone seeking a reliable and efficient API application.