mirror of
https://github.com/mudler/LocalAI
synced 2026-05-24 09:28:23 +00:00
* fix: resolve duplicate MCP route registration causing 50% failure rate Fixes #7772 The issue was caused by duplicate registration of the MCP endpoint /mcp/v1/chat/completions in both openai.go and localai.go, leading to a race condition where requests would randomly hit different handlers with incompatible behaviors. Changes: - Removed duplicate MCP route registration from openai.go - Kept the localai.MCPStreamEndpoint as the canonical handler - Added all three MCP route patterns for backward compatibility: * /v1/mcp/chat/completions * /mcp/v1/chat/completions * /mcp/chat/completions - Added comments to clarify route ownership and prevent future conflicts - Fixed formatting in ui_api.go The localai.MCPStreamEndpoint handler is more feature-complete as it supports both streaming and non-streaming modes, while the removed openai.MCPCompletionEndpoint only supported synchronous requests. This eliminates the ~50% failure rate where the cogito library would receive "Invalid http method" errors when internal HTTP requests were routed to the wrong handler. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> Signed-off-by: majiayu000 <1835304752@qq.com> * Address feedback from review Signed-off-by: Ettore Di Giacinto <mudler@localai.io> --------- Signed-off-by: majiayu000 <1835304752@qq.com> Signed-off-by: Ettore Di Giacinto <mudler@localai.io> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com> Co-authored-by: Ettore Di Giacinto <mudler@localai.io> |
||
|---|---|---|
| .. | ||
| agent_jobs.go | ||
| backend.go | ||
| backend_monitor.go | ||
| detection.go | ||
| edit_model.go | ||
| edit_model_test.go | ||
| gallery.go | ||
| get_token_metrics.go | ||
| import_model.go | ||
| localai_suite_test.go | ||
| mcp.go | ||
| metrics.go | ||
| p2p.go | ||
| settings.go | ||
| stores.go | ||
| system.go | ||
| tokenize.go | ||
| tts.go | ||
| types.go | ||
| vad.go | ||
| video.go | ||
| welcome.go | ||