OpenAPI to Model Context Protocol (MCP)
Bridge the gap between AI agents and external APIs
- Repository: https://github.com/gujord/OpenAPI-MCP
Key Features
- 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.
- OAuth2 Support: Handles machine authentication via Client Credentials flow.
- JSON-RPC 2.0 Support: Fully compliant request/response structure.
- 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 (with a leading "?") and multiple JSON variations (including keys with dots and numeric values).
- Enhanced Parameter Handling: Automatically converts parameters to the correct data types.
- Extended Tool Metadata: Includes detailed parameter information and response schemas.
Quick Start
Installation
LLM Orchestrator Configuration
- Cursor:
~/.cursor/mcp.json
- Windsurf:
~/.codeium/windsurf/mcp_config.json
- Claude Desktop:
~/Library/Application Support/Claude/claude_desktop_config.json
Replacefull_path_to_openapi_mcp
with your actual installation path.
Environment Configuration
[object Object] | [object Object] | [object Object] | [object Object] |
[object Object] | [object Object] | [object Object] | [object Object] |
[object Object] | [object Object] | [object Object] | [object Object] |
[object Object] | [object Object] | [object Object] | [object Object] |
[object Object] | [object Object] | [object Object] | [object Object] |
[object Object] | [object Object] | [object Object] | [object Object] |
[object Object] | [object Object] | [object Object] | [object Object] |
How It Works
- Parses OpenAPI Spec: Loads the OpenAPI specification using
httpx
andPyYAML
if needed.
- Registers Operations: Extracts API operations and generates MCP-compatible tools with proper input and response schemas.
- Resource Registration: Automatically converts OpenAPI component schemas into resource objects with assigned URIs (e.g.,
/resource/{name}
).
- Prompt Generation: Creates contextual prompts based on API operations to assist LLMs in understanding API usage.
- Authentication: Supports OAuth2 authentication via the Client Credentials flow.
- Parameter Handling: Converts parameters to required data types and supports flexible query string and JSON formats.
- JSON-RPC 2.0 Compliance: Ensures standard communication protocols for tool interactions.
Resources & Prompts
- Resources: Derived from OpenAPI component schemas, resource objects are registered with defined URIs (e.g.,
/resource/{name}
) for structured data handling.
- Prompts: Contextual prompts are generated based on API operations to provide usage guidance to LLMs, enhancing their understanding of available endpoints.
Contributing
- Fork this repository.
- Create a new branch.
- Submit a pull request with a clear description of your changes.
License
OpenAPI to Model Context Protocol (MCP)
Bridge the gap between AI agents and external APIs
- Repository: https://github.com/gujord/OpenAPI-MCP
Key Features
- 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.
- OAuth2 Support: Handles machine authentication via Client Credentials flow.
- JSON-RPC 2.0 Support: Fully compliant request/response structure.
- 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 (with a leading "?") and multiple JSON variations (including keys with dots and numeric values).
- Enhanced Parameter Handling: Automatically converts parameters to the correct data types.
- Extended Tool Metadata: Includes detailed parameter information and response schemas.
Quick Start
Installation
LLM Orchestrator Configuration
- Cursor:
~/.cursor/mcp.json
- Windsurf:
~/.codeium/windsurf/mcp_config.json
- Claude Desktop:
~/Library/Application Support/Claude/claude_desktop_config.json
Replacefull_path_to_openapi_mcp
with your actual installation path.
Environment Configuration
[object Object] | [object Object] | [object Object] | [object Object] |
[object Object] | [object Object] | [object Object] | [object Object] |
[object Object] | [object Object] | [object Object] | [object Object] |
[object Object] | [object Object] | [object Object] | [object Object] |
[object Object] | [object Object] | [object Object] | [object Object] |
[object Object] | [object Object] | [object Object] | [object Object] |
[object Object] | [object Object] | [object Object] | [object Object] |
How It Works
- Parses OpenAPI Spec: Loads the OpenAPI specification using
httpx
andPyYAML
if needed.
- Registers Operations: Extracts API operations and generates MCP-compatible tools with proper input and response schemas.
- Resource Registration: Automatically converts OpenAPI component schemas into resource objects with assigned URIs (e.g.,
/resource/{name}
).
- Prompt Generation: Creates contextual prompts based on API operations to assist LLMs in understanding API usage.
- Authentication: Supports OAuth2 authentication via the Client Credentials flow.
- Parameter Handling: Converts parameters to required data types and supports flexible query string and JSON formats.
- JSON-RPC 2.0 Compliance: Ensures standard communication protocols for tool interactions.
Resources & Prompts
- Resources: Derived from OpenAPI component schemas, resource objects are registered with defined URIs (e.g.,
/resource/{name}
) for structured data handling.
- Prompts: Contextual prompts are generated based on API operations to provide usage guidance to LLMs, enhancing their understanding of available endpoints.
Contributing
- Fork this repository.
- Create a new branch.
- Submit a pull request with a clear description of your changes.