fix(ingestion): support GET/SSE on /mcp endpoint for claude.ai compatibility
All checks were successful
CI / Lint / Test / Vet (push) Successful in 10s
CI / Mirror to GitHub (push) Successful in 3s

This commit is contained in:
Mathias Bergqvist
2026-05-07 23:20:47 +02:00
parent 7139a3ca74
commit 78be3d1f9c
2 changed files with 15 additions and 1 deletions

View File

@@ -80,7 +80,7 @@ func main() {
mux.HandleFunc("POST /ingest-raw", h.IngestRaw)
mux.HandleFunc("POST /backfill-refs", h.BackfillRefs)
mux.HandleFunc("GET /pass-rate", h.PassRate)
mux.Handle("POST /mcp", mcp.BearerAuth(mcpToken, mcpSrv))
mux.Handle("/mcp", mcp.BearerAuth(mcpToken, mcpSrv))
addr := ":" + port
watchIntervalLog := "disabled"

View File

@@ -48,6 +48,20 @@ func NewServer(brainDir string, pipelineCfg *pipeline.Config, llm pipeline.Compl
}
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// MCP streamable HTTP: GET establishes the SSE stream for server-to-client events.
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 {
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")