MCP server with tools for efficient querying of OpenAPI specifications
1.9K
Stop drowning your LLM in API documentation. This MCP server gives LLMs intelligent, progressive access to OpenAPI specs without overwhelming their context windows.
{
"openapi-context": { // name it whatever you want
"command": "docker",
"args": [
"run", "--rm", "-i",
"-v", "/path/to/your/openapi.yaml:/app/spec:ro", // filepath + :/app/spec:ro
"djankies/openapi-context:latest"
]
}
}
That's it. Your LLM now has API hotwheels.
I wanted to create a tool that was more effective at helping LLMs efficiently navigate and retrieve laser-scoped information from OpenAPI specs without overwhelming their context windows. LLMs start with high-level overviews, then drill down only into what they need, being naturally guided by the tools the whole way.
Every tool description is dynamically generated to include context about the loaded API:
list_operations: "List all endpoints from Petstore API v1.0.0"
get_operation_details: "Get details for operations in Petstore API v1.0.0"
Every error includes the exact next step:
**Operation Not Found**
Operation not found: createUser
๐ก Use `list_operations()` to see available operations or call `help()` for usage guidance.
The tool design naturally guides LLMs through efficient exploration:
list_tags โ See API structureget_operation_summary โ Quick overview without schemasget_request_schema โ Details only when needed// LLM can request minimal info
get_operation_details({ operation_id: "createUser", detail_level: "minimal" })
// Or specific fields only
get_operation_details({ operation_id: "createUser", fields: ["parameters"] })
// Or compact schemas
get_request_schema({ operation_id: "createUser", compact: true })
// Returns: "Type: object { name: string, email: string (email) }"
Helpful Parameter Validation:
**Missing Parameters**
Please provide either `operation_id` or both `method` and `path`.
๐ก Need help with tool usage? Call the `help` tool for detailed parameter guidance.
Built-in Health Check:
The ping helps the llm verify the server is actually responsive when receiving errors, preventing extraneous calls to the tool when the server is not running.
**Server Status**
Status: Ready
OpenAPI Spec: Loaded (Petstore API v1.0.0)
Ready to process queries.
list_tags - See API categories with operation countslist_operations - List endpoints with filtering and compact modesearch_operations - Find endpoints by keywordget_operation_summary - Quick overview without full schemasget_operation_details - Full endpoint info with customizable detail levelsget_request_schema - Request schemas with pagination and compact modeget_response_schema - Response schemas by status codeget_operation_examples - Example payloads when availableget_auth_requirements - Authentication details with examplesget_server_info - API metadata and statisticsping - Check server responsivenesshelp - Comprehensive guidance with current context// 1. Understand API structure (3 lines)
list_tags()
// โ "Users (12 operations), Orders (8 operations), Auth (3 operations)"
// 2. Find relevant operations (10 lines)
list_operations({ filter: "Users", compact: true })
// โ "GET /users - List users\nPOST /users - Create user..."
// 3. Get overview before diving deep (5 lines)
get_operation_summary({ operation_id: "createUser" })
// โ "POST /users\nParameters: body: required\nRequired: name, email\nAuth: api_key"
// 4. Get details only when needed (1 line with compact mode)
get_request_schema({ operation_id: "createUser", compact: true })
// โ "Type: object { name: string, email: string (email), age?: number }"
The server provides three detail levels that LLMs can choose based on their needs:
minimal: Just operation signatures and required fieldsstandard: Simplified schemas without patterns (default)full: Complete details including patterns and examplesWhen schemas are large, LLMs receive clear continuation instructions:
Page 1 of 3 (showing 0-2000 of 5432 chars)
...content...
Use index=2000 to continue reading.
{
"openapi-context": {
"command": "docker",
"args": [
"run", "--rm", "-i",
"-v", "/path/to/your/spec.yaml:/app/spec:ro",
"djankies/openapi-context:latest"
]
}
}
Each API gets its own instance with dedicated tool contexts:
{
"users-api": {
"command": "docker",
"args": [
"run", "--rm", "-i",
"-v", "/path/to/users-api.yaml:/app/spec:ro",
"djankies/openapi-context:latest"
]
},
"orders-api": {
"command": "docker",
"args": [
"run", "--rm", "-i",
"-v", "/path/to/orders-api.yaml:/app/spec:ro",
"djankies/openapi-context:latest"
]
}
}
| Variable | Description | Default |
|---|---|---|
LOG_LEVEL | Logging verbosity (error, warn, info, debug) | info |
MAX_SPEC_SIZE | Maximum OpenAPI spec file size in MB | 10 |
MCP_MODE | Server mode (stdio for MCP, http for debugging) | stdio |
Test the server independently:
docker run --rm -p 3000:3000 \
-e MCP_MODE=http \
-v "/path/to/spec.yaml:/app/spec:ro" \
djankies/openapi-context:latest
Access health check at http://localhost:3000/health
# Install dependencies
npm install
# Run tests
npm test
# Development mode
npm run dev
# Full CI pipeline
npm run ci
.yaml, .yml, .jsonMIT License - see LICENSEโ file for details.
Content type
Image
Digest
sha256:95eaf6534โฆ
Size
78.2 MB
Last updated
over 1 year ago
docker pull djankies/openapi-context