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

Function renderAuthError

apps/host-cloudflare/src/mcp/agent-handler.ts:46–63  ·  view source on GitHub ↗
(
  auth: McpAuthProvider["Service"],
  request: Request,
  outcome: Exclude<AuthOutcome, { readonly _tag: "Authenticated" }>,
)

Source from the content-addressed store, hash-verified

44 : jsonRpcErrorBody(status, code, message, { challenge });
45
46const renderAuthError = (
47 auth: McpAuthProvider["Service"],
48 request: Request,
49 outcome: Exclude<AuthOutcome, { readonly _tag: "Authenticated" }>,
50): Response => {
51 if (Predicate.isTagged(outcome, "Unauthorized")) {
52 return jsonRpcResponse(
53 401,
54 -32001,
55 "Unauthorized",
56 outcome.challenge ?? `Bearer resource_metadata="${auth.resourceMetadataUrl(request)}"`,
57 );
58 }
59 if (Predicate.isTagged(outcome, "Forbidden")) {
60 return jsonRpcResponse(403, outcome.code ?? -32001, outcome.message);
61 }
62 return jsonRpcResponse(503, -32001, outcome.message);
63};
64
65const authenticate = (request: Request, config: CloudflareConfig) =>
66 Effect.gen(function* () {

Callers 1

Calls 1

jsonRpcResponseFunction · 0.70

Tested by

no test coverage detected