Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion apps/cloud/src/env-augment.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ declare global {
EXECUTOR_MCP_DEBUG?: string;
MCP_AUTHKIT_DOMAIN?: string;
MCP_RESOURCE_ORIGIN?: string;
MCP_STRICT_AUDIENCE?: string;
NODE_ENV?: string;

// Shared with frontend
Expand Down
26 changes: 4 additions & 22 deletions apps/cloud/src/mcp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import { env } from "cloudflare:workers";
import { HttpApp, HttpServerRequest, HttpServerResponse } from "@effect/platform";
import * as Sentry from "@sentry/cloudflare";
import { Context, Effect, Either, Layer, Option, Schema } from "effect";
import { Context, Effect, Layer, Option, Schema } from "effect";
import { createRemoteJWKSet } from "jose";

import { TelemetryLive } from "./services/telemetry";
Expand Down Expand Up @@ -94,27 +94,9 @@ export class McpAuth extends Context.Tag("@executor/cloud/McpAuth")<
>() {}

const verifyJwt = (token: string) =>
Effect.gen(function* () {
const strictResult = yield* verifyMcpAccessToken(token, jwks, {
issuer: AUTHKIT_DOMAIN,
audience: RESOURCE_URL,
}).pipe(Effect.either);

if (Either.isRight(strictResult)) {
return strictResult.right;
}

if (env.MCP_STRICT_AUDIENCE === "true") {
return yield* Effect.fail(strictResult.left);
}

const verified = yield* verifyMcpAccessToken(token, jwks, {
issuer: AUTHKIT_DOMAIN,
});
yield* Effect.annotateCurrentSpan({
"mcp.auth.audience_fallback": true,
});
return verified;
verifyMcpAccessToken(token, jwks, {
issuer: AUTHKIT_DOMAIN,
audience: RESOURCE_URL,
});

export const McpAuthLive = Layer.succeed(McpAuth, {
Expand Down
Loading