(lookup: "not-found" | "forbidden", method: string)
| 316 | * reconnect loops whose GET-404 path never re-initialized. |
| 317 | */ |
| 318 | const renderDispatchError = (lookup: "not-found" | "forbidden", method: string): Response => { |
| 319 | if (lookup === "forbidden") { |
| 320 | return jsonRpcResponse(403, -32003, "MCP session does not belong to the current bearer"); |
| 321 | } |
| 322 | if (method === "GET") { |
| 323 | return new Response( |
| 324 | JSON.stringify({ |
| 325 | jsonrpc: "2.0", |
| 326 | error: { code: -32001, message: "Session not found" }, |
| 327 | id: null, |
| 328 | }), |
| 329 | { status: 405, headers: { "content-type": "application/json", allow: "POST, DELETE" } }, |
| 330 | ); |
| 331 | } |
| 332 | return jsonRpcResponse(404, -32001, "Session not found"); |
| 333 | }; |
| 334 | |
| 335 | /** Dispatch an MCP request through authenticate -> store.dispatch -> transport. */ |
| 336 | const mcpDispatch = (resource: McpResource) => |
no test coverage detected