fix(mcp): mount /mcp/rpc with explicit method patterns

Go 1.22 ServeMux treats prefix patterns as conflicting with the root
catch-all when one matches more methods than the other. Switch from
prefix mounting (`/mcp/`) to two explicit `POST/GET /mcp/rpc` handlers
so the projax server boots cleanly. /healthz crash loop on first deploy
of phase 3a was caused by this.
This commit is contained in:
mAi
2026-05-15 18:11:49 +02:00
parent dc50823860
commit 4c8488cdbb

View File

@@ -136,7 +136,12 @@ func (s *Server) Routes() http.Handler {
})
if s.MCP != nil {
mux.Handle("/mcp/", http.StripPrefix("/mcp", s.MCP))
// Mount MCP routes with explicit method+path patterns. A prefix pattern
// like `/mcp/` would conflict with `GET /` under Go 1.22's strict
// ServeMux (the prefix matches more methods than the subtree root).
mcpHandler := http.StripPrefix("/mcp", s.MCP)
mux.Handle("POST /mcp/rpc", mcpHandler)
mux.Handle("GET /mcp/rpc", mcpHandler)
}
static, _ := fs.Sub(staticFS, "static")