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

Function renderAuthError

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

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 1

jsonRpcResponseFunction · 0.70

Tested by

no test coverage detected