From 43a82552721a1a2e4aafa199a54d079261c7bfdd Mon Sep 17 00:00:00 2001 From: Mathias Bergqvist Date: Thu, 7 May 2026 23:27:56 +0200 Subject: [PATCH] fix(mcp): add SSE GET handler for streamable HTTP transport claude.ai probes with GET before initialize; without this the supervisor returned application/json parse error instead of text/event-stream, causing "Couldn't reach the MCP server" in the claude.ai connector setup. Co-Authored-By: Claude Sonnet 4.6 --- internal/mcp/server.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/internal/mcp/server.go b/internal/mcp/server.go index a487730..3b21898 100644 --- a/internal/mcp/server.go +++ b/internal/mcp/server.go @@ -48,6 +48,22 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } + // GET opens the SSE stream for server-to-client events (MCP streamable HTTP). + // claude.ai probes with GET before sending initialize, so accept without a session. + if r.Method == http.MethodGet { + w.Header().Set("Content-Type", "text/event-stream") + w.Header().Set("Cache-Control", "no-cache") + w.Header().Set("Connection", "keep-alive") + w.Header().Set("X-Accel-Buffering", "no") + w.WriteHeader(http.StatusOK) + if f, ok := w.(http.Flusher); ok { + _, _ = w.Write([]byte(": stream open\n\n")) + f.Flush() + } + <-r.Context().Done() + return + } + var req request if err := json.NewDecoder(r.Body).Decode(&req); err != nil { writeError(w, nil, -32700, "parse error")