--- title: "OpenAPI Integration" description: "Generate OpenAPI specifications from MCP tools for seamless integration with OpenWebUI and other systems" --- # OpenAPI Generation for OpenWebUI Integration MCPHub now supports generating OpenAPI 3.0.3 specifications from MCP tools, enabling seamless integration with OpenWebUI and other OpenAPI-compatible systems without requiring MCPO as an intermediary proxy. ## Features - ✅ **Automatic OpenAPI Generation**: Converts MCP tools to OpenAPI 3.0.3 specification - ✅ **OpenWebUI Compatible**: Direct integration without MCPO proxy - ✅ **Real-time Tool Discovery**: Dynamically includes tools from connected MCP servers - ✅ **Dual Parameter Support**: Supports both GET (query params) and POST (JSON body) for tool execution - ✅ **No Authentication Required**: OpenAPI endpoints are public for easy integration - ✅ **Comprehensive Metadata**: Full OpenAPI specification with proper schemas and documentation ## API Endpoints ### OpenAPI Specification ```bash GET /api/openapi.json curl "http://localhost:3000/api/openapi.json" ``` ```bash With Parameters curl "http://localhost:3000/api/openapi.json?title=My MCP API&version=2.0.0" ``` Generates and returns the complete OpenAPI 3.0.3 specification for all connected MCP tools. **Query Parameters:** Custom API title Custom API description Custom API version Custom server URL Include disabled tools Comma-separated list of server names to include ### Group/Server-Specific OpenAPI Specification ```bash GET /api/:name/openapi.json curl "http://localhost:3000/api/mygroup/openapi.json" ``` ```bash With Parameters curl "http://localhost:3000/api/myserver/openapi.json?title=My Server API&version=1.0.0" ``` Generates and returns the OpenAPI 3.0.3 specification for a specific group or server. If a group with the given name exists, it returns the specification for all servers in that group. Otherwise, it treats the name as a server name and returns the specification for that server only. **Path Parameters:** Group ID/name or server name **Query Parameters:** Same as the main OpenAPI specification endpoint (title, description, version, serverUrl, includeDisabled). ### Available Servers ```bash GET /api/openapi/servers curl "http://localhost:3000/api/openapi/servers" ``` Returns a list of connected MCP server names. ```json Example Response { "success": true, "data": ["amap", "playwright", "slack"] } ``` ### Tool Statistics ```bash GET /api/openapi/stats curl "http://localhost:3000/api/openapi/stats" ``` Returns statistics about available tools and servers. ```json Example Response { "success": true, "data": { "totalServers": 3, "totalTools": 41, "serverBreakdown": [ {"name": "amap", "toolCount": 12, "status": "connected"}, {"name": "playwright", "toolCount": 21, "status": "connected"}, {"name": "slack", "toolCount": 8, "status": "connected"} ] } } ``` ### Tool Execution ```bash GET /api/tools/{serverName}/{toolName} curl "http://localhost:3000/api/tools/amap/amap-maps_weather?city=Beijing" ``` ```bash POST /api/tools/{serverName}/{toolName} curl -X POST "http://localhost:3000/api/tools/playwright/playwright-browser_navigate" \ -H "Content-Type: application/json" \ -d '{"url": "https://example.com"}' ``` Execute MCP tools via OpenAPI-compatible endpoints. **Path Parameters:** The name of the MCP server The name of the tool to execute ## OpenWebUI Integration To integrate MCPHub with OpenWebUI: Ensure MCPHub is running with your MCP servers configured ```bash curl http://localhost:3000/api/openapi.json > mcphub-api.json ``` Import the OpenAPI specification file or point to the URL directly in OpenWebUI ### Configuration Example In OpenWebUI, you can add MCPHub as an OpenAPI tool by using: `http://localhost:3000/api/openapi.json` `http://localhost:3000/api` ## Generated OpenAPI Structure The generated OpenAPI specification includes: ### Tool Conversion Logic - **Simple tools** (≤10 primitive parameters) → GET endpoints with query parameters - **Complex tools** (objects, arrays, or >10 parameters) → POST endpoints with JSON request body - **All tools** include comprehensive response schemas and error handling ### Example Generated Operation ```yaml /tools/amap/amap-maps_weather: get: summary: "根据城市名称或者标准adcode查询指定城市的天气" operationId: "amap_amap-maps_weather" tags: ["amap"] parameters: - name: city in: query required: true description: "城市名称或者adcode" schema: type: string responses: '200': description: "Successful tool execution" content: application/json: schema: $ref: '#/components/schemas/ToolResponse' ``` ### Security - Bearer authentication is defined but not enforced for tool execution endpoints - Enables flexible integration with various OpenAPI-compatible systems ## Benefits over MCPO No need for intermediate proxy OpenAPI spec updates automatically as MCP servers connect/disconnect Direct tool execution without proxy overhead One less component to manage ## Troubleshooting Ensure MCP servers are connected. Check `/api/openapi/stats` for server status. Verify the tool name and parameters match the OpenAPI specification. Check server logs for details. Ensure MCPHub is accessible from OpenWebUI and the OpenAPI URL is correct. Check if tools are enabled in your MCP server configuration. Use `includeDisabled=true` to see all tools.