Uses Swagger/OpenAPI specifications to dynamically generate MCP tools, enabling AI agents to interact with any API that provides an OpenAPI specification
OpenAPI to Model Context Protocol (MCP)
The OpenAPI-MCP proxy translates OpenAPI specs into MCP tools, enabling AI agents to access external APIs without custom wrappers!
Bridge the gap between AI agents and external APIs
The OpenAPI to Model Context Protocol (MCP) proxy server bridges the gap between AI agents and external APIs by dynamically translating OpenAPI specifications into standardized MCP tools, resources, and prompts. This simplifies integration by eliminating the need for custom API wrappers.
Built with FastMCP following official MCP patterns and best practices, the server provides:
- ✅ Official FastMCP Integration - Uses the latest FastMCP framework for optimal performance
- ✅ Proper MCP Transport - Supports stdio, SSE, and streamable HTTP transports
- ✅ Modular Architecture - Clean separation of concerns with dependency injection
- ✅ Production Ready - Robust error handling, comprehensive logging, and type safety
- Repository: https://github.com/gujord/OpenAPI-MCP
If you find it useful, please give it a ⭐ on GitHub!
Key Features
Core Functionality
- FastMCP Transport: Optimized for
stdio
, working out-of-the-box with popular LLM orchestrators. - OpenAPI Integration: Parses and registers OpenAPI operations as callable tools.
- Resource Registration: Automatically converts OpenAPI component schemas into resource objects with defined URIs.
- Prompt Generation: Generates contextual prompts based on API operations to guide LLMs in using the API.
- Dual Authentication: Supports both OAuth2 Client Credentials flow and username/password authentication with automatic token caching.
- MCP HTTP Transport: Official MCP-compliant HTTP streaming transport with JSON-RPC 2.0 over SSE.
- Server-Sent Events (SSE): Legacy streaming support (deprecated - use MCP HTTP transport).
- JSON-RPC 2.0 Support: Fully compliant request/response structure.
Advanced Features
- Modular Architecture: Clean separation of concerns with dedicated modules for authentication, request handling, and tool generation.
- Robust Error Handling: Comprehensive exception hierarchy with proper JSON-RPC error codes and structured error responses.
- Auto Metadata: Derives tool names, summaries, and schemas from the OpenAPI specification.
- Sanitized Tool Names: Ensures compatibility with MCP name constraints.
- Flexible Parameter Parsing: Supports query strings, JSON, and comma-separated formats with intelligent type conversion.
- Enhanced Parameter Handling: Automatically converts parameters to correct data types with validation.
- Extended Tool Metadata: Includes detailed parameter information, response schemas, and API categorization.
- CRUD Operation Detection: Automatically identifies and generates example prompts for Create, Read, Update, Delete operations.
- MCP-Compliant Streaming: Official MCP HTTP transport for real-time streaming with proper session management.
Developer Experience
- Configuration Management: Centralized environment variable handling with validation and defaults.
- Comprehensive Logging: Structured logging with appropriate levels for debugging and monitoring.
- Type Safety: Full type hints and validation throughout the codebase.
- Extensible Design: Factory patterns and dependency injection for easy customization and testing.
🚀 Quick Start
Installation
🎯 Simple Usage
Option 1: Quick Test (Norwegian Weather API)
Option 2: HTTP Transport (Recommended for Claude Desktop)
🔗 Claude Desktop Setup
1. Copy the provided configuration:
2. Start the weather server:
3. Test in Claude Desktop:
- Ask: "What's the weather in Oslo tomorrow?"
- Claude will use the
weather_get__compact
tool automatically!
🌐 Multiple API Servers
Run multiple OpenAPI services simultaneously:
🐳 Docker Deployment
Quick start with Docker:
This automatically runs:
- Weather API on port 8001
- Petstore API on port 8002
⚙️ Advanced Configuration
Claude Desktop / Cursor / Windsurf
HTTP Transport (Recommended):
Use the provided configuration file:
Or create manually:
Stdio Transport (Alternative):
Note: Replace
/full/path/to/OpenAPI-MCP
with your actual installation path.
With Username/Password Authentication
With OAuth2 Authentication
Multiple API Servers with MCP HTTP Transport
Configure multiple OpenAPI services to run simultaneously:
This configuration gives Claude access to both weather data AND petstore API tools simultaneously, with clear tool naming like weather_get__compact
and petstore_addPet
.
Single API Server with MCP HTTP Transport
For a single API service:
Standard SSE Configuration:
Streamable HTTP Configuration:
With Debugging (for development):
With Custom Transport Strategy:
With Legacy SSE Streaming (Deprecated)
Apply this configuration to the following files:
- Cursor:
~/.cursor/mcp.json
- Windsurf:
~/.codeium/windsurf/mcp_config.json
- Claude Desktop:
~/Library/Application Support/Claude/claude_desktop_config.json
Replace
full_path_to_openapi_mcp
with your actual installation path.
Quick Setup for Multiple APIs
Copy the provided example configuration:
Start both services:
Result: Claude gets access to both weather and petstore APIs with prefixed tool names.
Environment Configuration
Core Configuration
Variable | Description | Required | Default |
---|---|---|---|
OPENAPI_URL | URL to the OpenAPI specification | Yes | - |
SERVER_NAME | MCP server name | No | openapi_proxy_server |
OAuth2 Authentication
Variable | Description | Required | Default |
---|---|---|---|
OAUTH_CLIENT_ID | OAuth client ID | No | - |
OAUTH_CLIENT_SECRET | OAuth client secret | No | - |
OAUTH_TOKEN_URL | OAuth token endpoint URL | No | - |
OAUTH_SCOPE | OAuth scope | No | api |
Username/Password Authentication
Variable | Description | Required | Default |
---|---|---|---|
API_USERNAME | API username for authentication | No | - |
API_PASSWORD | API password for authentication | No | - |
API_LOGIN_ENDPOINT | Login endpoint URL | No | Auto-detected |
MCP HTTP Transport (Recommended)
Variable | Description | Required | Default |
---|---|---|---|
MCP_HTTP_ENABLED | Enable MCP HTTP transport | No | false |
MCP_HTTP_HOST | MCP HTTP server host | No | 127.0.0.1 |
MCP_HTTP_PORT | MCP HTTP server port | No | 8000 |
MCP_CORS_ORIGINS | CORS origins (comma-separated) | No | * |
MCP_MESSAGE_SIZE_LIMIT | Message size limit | No | 4mb |
MCP_BATCH_TIMEOUT | Batch timeout in seconds | No | 30 |
MCP_SESSION_TIMEOUT | Session timeout in seconds | No | 3600 |
Legacy SSE Support (Deprecated)
Variable | Description | Required | Default |
---|---|---|---|
SSE_ENABLED | Enable SSE streaming support | No | false |
SSE_HOST | SSE server host | No | 127.0.0.1 |
SSE_PORT | SSE server port | No | 8000 |
🛠️ Examples & Use Cases
Norwegian Weather API
Test with real weather data (no authentication required):
Available tools:
weather_get__compact
- Weather forecast for coordinatesweather_get__complete
- Detailed weather forecastweather_get__status
- Server status
Example usage in Claude:
- "What's the weather in Oslo tomorrow?" → Uses lat=59.9139, lon=10.7522
- "Show me detailed weather for Bergen" → Uses lat=60.3913, lon=5.3221
Pet Store API
Test with Swagger's demo API:
Available tools:
petstore_addPet
- Add a new pet to the storepetstore_findPetsByStatus
- Find pets by statuspetstore_getPetById
- Find pet by ID
🏗️ Architecture
FastMCP-Based Design
Key Features
✅ FastMCP Integration - Uses latest FastMCP framework
✅ Automatic Tool Registration - Converts OpenAPI operations to MCP tools
✅ Multi-Transport Support - stdio, HTTP, SSE
✅ Parameter Validation - Type conversion and validation
✅ Error Handling - Comprehensive JSON-RPC error responses
✅ Authentication - OAuth2 and username/password support
How It Works
- Configuration Loading: Validates environment variables and server configuration.
- OpenAPI Spec Loading: Fetches and parses OpenAPI specifications with comprehensive error handling.
- Component Initialization: Sets up modular components with dependency injection.
- Tool Registration: Dynamically creates MCP tools from OpenAPI operations with full metadata.
- Resource Registration: Converts OpenAPI schemas into MCP resources with proper URIs.
- Prompt Generation: Creates contextual usage prompts and CRUD operation examples.
- Authentication: Handles both OAuth2 and username/password authentication with token caching and automatic renewal.
- Request Processing: Advanced parameter parsing, type conversion, and validation.
- Error Handling: Comprehensive exception handling with structured error responses.
Resources & Prompts
The server automatically generates comprehensive metadata to enhance AI integration:
Resources
- Schema-based Resources: Automatically derived from OpenAPI component schemas
- Structured URIs: Resources are registered with consistent URIs (e.g.,
/resource/{server_name}_{schema_name}
) - Type Conversion: OpenAPI schemas are converted to MCP-compatible resource definitions
- Metadata Enrichment: Resources include server context and categorization tags
Prompts
- API Usage Guides: General prompts explaining available operations and their parameters
- CRUD Examples: Automatically generated examples for Create, Read, Update, Delete operations
- Contextual Guidance: Operation-specific prompts with parameter descriptions and usage patterns
- Server-specific Branding: All prompts are prefixed with server name for multi-API environments
Benefits
- Enhanced Discoverability: AI agents can better understand available API capabilities
- Usage Guidance: Prompts provide clear examples of how to use each operation
- Type Safety: Resource schemas ensure proper data structure understanding
- Context Awareness: Server-specific metadata helps with multi-API integration
📊 Performance & Production
Performance Characteristics
- Fast Startup: Initializes in ~2-3 seconds
- Low Memory: ~50MB base memory usage
- Concurrent Requests: Handles multiple API calls simultaneously
- Caching: Automatic OpenAPI spec and authentication token caching
Production Deployment
Monitoring
- Health check endpoint:
GET /health
- Metrics via structured logging
- Error tracking with JSON-RPC error codes
🔍 Troubleshooting
Common Issues
❌ RequestHandler.prepare_request() missing arguments
❌ Claude Desktop doesn't see the tools
❌ Connection refused on port 8001
❌ SSL/TLS errors with OpenAPI URLs
Testing Tools
Test server initialization:
Test with mcp-remote:
Check available tools:
Environment Issues
Python version mismatch:
Missing dependencies:
🤝 Contributing
- Fork this repository
- Create a feature branch:
git checkout -b feature/amazing-feature
- Commit changes:
git commit -m 'Add amazing feature'
- Push to branch:
git push origin feature/amazing-feature
- Open a Pull Request
📄 License
Audits
Star History
If you find it useful, please give it a ⭐ on GitHub!
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
A proxy server that bridges AI agents and external APIs by dynamically translating OpenAPI specifications into standardized MCP tools, enabling seamless interaction without custom integration code.
Related MCP Servers
- AsecurityAlicenseAqualityAn MCP server that generates AI agent tools from Postman collections and requests. This server integrates with the Postman API to convert API endpoints into type-safe code that can be used with various AI frameworks.Last updated -112JavaScriptMIT License
- -securityAlicense-qualityA proxy server that enables AI assistants to run and interact with command-line applications like Expo through the Model Context Protocol (MCP), capturing logs and allowing keypress forwarding.Last updated -89TypeScriptMIT License
- -securityAlicense-qualityA command-line tool that transforms any OpenAPI service into a Model Context Protocol (MCP) server, enabling seamless integration with AI agents and tools that support the MCP specification.Last updated -35TypeScriptMIT License
- -securityFlicense-qualityA dynamic proxy that converts OpenAPI Specification (OAS) endpoints into Message Communication Protocol (MCP) tools, allowing AI agents to use existing REST APIs as if they were native MCP tools without manual implementation.Last updated -16TypeScript