Dynamically exposes OpenAPI-defined REST APIs as MCP tools
OpenAPI MCP Server
A generic Model Context Protocol (MCP) server that dynamically exposes OpenAPI-defined REST APIs as MCP tools. This enables Large Language Models like Claude to discover and interact with any OpenAPI-compliant API through the standardized MCP protocol.
⨠Key Features
- š Dynamic Tool Generation: Automatically converts OpenAPI operations to MCP tools
- š Flexible Authentication: Static headers, dynamic providers, token refresh
- š Advanced Filtering: Filter tools by tags, resources, operations, or explicit lists
- š Multiple Transports: Stdio for Claude Desktop, HTTP for web applications
- š Smart Tool Naming: Intelligent abbreviation with ā¤64 character limit
- ļæ½ Meta-Tools: Built-in API exploration and dynamic endpoint invocation
- š Interface-Based Architecture: Type-safe, modular design with comprehensive interfaces
- š„ Multiple Input Methods: URL, file, stdin, or inline OpenAPI specifications
š Quick Start
CLI Usage (Recommended)
# Install globally
npm install -g @lucid-spark/openapi-mcp-server
# Use with any OpenAPI-compliant API
openapi-mcp-server \
--api-base-url https://api.example.com \
--openapi-spec https://api.example.com/openapi.json \
--transport stdio
Docker Usage (Production Ready)
# Run with HTTP transport
docker run --rm -p 3000:3000 \
-e API_BASE_URL=https://petstore.swagger.io/v2 \
-e OPENAPI_SPEC_PATH=https://raw.githubusercontent.com/readmeio/oas-examples/main/3.0/json/petstore.json \
-e TRANSPORT_TYPE=http \
reallv/openapi-mcp-server:latest
# Run with stdio transport (for Claude Desktop)
docker run --rm -i \
-e API_BASE_URL=https://api.example.com \
-e OPENAPI_SPEC_PATH=https://api.example.com/openapi.json \
reallv/openapi-mcp-server:latest
# Use docker-compose for multiple APIs
docker-compose up -d
Library Usage
npm install @lucid-spark/openapi-mcp-server
import { OpenAPIServer } from "@lucid-spark/openapi-mcp-server";
const server = new OpenAPIServer({
apiBaseUrl: "https://api.example.com",
openApiSpec: "https://api.example.com/openapi.json",
transportType: "stdio",
});
await server.start();
š Documentation
- Complete Documentation - Comprehensive guide with examples and patterns
- Library Usage - For developers creating custom MCP servers using this package
- Developer Guide - For contributors and developers working on the codebase
- Examples Directory - Practical usage examples and patterns
For MCP protocol details, see modelcontextprotocol.io.
š Table of Contents
- Architecture
- Installation
- Configuration
- Docker Usage
- Usage Examples
- Claude Desktop Integration
- Authentication
- Tool Management
- Transport Types
- API Documentation
- Development
- Examples
- Troubleshooting
š Architecture
The OpenAPI MCP Server uses a modular, interface-based architecture for maximum flexibility and type safety:
āāāāāāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāāāāāā
ā OpenAPI Server ā ā Configuration ā ā Type System ā
ā ā ā ā ā ā
ā ⢠Orchestration āāāāāŗā ⢠Validation āāāāāŗā ⢠Interface-based ā
ā ⢠MCP Protocol ā ā ⢠Defaults ā ā ⢠Type Safety ā
ā ⢠Lifecycle Mgmt ā ā ⢠Environment Vars ā ā ⢠Extensibility ā
āāāāāāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāāāāāā
ā ā ā
ā¼ ā¼ ā¼
āāāāāāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāāāāāā
ā OpenAPI Spec ā ā Tools Manager ā ā Authentication ā
ā Loader ā ā ā ā System ā
ā ā ā ⢠Tool Creation ā ā ā
ā ⢠Multiple Inputs ā ā ⢠Filtering ā ā ⢠Static Headers ā
ā ⢠$ref Resolution ā ā ⢠Lookup & Cache ā ā ⢠Dynamic Providers ā
ā ⢠Schema Processing ā ā ⢠Meta-tool
Tools (1)
dynamic-api-toolsAutomatically generated tools based on the provided OpenAPI specification operations.Environment Variables
API_BASE_URLrequiredThe base URL of the target REST APIOPENAPI_SPEC_PATHrequiredURL or local path to the OpenAPI JSON specificationTRANSPORT_TYPECommunication protocol (stdio or http)Configuration
{"mcpServers": {"openapi": {"command": "npx", "args": ["-y", "@lucid-spark/openapi-mcp-server"], "env": {"API_BASE_URL": "https://api.example.com", "OPENAPI_SPEC_PATH": "https://api.example.com/openapi.json"}}}}