Open History to see the last commit
1import {
2 AuthAccessWriteScope,
3 type AuthMcpApprovalDecision,
4 type AuthMcpAuthorizationRequest,
5 type AuthMcpAuthorizationServerMetadata,
6 type AuthMcpClientRegistration,
7 type AuthMcpProtectedResourceMetadata,
8 AuthMcpRegistrationError,
9 AuthMcpTokenError,
10 type AuthMcpTokenRequest,
11 type AuthMcpTokenResult,
12 type AuthMcpClientAccess,
13 type AuthEnvironmentScope,
14 AuthOrchestrationOperateScope,
15 AuthOrchestrationReadScope,
16 MCP_PEER_LINK_SOFTWARE_ID,
17 mcpClientScopes,
18 type RuntimeMode,
19} from "@t3tools/contracts";
20import { DEFAULT_HOSTED_APP_URL } from "@t3tools/shared/connectAuth";
21import { encodeOAuthScope } from "@t3tools/shared/oauthScope";
22import * as Clock from "effect/Clock";
23import * as Context from "effect/Context";
24import * as Digest from "effect/crypto/Digest";
25import * as SecureRandom from "effect/crypto/SecureRandom";
26import * as Effect from "effect/Effect";
27import * as Layer from "effect/Layer";
28import * as Option from "effect/Option";
29import * as Redacted from "effect/Redacted";
30import * as Ref from "effect/Ref";
31import * as Schema from "effect/Schema";
32import { HttpServerRequest } from "effect/http";
33
34import { hostedAppUrlConfig } from "../cloud/publicConfig.ts";
35import * as ServerEnvironment from "../environment/ServerEnvironment.ts";
36import * as ServerSettings from "../serverSettings.ts";
37import * as McpHttpServer from "../mcp/McpHttpServer.ts";
38import type * as McpInvocationContext from "../mcp/McpInvocationContext.ts";
39import * as PayloadSigner from "./PayloadSigner.ts";
40import * as EnvironmentAuth from "./EnvironmentAuth.ts";
41import * as ServerSecretStore from "./ServerSecretStore.ts";
42import {
43 base64UrlDecodeUtf8,
44 base64UrlEncode,
45 deriveAuthClientMetadata,
46 timingSafeEqualBase64Url,
47} from "./utils.ts";
48import { requestUrl } from "../requestUrl.ts";
49
50// Request-derived origins support loopback, Tailscale and tunnels.
51// Signed client metadata keeps unauthenticated registration stateless.
52
53const SIGNING_SECRET_NAME = "mcp-oauth-signing-key";
54const AUTHORIZATION_CODE_TTL_MS = 60_000;
55const MAX_CLIENT_NAME_LENGTH = 100;
56const MAX_REDIRECT_URIS = 5;
57const MAX_REDIRECT_URI_LENGTH = 512;
58const DEFAULT_CLIENT_NAME = "MCP client";
59const LOOPBACK_HOSTNAMES = new Set(["localhost", "127.0.0.1", "[::1]"]);
60const CODE_CHALLENGE_PATTERN = /^[A-Za-z0-9_-]{43}$/;
61const CODE_VERIFIER_PATTERN = /^[A-Za-z0-9\-._~]{43,128}$/;
62
63const MCP_OAUTH_SCOPES = [AuthOrchestrationReadScope, AuthOrchestrationOperateScope];
64
65export interface McpOAuthUrls {
66 readonly issuer: string;
67 readonly resource: string;
68}
69
70export const requestUrls = (request: HttpServerRequest.HttpServerRequest): McpOAuthUrls => {
71 const origin = Option.match(requestUrl(request), {
72 onNone: () => "http://localhost",
73 onSome: (url) => url.origin,
74 });
75 return { issuer: origin, resource: `${origin}/mcp` };
76};
77
78export const protectedResourceMetadata = (
79 urls: McpOAuthUrls,
80): AuthMcpProtectedResourceMetadata => ({
81 resource: urls.resource,
82 authorization_servers: [urls.issuer],
83 scopes_supported: MCP_OAUTH_SCOPES,
84 bearer_methods_supported: ["header"],
85 resource_name: "T3 Code",
86});
87
88export const authorizationServerMetadata = (
89 urls: McpOAuthUrls,
90): AuthMcpAuthorizationServerMetadata => ({
91 issuer: urls.issuer,
92 authorization_endpoint: `${urls.issuer}/oauth/mcp/authorize`,
93 token_endpoint: `${urls.issuer}/oauth/mcp/token`,
94 registration_endpoint: `${urls.issuer}/oauth/mcp/register`,
95 response_types_supported: ["code"],
96 grant_types_supported: ["authorization_code"],
97 code_challenge_methods_supported: ["S256"],
98 token_endpoint_auth_methods_supported: ["none"],
99 scopes_supported: MCP_OAUTH_SCOPES,
100 authorization_response_iss_parameter_supported: true,
101});
102
103const parseRedirect = (value: string): URL | undefined => {
104 // URL.hash misses empty fragments, which RFC 6749 §3.1.2 also forbids.
105 if (value.length > MAX_REDIRECT_URI_LENGTH || value.includes("#")) return undefined;
106 try {
107 const url = new URL(value);
108 const allowed =
109 url.protocol === "https:" ||
110 (url.protocol === "http:" && LOOPBACK_HOSTNAMES.has(url.hostname));
111 return allowed && url.username === "" && url.password === "" ? url : undefined;
112 } catch {
113 return undefined;
114 }
115};
116
117/** Loopback redirects ignore port (RFC 8252 §7.3); HTTPS redirects match exactly. */
118export const redirectMatches = (registered: string, presented: string): boolean => {
119 const left = parseRedirect(registered);
120 const right = parseRedirect(presented);
121 if (left === undefined || right === undefined) return false;
122 if (left.protocol === "https:" || right.protocol === "https:") return left.href === right.href;
123 return (
124 left.hostname === right.hostname &&
125 left.pathname === right.pathname &&
126 left.search === right.search
127 );
128};
129
130const sameResource = (urls: McpOAuthUrls, presented: string | undefined): boolean => {
131 if (presented === undefined) return true;
132 try {
133 const url = new URL(presented);
134 return url.hash === "" && `${url.origin}${url.pathname.replace(/\/+$/u, "")}` === urls.resource;
135 } catch {
136 return false;
137 }
138};
139
140const ClientIdPayload = Schema.Struct({
141 v: Schema.Literal(1),
142 n: Schema.String,
143 r: Schema.Array(Schema.String),
144 /** Registered as another T3 Code environment's peer link. */
145 p: Schema.optionalKey(Schema.Literal(1)),
146});
147const decodeClientIdPayload = Schema.decodeUnknownOption(Schema.fromJsonString(ClientIdPayload));
148
149export interface McpOAuthClient {
150 readonly clientId: string;
151 readonly name: string;
152 readonly redirectUris: ReadonlyArray<string>;
153 readonly peerLink: boolean;
154}
155
156export class McpOAuthPageError extends Schema.TaggedError<McpOAuthPageError>()(
157 "McpOAuthPageError",
158 { description: Schema.String },
159) {
160 override get message(): string {
161 return this.description;
162 }
163}
164
165export class McpOAuthRedirectError extends Schema.TaggedError<McpOAuthRedirectError>()(
166 "McpOAuthRedirectError",
167 {
168 error: Schema.Literals(["invalid_request", "unsupported_response_type", "invalid_target"]),
169 description: Schema.String,
170 redirectUri: Schema.String,
171 state: Schema.optional(Schema.RedactedFromValue(Schema.String)),
172 },
173) {}
174
175export interface AuthorizationRequest {
176 readonly client: McpOAuthClient;
177 readonly redirectUri: string;
178 readonly codeChallenge: string;
179 readonly state: Redacted.Redacted<string> | undefined;
180 readonly resource: string;
181 readonly issuer: string;
182}
183
184interface PendingCode {
185 readonly clientId: string;
186 readonly clientName: string;
187 readonly peerLink: boolean;
188 readonly redirectUri: string;
189 readonly codeChallenge: string;
190 readonly resource: string;
191 readonly access: AuthMcpClientAccess;
192 readonly expiresAtMs: number;
193}
194
195export type ApprovalDecision = Exclude<AuthMcpApprovalDecision, { readonly _tag: "deny" }>;
196
197export class McpOAuth extends Context.Service<
198 McpOAuth,
199 {
200 readonly register: (
201 input: AuthMcpClientRegistration,
202 ) => Effect.Effect<McpOAuthClient, AuthMcpRegistrationError>;
203 /** Page errors must never redirect. */
204 readonly validateAuthorization: (input: {
205 readonly urls: McpOAuthUrls;
206 readonly request: AuthMcpAuthorizationRequest;
207 }) => Effect.Effect<AuthorizationRequest, McpOAuthPageError | McpOAuthRedirectError>;
208 readonly approvingBrowserSession: (
209 request: HttpServerRequest.HttpServerRequest,
210 authorization: AuthorizationRequest,
211 ) => Effect.Effect<
212 | { readonly csrfToken: string; readonly scopes: ReadonlyArray<AuthEnvironmentScope> }
213 | undefined
214 >;
215 readonly approve: (input: {
216 readonly request: HttpServerRequest.HttpServerRequest;
217 readonly authorization: AuthorizationRequest;
218 readonly decision: ApprovalDecision;
219 }) => Effect.Effect<string, EnvironmentAuth.ServerAuthMcpApprovalCodeError | McpOAuthPageError>;
220 readonly deny: (authorization: AuthorizationRequest) => string;
221 /** A managed policy's runtime-mode ceiling, shown on the approval page. */
222 readonly runtimeModeCeiling:
223 | { readonly organization: string; readonly maxRuntimeMode: RuntimeMode }
224 | undefined;
225 readonly exchangeCode: (input: {
226 readonly request: HttpServerRequest.HttpServerRequest;
227 readonly urls: McpOAuthUrls;
228 readonly token: AuthMcpTokenRequest;
229 }) => Effect.Effect<AuthMcpTokenResult, AuthMcpTokenError>;
230 }
231>()("t3/auth/McpOAuth") {}
232
233const redirectWith = (
234 redirectUri: string,
235 params: Record<string, string | Redacted.Redacted<string> | undefined>,
236) => {
237 const url = new URL(redirectUri);
238 for (const [name, value] of Object.entries(params)) {
239 if (value !== undefined) {
240 url.searchParams.set(name, Redacted.isRedacted(value) ? Redacted.value(value) : value);
241 }
242 }
243 return url.toString();
244};
245
246export const redirectForError = (error: McpOAuthRedirectError, issuer: string) =>
247 redirectWith(error.redirectUri, {
248 error: error.error,
249 error_description: error.description,
250 state: error.state,
251 iss: issuer,
252 });
253
254const make = Effect.gen(function* () {
255 const environmentAuth = yield* EnvironmentAuth.EnvironmentAuth;
256 const secretStore = yield* ServerSecretStore.ServerSecretStore;
257 const random = yield* SecureRandom.SecureRandom;
258 const digester = yield* Digest.Digest;
259 const serverSettings = yield* ServerSettings.ServerSettingsService;
260 const linksEnabled = serverSettings.getSettings.pipe(
261 Effect.map((settings) => settings.linkedEnvironmentsEnabled),
262 Effect.orElseSucceed(() => false),
263 );
264 const signer = yield* PayloadSigner.fromSecret(
265 yield* secretStore.getOrCreateRandom(SIGNING_SECRET_NAME, 32).pipe(Effect.orDie),
266 );
267 const codes = yield* Ref.make<ReadonlyMap<string, PendingCode>>(new Map());
268
269 const sign = (domain: string, payload: string) => signer.sign(`${domain}.${payload}`);
270
271 const signClientId = (name: string, redirectUris: ReadonlyArray<string>, peerLink: boolean) => {
272 const body = base64UrlEncode(
273 JSON.stringify({ v: 1, n: name, r: redirectUris, ...(peerLink ? { p: 1 } : {}) }),
274 );
275 return sign("mcp-client-id", body).pipe(Effect.map((signature) => `${body}.${signature}`));
276 };
277
278 // Untraced: only called inside the traced McpOAuth methods below.
279 const parseClientId = Effect.fnUntraced(function* (
280 clientId: string,
281 ): Effect.fn.Return<McpOAuthClient | undefined> {
282 const [body, signature, extra] = clientId.split(".");
283 if (!body || !signature || extra !== undefined) return undefined;
284 const verified = yield* signer.verify(`mcp-client-id.${body}`, signature);
285 if (!verified) return undefined;
286 const json = yield* Effect.try(() => base64UrlDecodeUtf8(body)).pipe(Effect.option);
287 if (Option.isNone(json)) return undefined;
288 return Option.getOrUndefined(
289 decodeClientIdPayload(json.value).pipe(
290 Option.map((payload) => ({
291 clientId,
292 name: payload.n,
293 redirectUris: payload.r,
294 peerLink: payload.p === 1,
295 })),
296 ),
297 );
298 });
299
300 const pkceVerifies = (verifier: string, challenge: string) =>
301 CODE_VERIFIER_PATTERN.test(verifier)
302 ? digester.digest(Digest.sha256, new TextEncoder().encode(verifier)).pipe(
303 Effect.orDie,
304 Effect.map((digest) => timingSafeEqualBase64Url(base64UrlEncode(digest), challenge)),
305 )
306 : Effect.succeed(false);
307
308 const csrfToken = (sessionId: string, authorization: AuthorizationRequest) =>
309 sign(
310 "mcp-csrf",
311 JSON.stringify([
312 sessionId,
313 authorization.client.clientId,
314 authorization.redirectUri,
315 authorization.codeChallenge,
316 ]),
317 );
318
319 const register: McpOAuth["Service"]["register"] = Effect.fn("McpOAuth.register")(
320 function* (metadata) {
321 const rawName = metadata.client_name?.trim() ?? "";
322 const name = (rawName.length > 0 ? rawName : DEFAULT_CLIENT_NAME).slice(
323 0,
324 MAX_CLIENT_NAME_LENGTH,
325 );
326 const redirectUris = metadata.redirect_uris ?? [];
327 if (redirectUris.length === 0 || redirectUris.length > MAX_REDIRECT_URIS) {
328 return yield* new AuthMcpRegistrationError({
329 error: "invalid_redirect_uri",
330 error_description: `Register between 1 and ${MAX_REDIRECT_URIS} redirect URIs.`,
331 });
332 }
333 if (!redirectUris.every((uri) => parseRedirect(uri) !== undefined)) {
334 return yield* new AuthMcpRegistrationError({
335 error: "invalid_redirect_uri",
336 error_description:
337 "Redirect URIs must be https, or http on localhost, 127.0.0.1 or [::1].",
338 });
339 }
340 // RFC 7591 allows ignoring unsupported registration options; all clients use public PKCE.
341 const peerLink = metadata.software_id === MCP_PEER_LINK_SOFTWARE_ID;
342 if (peerLink && !(yield* linksEnabled)) {
343 return yield* new AuthMcpRegistrationError({
344 error: "invalid_client_metadata",
345 error_description:
346 "Linked environments is off on that machine. Turn it on in its Settings → Labs.",
347 });
348 }
349 return {
350 clientId: yield* signClientId(name, redirectUris, peerLink),
351 name,
352 redirectUris,
353 peerLink,
354 };
355 },
356 );
357
358 const validateAuthorization: McpOAuth["Service"]["validateAuthorization"] = Effect.fn(
359 "McpOAuth.validateAuthorization",
360 )(function* ({ urls, request }) {
361 const client = yield* parseClientId(request.client_id ?? "");
362 if (client === undefined) {
363 return yield* new McpOAuthPageError({
364 description: "This sign-in link names an unknown app. Start the sign-in again from it.",
365 });
366 }
367 const redirectUri = request.redirect_uri;
368 if (
369 redirectUri === undefined ||
370 !client.redirectUris.some((registered) => redirectMatches(registered, redirectUri))
371 ) {
372 return yield* new McpOAuthPageError({
373 description: "This sign-in link sends you to an address the app did not register.",
374 });
375 }
376 const state = request.state;
377 const fail = (error: McpOAuthRedirectError["error"], description: string) =>
378 new McpOAuthRedirectError({
379 error,
380 description,
381 redirectUri,
382 ...(state === undefined ? {} : { state }),
383 });
384 if (request.response_type !== "code") {
385 return yield* fail("unsupported_response_type", "Only response_type=code is supported.");
386 }
387 const codeChallenge = request.code_challenge;
388 if (
389 request.code_challenge_method !== "S256" ||
390 codeChallenge === undefined ||
391 !CODE_CHALLENGE_PATTERN.test(codeChallenge)
392 ) {
393 return yield* fail("invalid_request", "PKCE with code_challenge_method=S256 is required.");
394 }
395 if (!sameResource(urls, request.resource)) {
396 return yield* fail("invalid_target", `This server only issues tokens for ${urls.resource}.`);
397 }
398 return {
399 client,
400 redirectUri,
401 codeChallenge,
402 state,
403 resource: urls.resource,
404 issuer: urls.issuer,
405 } satisfies AuthorizationRequest;
406 });
407
408 const approvingBrowserSession: McpOAuth["Service"]["approvingBrowserSession"] = (
409 request,
410 authorization,
411 ) =>
412 environmentAuth.authenticateBrowserSession(request).pipe(
413 Effect.flatMap((session) =>
414 // Approving manages access, and a session may only hand out scopes it holds.
415 session.scopes.includes(AuthAccessWriteScope) &&
416 session.scopes.includes(AuthOrchestrationReadScope)
417 ? csrfToken(session.sessionId, authorization).pipe(
418 Effect.map((token) => ({ csrfToken: token, scopes: session.scopes })),
419 )
420 : Effect.undefined,
421 ),
422 Effect.orElseSucceed(() => undefined),
423 );
424
425 const mintCode = Effect.fn("McpOAuth.mintCode")(function* (
426 authorization: AuthorizationRequest,
427 access: AuthMcpClientAccess,
428 ) {
429 const now = yield* Clock.currentTimeMillis;
430 const code = Buffer.from(yield* random.randomBytes(32)).toString("base64url");
431 yield* Ref.update(codes, (current) => {
432 const next = new Map(Array.from(current).filter(([, pending]) => pending.expiresAtMs > now));
433 next.set(code, {
434 clientId: authorization.client.clientId,
435 clientName: authorization.client.name,
436 peerLink: authorization.client.peerLink,
437 redirectUri: authorization.redirectUri,
438 codeChallenge: authorization.codeChallenge,
439 resource: authorization.resource,
440 access,
441 expiresAtMs: now + AUTHORIZATION_CODE_TTL_MS,
442 });
443 return next;
444 });
445 return code;
446 });
447
448 const approve: McpOAuth["Service"]["approve"] = Effect.fn("McpOAuth.approve")(function* (input) {
449 const { decision } = input;
450 if (decision._tag === "pairing-code") {
451 yield* environmentAuth.consumeMcpApprovalCode(decision.code, decision.access).pipe(
452 Effect.catchIf(EnvironmentAuth.isServerAuthInternalError, (cause) =>
453 Effect.logError("MCP approval code check failed.", { cause }).pipe(
454 Effect.andThen(
455 Effect.fail(
456 new McpOAuthPageError({
457 description: "The code could not be checked. Try again.",
458 }),
459 ),
460 ),
461 ),
462 ),
463 );
464 } else {
465 const session = yield* approvingBrowserSession(input.request, input.authorization);
466 if (
467 session === undefined ||
468 !timingSafeEqualBase64Url(decision.csrfToken, session.csrfToken) ||
469 !mcpClientScopes(decision.access).every((scope) => session.scopes.includes(scope))
470 ) {
471 return yield* new McpOAuthPageError({
472 description: "Your session cannot approve this request. Enter a pairing code instead.",
473 });
474 }
475 }
476 const code = yield* mintCode(input.authorization, decision.access);
477 yield* Effect.logInfo("Approved an MCP client sign-in.", {
478 client: input.authorization.client.name,
479 access: decision.access,
480 method: decision._tag,
481 });
482 return redirectWith(input.authorization.redirectUri, {
483 code,
484 state: input.authorization.state,
485 iss: input.authorization.issuer,
486 });
487 });
488
489 const deny: McpOAuth["Service"]["deny"] = (authorization) =>
490 redirectWith(authorization.redirectUri, {
491 error: "access_denied",
492 state: authorization.state,
493 iss: authorization.issuer,
494 });
495
496 const exchangeCode: McpOAuth["Service"]["exchangeCode"] = Effect.fn("McpOAuth.exchangeCode")(
497 function* ({ request, urls, token }) {
498 const fail = (error: AuthMcpTokenError["error"], description: string) =>
499 new AuthMcpTokenError({ error, error_description: description });
500 if (token.grant_type !== "authorization_code") {
501 return yield* fail("unsupported_grant_type", "Only authorization_code is supported.");
502 }
503 const { redirect_uri: redirectUri, client_id: clientId } = token;
504 const code = token.code && Redacted.value(token.code);
505 const verifier = token.code_verifier && Redacted.value(token.code_verifier);
506 if (!code || !redirectUri || !clientId || !verifier) {
507 return yield* fail(
508 "invalid_request",
509 "code, redirect_uri, client_id and code_verifier are required.",
510 );
511 }
512 if ((yield* parseClientId(clientId)) === undefined) {
513 return yield* fail("invalid_client", "The client is unknown.");
514 }
515 // A presented code is spent even when a later check fails (RFC 6749 §4.1.2).
516 const pending = yield* Ref.modify(codes, (current) => {
517 const found = current.get(code);
518 if (found === undefined) return [undefined, current] as const;
519 const next = new Map(current);
520 next.delete(code);
521 return [found, next] as const;
522 });
523 const now = yield* Clock.currentTimeMillis;
524 if (
525 pending === undefined ||
526 pending.expiresAtMs <= now ||
527 pending.clientId !== clientId ||
528 pending.redirectUri !== redirectUri ||
529 pending.resource !== urls.resource ||
530 !sameResource(urls, token.resource) ||
531 !(yield* pkceVerifies(verifier, pending.codeChallenge))
532 ) {
533 return yield* fail("invalid_grant", "The authorization code is invalid or expired.");
534 }
535 const issued = yield* environmentAuth
536 .issueMcpClientSession({
537 label: pending.clientName,
538 access: pending.access,
539 peerLink: pending.peerLink,
540 client: deriveAuthClientMetadata({ request }),
541 })
542 .pipe(
543 Effect.catch((cause) =>
544 Effect.logError("Could not issue an MCP client session.", { cause }).pipe(
545 Effect.andThen(
546 Effect.fail(fail("invalid_grant", "The session could not be issued.")),
547 ),
548 ),
549 ),
550 );
551 return {
552 access_token: issued.token,
553 token_type: "Bearer",
554 expires_in: Math.max(0, Math.floor((issued.expiresAt.epochMilliseconds - now) / 1000)),
555 scope: encodeOAuthScope(mcpClientScopes(pending.access)),
556 };
557 },
558 );
559
560 const managedPolicy = serverSettings.managedPolicy;
561 const maxRuntimeMode = managedPolicy?.limits?.maxRuntimeMode;
562 return McpOAuth.of({
563 runtimeModeCeiling:
564 managedPolicy === undefined || maxRuntimeMode === undefined
565 ? undefined
566 : { organization: managedPolicy.organization, maxRuntimeMode },
567 register,
568 validateAuthorization,
569 approvingBrowserSession,
570 approve,
571 deny,
572 exchangeCode,
573 });
574});
575
576export const layer = Layer.effect(McpOAuth, make);
577
578export const layerMcpClientAuthenticator = Layer.effect(
579 McpHttpServer.McpClientAuthenticator,
580 Effect.gen(function* () {
581 const environmentAuth = yield* EnvironmentAuth.EnvironmentAuth;
582 const environment = yield* ServerEnvironment.ServerEnvironment;
583 const environmentId = yield* environment.getEnvironmentId;
584 const hostedAppUrl = yield* hostedAppUrlConfig.pipe(
585 Effect.catch((cause) =>
586 Effect.logWarning("Outside MCP clients get app.t3.codes thread links", { cause }).pipe(
587 Effect.as(DEFAULT_HOSTED_APP_URL),
588 ),
589 ),
590 );
591 return McpHttpServer.McpClientAuthenticator.of({
592 authenticate: Effect.fn("McpHttpServer.McpClientAuthenticator.authenticate")(
593 function (request) {
594 return environmentAuth.authenticateMcpClient(request).pipe(
595 Effect.flatMap((client) =>
596 Clock.currentTimeMillis.pipe(
597 Effect.map((issuedAt): McpInvocationContext.McpInvocationScope => ({
598 environmentId,
599 requestNamespace: `client:${client.sessionId}`,
600 thread: undefined,
601 client: {
602 sessionId: client.sessionId,
603 label: client.label,
604 access: client.access,
605 linked: client.peerLink,
606 ...(client.peerLink ? {} : { hostedAppUrl }),
607 },
608 capabilities: new Set<McpInvocationContext.McpCapability>([
609 "orchestration",
610 "worktree",
611 "pull-requests",
612 ]),
613 issuedAt,
614 })),
615 ),
616 ),
617 Effect.catch((error) =>
618 (EnvironmentAuth.isServerAuthCredentialError(error)
619 ? Effect.void
620 : Effect.logWarning("MCP client authentication failed.", { cause: error })
621 ).pipe(Effect.as(undefined)),
622 ),
623 );
624 },
625 ),
626 });
627 }),
628);