Skip to content

fix(professional-crm): remove Accept header patch causing SSE reconnect loop#148

Open
Promithius-DR wants to merge 2 commits intoNateBJones-Projects:mainfrom
Promithius-DR:fix/crm-sse-reconnect-loop
Open

fix(professional-crm): remove Accept header patch causing SSE reconnect loop#148
Promithius-DR wants to merge 2 commits intoNateBJones-Projects:mainfrom
Promithius-DR:fix/crm-sse-reconnect-loop

Conversation

@Promithius-DR
Copy link
Copy Markdown

Problem

The POST /mcp handler patches every incoming request to add Accept: application/json, text/event-stream before passing it to StreamableHTTPTransport. When StreamableHTTPTransport sees text/event-stream in the Accept header, it switches to SSE response mode.

Supabase edge functions are stateless — they terminate after each response. An SSE stream that terminates immediately looks like a dropped connection to the MCP client, which reconnects every ~2 seconds. This results in ~43,000 Supabase invocations per day with zero actual tool usage.

Root Cause

// This block forces SSE mode on every request ❌
if (!c.req.header("accept")?.includes("text/event-stream")) {
  const headers = new Headers(c.req.raw.headers);
  headers.set("Accept", "application/json, text/event-stream");
  // ...patches request
}

Fix

Remove the Accept header patch entirely. StreamableHTTPTransport is designed for request/response — without the SSE accept header, it responds with plain JSON, the edge function terminates cleanly, and the client only calls again when it needs to invoke a tool.

Claude Code (the primary consumer of this extension) sends correct Streamable HTTP headers and does not need this workaround.

Impact

  • Eliminates ~43k idle Supabase invocations/day
  • Keeps the server within Supabase free tier limits
  • No functional change to tool behavior

🤖 Generated with Claude Code

…ct loop

The Accept: text/event-stream header patch forced StreamableHTTPTransport
into SSE mode on every request. Since Supabase edge functions are stateless,
the SSE stream terminates immediately after each response — causing the MCP
client to reconnect every ~2 seconds (~43k invocations/day).

StreamableHTTPTransport is request/response by design. Removing the patch
lets it respond with plain JSON, eliminating the reconnect loop entirely.
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 1, 2026

Hey @Promithius-DR — welcome to Open Brain Source! 👋

Thanks for submitting your first PR. The automated review will run shortly and check things like metadata, folder structure, and README completeness. If anything needs fixing, the review comment will tell you exactly what.

Once the automated checks pass, a human admin will review for quality and clarity. Expect a response within a few days.

If you have questions, check out CONTRIBUTING.md or open an issue.

@github-actions github-actions bot added the extension Contribution: curated learning path build label Apr 1, 2026
…econnect loop

Removing text/event-stream from the Accept header before it reaches
StreamableHTTPTransport prevents it from opening SSE streams. MCP clients
send Accept: application/json, text/event-stream per spec -- this is what
triggers SSE mode even without the original workaround.

JSON-only responses close cleanly, eliminating the boot/shutdown cycle.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extension Contribution: curated learning path build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant