(lookup: "not-found" | "forbidden", method: string)
| 214 | * reconnect loops whose GET-404 path never re-initialized. |
| 215 | */ |
| 216 | const renderDispatchError = (lookup: "not-found" | "forbidden", method: string): Response => { |
| 217 | if (lookup === "forbidden") { |
| 218 | return jsonRpcResponse(403, -32003, "MCP session does not belong to the current bearer"); |
| 219 | } |
| 220 | if (method === "GET") { |
| 221 | return new Response( |
| 222 | JSON.stringify({ |
| 223 | jsonrpc: "2.0", |
| 224 | error: { code: -32001, message: "Session not found" }, |
| 225 | id: null, |
| 226 | }), |
| 227 | { status: 405, headers: { "content-type": "application/json", allow: "POST, DELETE" } }, |
| 228 | ); |
| 229 | } |
| 230 | return jsonRpcResponse(404, -32001, "Session not found"); |
| 231 | }; |
| 232 | |
| 233 | /** Dispatch an MCP request through authenticate -> store.dispatch -> transport. */ |
| 234 | const mcpDispatch = (resource: McpResource) => |
no test coverage detected