""" PATCH: Add OpenAI-compatible routes to gateway_proxy.py This file contains the modifications needed to add OpenAI API support to the MCP gateway. Apply these changes to gateway_proxy.py: 1. Add import at the top of the file (after other imports): from .openai_routes_fixed import convert_mcp_tool_to_openai, list_models, tools, chat_completions 2. Add these routes to the routes list (before the closing bracket): # OpenAI-compatible API endpoints Route("/v1/models", list_models, methods=["GET"]), Route("/v1/tools", lambda r: tools(r, TOOL_DEFINITIONS), methods=["GET"]), Route("/v1/chat/completions", lambda r: chat_completions(r, TOOL_DEFINITIONS), methods=["POST"]), 3. The lambda functions are necessary to pass TOOL_DEFINITIONS to the handlers. IMPLEMENTATION STEPS: ===================== 1. Make a backup of gateway_proxy.py: cp gateway_proxy.py gateway_proxy.backup 2. Add the import statement after line 27 (after from .openai_routes import...): from .openai_routes_fixed import convert_mcp_tool_to_openai, list_models, tools, chat_completions 3. Find the routes list (around line 795) and add before the final closing bracket: # OpenAI-compatible API endpoints (for Open-UI and other OpenAI clients) Route("/v1/models", list_models, methods=["GET"]), Route("/v1/tools", lambda r: tools(r, TOOL_DEFINITIONS), methods=["GET"]), Route("/v1/chat/completions", lambda r: chat_completions(r, TOOL_DEFINITIONS), methods=["POST"]), 4. Restart the gateway container: docker-compose restart gateway-proxy 5. Test tool discovery from OpenUI: GET http://mcp.wilddragon.net:8000/v1/tools Should return JSON with "data" array containing tool definitions in OpenAI format. """ print(__doc__)