MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / rawSseGet

Function rawSseGet

e2e/cloud/repro-transport-brick.test.ts:86–106  ·  view source on GitHub ↗
(mcpUrl: string, bearer: string, sessionId: string)

Source from the content-addressed store, hash-verified

84/** A raw SSE GET (the "listen" stream) on an existing session id. We only need
85 * the response head — status + start of body — to see whether it 500s. */
86const rawSseGet = async (mcpUrl: string, bearer: string, sessionId: string): Promise<RawResult> => {
87 const res = await fetch(mcpUrl, {
88 method: "GET",
89 headers: {
90 authorization: `Bearer ${bearer}`,
91 accept: "text/event-stream",
92 "mcp-session-id": sessionId,
93 "mcp-protocol-version": "2025-06-18",
94 },
95 });
96 // A 200 opens a long-lived stream; don't hang reading it. A 500 has a short
97 // (usually empty) body we can read fully.
98 let body = "";
99 if (res.status !== 200) {
100 body = await res.text().catch(() => "");
101 } else {
102 // Cancel the stream immediately; we only wanted the status.
103 await res.body?.cancel().catch(() => undefined);
104 }
105 return { status: res.status, body };
106};
107
108const toolsListMessage = { jsonrpc: "2.0" as const, id: "brick-tools-list", method: "tools/list" };
109

Callers 1

Calls 3

cancelMethod · 0.80
textMethod · 0.65
fetchFunction · 0.50

Tested by

no test coverage detected