The OpenAPI to Model Context Protocol (MCP) proxy server translates OpenAPI specifications into MCP tools, allowing AI agents to seamlessly access external APIs without needing custom wrappers. It acts as a bridge between AI models and API services by dynamically converting API operations into standardized tools that AI agents can use.
git clone https://github.com/gujord/OpenAPI-MCP.git
cd OpenAPI-MCP
python3.12 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
For a quick start using Docker:
# Start all services (weather + petstore)
./docker-start.sh
# Or manually
docker-compose up --build -d
This runs the Weather API on port 8001 and Petstore API on port 8002.
# Activate virtual environment
source venv/bin/activate
# Run weather API server
OPENAPI_URL="https://api.met.no/weatherapi/locationforecast/2.0/swagger" \
SERVER_NAME="weather" \
python src/fastmcp_server.py
# Start weather API with HTTP transport
source venv/bin/activate && \
OPENAPI_URL="https://api.met.no/weatherapi/locationforecast/2.0/swagger" \
SERVER_NAME="weather" \
MCP_HTTP_ENABLED="true" \
MCP_HTTP_PORT="8001" \
python src/fastmcp_server.py
Run multiple OpenAPI services simultaneously:
# Terminal 1: Weather API
source venv/bin/activate && \
OPENAPI_URL="https://api.met.no/weatherapi/locationforecast/2.0/swagger" \
SERVER_NAME="weather" \
MCP_HTTP_ENABLED="true" \
MCP_HTTP_PORT="8001" \
python src/fastmcp_server.py
# Terminal 2: Petstore API
source venv/bin/activate && \
OPENAPI_URL="https://petstore3.swagger.io/api/v3/openapi.json" \
SERVER_NAME="petstore" \
MCP_HTTP_ENABLED="true" \
MCP_HTTP_PORT="8002" \
python src/fastmcp_server.py
cp claude_desktop_config.json ~/Library/Application\ Support/Claude/claude_desktop_config.json
source venv/bin/activate && \
OPENAPI_URL="https://api.met.no/weatherapi/locationforecast/2.0/swagger" \
SERVER_NAME="weather" \
MCP_HTTP_ENABLED="true" \
MCP_HTTP_PORT="8001" \
python src/fastmcp_server.py
Ask: "What's the weather in Oslo tomorrow?" and Claude will use the weather_get__compact
tool automatically!
{
"mcpServers": {
"weather": {
"command": "npx",
"args": ["mcp-remote", "http://127.0.0.1:8001/sse"]
},
"petstore": {
"command": "npx",
"args": ["mcp-remote", "http://127.0.0.1:8002/sse"]
}
}
}
{
"mcpServers": {
"secure_api": {
"command": "full_path_to_openapi_mcp/venv/bin/python",
"args": ["full_path_to_openapi_mcp/src/server.py"],
"env": {
"SERVER_NAME": "secure_api",
"OPENAPI_URL": "https://api.example.com/openapi.json",
"API_USERNAME": "your_username",
"API_PASSWORD": "your_password"
},
"transport": "stdio"
}
}
}
{
"mcpServers": {
"oauth_api": {
"command": "full_path_to_openapi_mcp/venv/bin/python",
"args": ["full_path_to_openapi_mcp/src/server.py"],
"env": {
"SERVER_NAME": "oauth_api",
"OPENAPI_URL": "https://api.example.com/openapi.json",
"OAUTH_CLIENT_ID": "your_client_id",
"OAUTH_CLIENT_SECRET": "your_client_secret",
"OAUTH_TOKEN_URL": "https://api.example.com/oauth/token"
},
"transport": "stdio"
}
}
}
Variable | Description | Required | Default |
---|---|---|---|
OPENAPI_URL |
URL to the OpenAPI specification | Yes | - |
SERVER_NAME |
MCP server name | No | openapi_proxy_server |
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 |
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 | * |
# Start weather server
source venv/bin/activate && \
OPENAPI_URL="https://api.met.no/weatherapi/locationforecast/2.0/swagger" \
SERVER_NAME="weather" \
MCP_HTTP_ENABLED="true" \
MCP_HTTP_PORT="8001" \
python src/fastmcp_server.py
Available tools:
weather_get__compact
- Weather forecast for coordinatesweather_get__complete
- Detailed weather forecastweather_get__status
- Server statusExample usage in Claude:
# Start petstore server
source venv/bin/activate && \
OPENAPI_URL="https://petstore3.swagger.io/api/v3/openapi.json" \
SERVER_NAME="petstore" \
MCP_HTTP_ENABLED="true" \
MCP_HTTP_PORT="8002" \
python src/fastmcp_server.py
Available tools:
petstore_addPet
- Add a new pet to the storepetstore_findPetsByStatus
- Find pets by statuspetstore_getPetById
- Find pet by ID❌ Claude Desktop doesn't see the tools
# Check configuration location
ls ~/Library/Application\ Support/Claude/claude_desktop_config.json
# Restart Claude Desktop after config changes
❌ Connection refused on port 8001
# Check if server is running
lsof -i :8001
# Check server logs for errors
❌ SSL/TLS errors with OpenAPI URLs
# Update certificates
pip install --upgrade certifi httpx
Test with mcp-remote:
npx mcp-remote http://127.0.0.1:8001/sse
Check available tools:
curl http://127.0.0.1:8001/health
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "openapi_service" '{"command":"npx","args":["mcp-remote","http://127.0.0.1:8001/sse"]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"openapi_service": {
"command": "npx",
"args": [
"mcp-remote",
"http://127.0.0.1:8001/sse"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"openapi_service": {
"command": "npx",
"args": [
"mcp-remote",
"http://127.0.0.1:8001/sse"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect