Skip to content
Open
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
25 changes: 25 additions & 0 deletions apps/server/src/mcp/McpSessionRegistry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,31 @@ it.effect("stores only a token hash, resolves the bearer token, and revokes by t
}),
);

it.effect("revokes one provider session without revoking another credential for the thread", () =>
Effect.gen(function* () {
const registry = yield* makeRegistry(() => 1_000);
const threadId = ThreadId.make("thread-selective-revocation");
const first = yield* registry.issue({
threadId,
providerInstanceId: ProviderInstanceId.make("codex"),
});
const second = yield* registry.issue({
threadId,
providerInstanceId: ProviderInstanceId.make("claudeAgent"),
});
const firstToken = first.config.authorizationHeader.replace(/^Bearer\s+/, "");
const secondToken = second.config.authorizationHeader.replace(/^Bearer\s+/, "");

yield* registry.revokeProviderSession(second.config.providerSessionId);

expect(yield* registry.resolve(firstToken)).toMatchObject({
threadId,
providerSessionId: first.config.providerSessionId,
});
expect(yield* registry.resolve(secondToken)).toBeUndefined();
}),
);

it.effect("builds MCP endpoints from the bound server host", () =>
Effect.gen(function* () {
const cases = [
Expand Down
12 changes: 12 additions & 0 deletions apps/server/src/mcp/McpSessionRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,18 @@ export const issueActiveMcpCredential = (
.pipe(Effect.andThen(activeMcpSessionRegistry.issue(request)))
: Effect.sync((): McpIssuedCredential | undefined => undefined);

export const issueUncommittedMcpCredential = (
request: McpCredentialRequest,
): Effect.Effect<McpIssuedCredential | undefined> =>
activeMcpSessionRegistry
? activeMcpSessionRegistry.issue(request)
: Effect.sync((): McpIssuedCredential | undefined => undefined);

export const revokeActiveMcpProviderSession = (providerSessionId: string): Effect.Effect<void> =>
activeMcpSessionRegistry
? activeMcpSessionRegistry.revokeProviderSession(providerSessionId)
: Effect.void;
Comment thread
bdsqqq marked this conversation as resolved.
Comment thread
bdsqqq marked this conversation as resolved.

export const revokeActiveMcpThread = (threadId: ThreadId): Effect.Effect<void> =>
activeMcpSessionRegistry ? activeMcpSessionRegistry.revokeThread(threadId) : Effect.void;

Expand Down
Loading