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

Function renderAuthError

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

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 1

jsonRpcResponseFunction · 0.70

Tested by

no test coverage detected