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

Function withJwtVerificationSpan

apps/cloud/src/mcp/jwt.ts:72–97  ·  view source on GitHub ↗
(
  effect: Effect.Effect<A, McpJwtVerificationError>,
)

Source from the content-addressed store, hash-verified

70 error.reason === "expired" || error.reason === "invalid";
71
72const withJwtVerificationSpan = <A>(
73 effect: Effect.Effect<A, McpJwtVerificationError>,
74): Effect.Effect<A, McpJwtVerificationError> =>
75 effect.pipe(
76 Effect.result,
77 Effect.flatMap((outcome) =>
78 Effect.gen(function* () {
79 if (Result.isSuccess(outcome)) {
80 yield* Effect.annotateCurrentSpan({ "mcp.auth.jwt_verify.outcome": "verified" });
81 return outcome;
82 }
83
84 yield* Effect.annotateCurrentSpan({
85 "mcp.auth.jwt_verify.outcome": outcome.failure.reason,
86 });
87
88 return isExpectedJwtVerificationError(outcome.failure)
89 ? outcome
90 : yield* Effect.fail(outcome.failure);
91 }),
92 ),
93 Effect.withSpan("mcp.auth.jwt_verify"),
94 Effect.flatMap((outcome) =>
95 Result.isSuccess(outcome) ? Effect.succeed(outcome.success) : Effect.fail(outcome.failure),
96 ),
97 );
98
99export const verifyMcpAccessToken = (
100 token: string,

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected