(
auth: McpAuthProvider["Service"],
request: Request,
outcome: Exclude<AuthOutcome, { readonly _tag: "Authenticated" }>,
)
| 49 | : jsonRpcErrorBody(status, code, message, { challenge }); |
| 50 | |
| 51 | const renderAuthError = ( |
| 52 | auth: McpAuthProvider["Service"], |
| 53 | request: Request, |
| 54 | outcome: Exclude<AuthOutcome, { readonly _tag: "Authenticated" }>, |
| 55 | ): Response => { |
| 56 | if (Predicate.isTagged(outcome, "Unauthorized")) { |
| 57 | return jsonRpcResponse( |
| 58 | 401, |
| 59 | -32001, |
| 60 | "Unauthorized", |
| 61 | outcome.challenge ?? `Bearer resource_metadata="${auth.resourceMetadataUrl(request)}"`, |
| 62 | ); |
| 63 | } |
| 64 | if (Predicate.isTagged(outcome, "Forbidden")) { |
| 65 | return jsonRpcResponse(403, outcome.code ?? -32001, outcome.message); |
| 66 | } |
| 67 | return jsonRpcResponse(503, -32001, outcome.message); |
| 68 | }; |
| 69 | |
| 70 | const sessionStub = (env: Env, sessionId: string): McpAgentSessionStub => |
| 71 | // oxlint-disable-next-line executor/no-double-cast -- boundary: Workers types expose only DurableObjectStub, but RPC methods are generated from the bound DO class. |
no test coverage detected