Automatically generates MCP tools from OpenAPI/Swagger specifications, enabling interaction with any OpenAPI-based API with built-in OAuth2 authentication management and automatic token refresh.
MCP OpenAPI Connector
A unified Model Context Protocol (MCP) server for connecting OpenAPI-based APIs with built-in authentication management. This project enables Claude Desktop, Cursor, and other MCP-compatible clients to interact with authenticated OpenAPI-based APIs without requiring separate proxy servers.
Features
Single Process Architecture: No separate proxy server needed
Built-in OAuth2 Authentication: Automatic token management and refresh
OpenAPI Integration: Automatically generate MCP tools from OpenAPI/Swagger specifications
Extensible Tool System: Easy to add custom tools and resources
Error Handling: Automatic retry and authentication error recovery
Simple Configuration: Single configuration file for all settings
Multiple API Support: Easily adapt to any OAuth2-based API
Installation
Via npm (Recommended)
Or use directly with npx:
From Source
Quick Setup (Recommended)
Run the interactive setup wizard:
This will:
Collect your API configuration through interactive prompts
Generate
generated/.envfile with your settingsCreate
generated/claude-desktop-config.jsonfor easy Claude Desktop integrationProvide step-by-step instructions for Claude Desktop configuration
Manual Configuration
Alternatively, you can set up manually:
Copy
.env.exampleto.env:
Edit
.envwith your API credentials:
Usage
Development Mode
For development with automatic recompilation:
Production Mode
Build and run the compiled version:
Claude Desktop Configuration
Add to your Claude Desktop config file:
Using npm package (Recommended):
Using global installation:
Using from source:
OpenAPI Integration
The server automatically generates tools from an OpenAPI specification. An OpenAPI specification is required for the server to function.
Place your OpenAPI spec file (JSON format) in the project
Set the path in your environment:
The server will automatically generate MCP tools from all operations in your OpenAPI spec. Without an OpenAPI specification, the server will only provide test/debug tools.
Custom Tools
Create custom tools by adding a JavaScript file:
Then set CUSTOM_TOOLS_PATH in your environment:
Publishing to npm
For maintainers:
Development
Available Scripts
TypeScript Development
This project is built with TypeScript for better type safety and development experience:
Source code:
src/directoryBuild output:
dist/directoryType definitions: Automatically generated
.d.tsfiles
Architecture
Key Components
src/mcp-openapi-connector.ts - Main server entry point
src/lib/token-manager.ts - OAuth2 token management with caching
src/lib/saas-client.ts - HTTP client with automatic authentication
src/lib/mcp-handler.ts - MCP protocol handling and tool registration
src/lib/openapi-loader.ts - OpenAPI specification parser and tool generator
src/types/ - TypeScript type definitions
Migration from v1.x
If you're using the previous gateway-based version:
Remove the proxy server configuration
Update your Claude Desktop config to point directly to this server
Use the same environment variables (no changes needed)
Example: Using with a Generic OpenAPI-based API
See the config/openapi-example.json file for a sample OpenAPI specification that demonstrates how to structure your API for MCP integration.
Troubleshooting
Authentication Errors
Verify CLIENT_ID and CLIENT_SECRET are correct
Check AUTH_URL points to the correct OAuth2 endpoint
Ensure your credentials have the necessary scopes
Connection Issues
Check API_BASE_URL is correct
Verify network connectivity
Check server logs for detailed error messages
Debug Mode
Set NODE_ENV=development for verbose logging:
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT
Acknowledgments
Built using the Model Context Protocol SDK by Anthropic.