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

Function renderDispatchError

packages/hosts/mcp/src/envelope.ts:248–263  ·  view source on GitHub ↗
(lookup: "not-found" | "forbidden", method: string)

Source from the content-addressed store, hash-verified

246 * reconnect loops whose GET-404 path never re-initialized.
247 */
248const renderDispatchError = (lookup: "not-found" | "forbidden", method: string): Response => {
249 if (lookup === "forbidden") {
250 return jsonRpcResponse(403, -32003, "MCP session does not belong to the current bearer");
251 }
252 if (method === "GET") {
253 return new Response(
254 JSON.stringify({
255 jsonrpc: "2.0",
256 error: { code: -32001, message: "Session not found" },
257 id: null,
258 }),
259 { status: 405, headers: { "content-type": "application/json", allow: "POST, DELETE" } },
260 );
261 }
262 return jsonRpcResponse(404, -32001, "Session not found");
263};
264
265const withModernMcpCors = (response: Response): Response => {
266 const headers = new Headers(response.headers);

Callers 1

mcpDispatchFunction · 0.85

Calls 1

jsonRpcResponseFunction · 0.70

Tested by

no test coverage detected