fix(mcp): allow GET/SSE without session ID for claude.ai compatibility
Some checks failed
CD / Lint / Test / Vet (push) Failing after 3s
CD / Build & Import (push) Has been skipped
CD / Deploy via GitOps (push) Has been skipped

This commit is contained in:
Mathias Bergqvist
2026-05-07 23:22:21 +02:00
parent d8db786e27
commit c4d3735272

View File

@@ -111,11 +111,8 @@ func (s *Server) handlePOST(w http.ResponseWriter, r *http.Request) {
} }
func (s *Server) handleGET(w http.ResponseWriter, r *http.Request) { func (s *Server) handleGET(w http.ResponseWriter, r *http.Request) {
sid := r.Header.Get("Mcp-Session-Id") // Session ID is optional for GET: clients may open the SSE stream before
if !s.opts.Sessions.Valid(sid) { // calling initialize (e.g. claude.ai probes on add). Accept with or without.
http.Error(w, "missing or invalid Mcp-Session-Id", http.StatusBadRequest)
return
}
w.Header().Set("Content-Type", "text/event-stream") w.Header().Set("Content-Type", "text/event-stream")
w.Header().Set("Cache-Control", "no-cache") w.Header().Set("Cache-Control", "no-cache")
w.Header().Set("Connection", "keep-alive") w.Header().Set("Connection", "keep-alive")