mcp-openapi
MCP Server (Model Context Protocol) for turning OpenAPI specifications into a MCP Resource
claude mcp add --transport stdio ivo-toby-mcp-openapi-server npx -y @ivotoby/openapi-mcp-server \ --env HTTP_HOST="127.0.0.1" \ --env HTTP_PORT="3000" \ --env TOOLS_MODE="all|dynamic|explicit" \ --env API_HEADERS="Authorization:Bearer token123,X-API-Key:your-api-key" \ --env SERVER_NAME="mcp-openapi-server" \ --env API_BASE_URL="https://api.example.com (base URL for the target API)" \ --env PROMPTS_PATH="path or URL to prompts JSON/YAML" \ --env ENDPOINT_PATH="/mcp" \ --env PROMPTS_INLINE="Prompts JSON string inline" \ --env RESOURCES_PATH="path or URL to resources JSON/YAML" \ --env SERVER_VERSION="1.0.0" \ --env TRANSPORT_TYPE="stdio or http" \ --env RESOURCES_INLINE="Resources JSON string inline" \ --env OPENAPI_SPEC_PATH="https://api.example.com/openapi.json or path/to/openapi.yaml" \ --env OPENAPI_SPEC_INLINE="Inline OpenAPI spec content as a string" \ --env DISABLE_ABBREVIATION="true or false" \ --env OPENAPI_SPEC_FROM_STDIN="true if loading spec from stdin"
How to use
This MCP server exposes OpenAPI-defined REST endpoints as MCP tools, enabling large language models to discover and invoke API operations through the MCP protocol. It supports two transport methods: the Stdio Transport, which is ideal for direct integration with clients like Claude Desktop via standard input/output, and the Streamable HTTP Transport, which exposes the MCP interface over HTTP for web clients and HTTP-capable tools. You can run the server with npx, and either point it at an OpenAPI spec via a URL/file or supply the spec inline or through stdin. Once running, you can list available tools derived from the OpenAPI specification and execute them by name, with results streamed back to the client. This makes REST APIs self-describing and accessible to MCP-enabled assistants and workflows.
How to install
Prerequisites:
- Node.js and npm installed on your machine
- Basic familiarity with MCP concepts and the target OpenAPI spec
Step-by-step installation:
-
Ensure Node.js and npm are installed
- Check versions: node -v and npm -v
-
Install and run the MCP server with npx (no local install required)
# Run the OpenAPI MCP server via npx (example)
npx @ivotoby/openapi-mcp-server \
--api-base-url https://api.example.com \
--openapi-spec https://api.example.com/openapi.json \
--transport http \
--port 3000
- Alternative: install as a local dependency (optional)
npm install --save @ivotoby/openapi-mcp-server
# Then run using npx or a script that invokes the binary/module as appropriate
- Configuration via environment or CLI (examples)
# Environment-based configuration (example)
export API_BASE_URL=https://api.example.com
export OPENAPI_SPEC_PATH=https://api.example.com/openapi.json
export TRANSPORT_TYPE=http
export HTTP_PORT=3000
npx @ivotoby/openapi-mcp-server --api-base-url $API_BASE_URL --openapi-spec $OPENAPI_SPEC_PATH --transport http --port 3000
- Optional: run using Docker (if you have a containerized workflow available)
- Build or pull a prebuilt image and map ports accordingly depending on your deployment setup.
Note: The exact CLI flags may vary by version. Refer to the package documentation for the latest options.
Additional notes
Tips and common considerations:
- OpenAPI_SPEC_PATH can be a remote URL, a local file path, or inline content via OPENAPI_SPEC_INLINE.
- If you use HTTP transport, ensure the port and host are accessible to your MCP clients.
- API_HEADERS should be a comma-separated list of header: value pairs, e.g. Authorization:Bearer token, X-API-Key: key.
- If your OpenAPI document requires external references, be mindful of how the server loads those references in your deployment environment.
- USE_PROMPTS and RESOURCES configuration (PROMPTS_PATH, PROMPTS_INLINE, RESOURCES_PATH, RESOURCES_INLINE) can customize the MCP experience with contextual prompts and resource data.
- Tools loading modes: all (default) loads all endpoint-based tools; dynamic loads only meta-tools; explicit loads only tools specified in includeTools. Adjust via TOOLS_MODE.
- If you encounter abbreviation errors, consider disabling abbreviation with DISABLE_ABBREVIATION=true, especially for long tool names.
Related MCP Servers
iterm
A Model Context Protocol server that executes commands in the current iTerm session - useful for REPL and CLI assistance
mcp
Octopus Deploy Official MCP Server
furi
CLI & API for MCP management
editor
MCP Server for Phaser Editor
DoorDash
MCP server from JordanDalton/DoorDash-MCP-Server
mcp
MCP сервер для автоматического создания и развертывания приложений в Timeweb Cloud