diff --git a/ingestion/cmd/server/main.go b/ingestion/cmd/server/main.go index 92f1398..b75ffc6 100644 --- a/ingestion/cmd/server/main.go +++ b/ingestion/cmd/server/main.go @@ -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" diff --git a/ingestion/internal/mcp/server.go b/ingestion/internal/mcp/server.go index a787f7a..26c0983 100644 --- a/ingestion/internal/mcp/server.go +++ b/ingestion/internal/mcp/server.go @@ -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")