This MCP server dynamically translates OpenAPI specifications into standardized Model Context Protocol (MCP) tools, resources, and prompts, enabling AI agents to easily interact with external APIs without custom wrappers.
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
# Start all services (weather + petstore)
./docker-start.sh
# Or manually
docker-compose up --build -d
Option 1: Test with Norwegian Weather API
# 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
Option 2: HTTP Transport (Recommended for Claude Desktop)
# 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
1. Copy the provided configuration:
cp claude_desktop_config.json ~/Library/Application\ Support/Claude/claude_desktop_config.json
2. Start the 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
3. Test in Claude Desktop:
weather_get__compact
tool automatically!# 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
{
"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 |
---|---|---|---|
API_USERNAME |
API username for authentication | No | - |
API_PASSWORD |
API password for authentication | No | - |
API_LOGIN_ENDPOINT |
Login endpoint URL | No | Auto-detected |
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❌ RequestHandler.prepare_request() missing arguments
# Solution: Use fastmcp_server.py instead of server.py
python src/fastmcp_server.py # ✅ Correct
❌ 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
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 > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
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 explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.