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
20 changes: 20 additions & 0 deletions apps/server/src/auth/McpOAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
AuthOrchestrationOperateScope,
AuthOrchestrationReadScope,
MCP_PEER_LINK_SOFTWARE_ID,
OrchestratorMcpFailure,
mcpClientScopes,
parseMcpApprovalCode,
type RuntimeMode,
Expand Down Expand Up @@ -630,6 +631,25 @@ export const layerMcpClientAuthenticator = Layer.effect(
sessionId: client.sessionId,
label: client.label,
access: client.access,
checkActive: environmentAuth.authenticateMcpClient(request).pipe(
Effect.map(
(current) =>
current.sessionId === client.sessionId &&
current.access === client.access &&
current.peerLink === client.peerLink,
),
Effect.orElseSucceed(() => false),
Effect.flatMap((active) =>
active
? Effect.void
: Effect.fail(
new OrchestratorMcpFailure({
code: "capability_denied",
message: "The MCP client session is no longer authorized.",
}),
),
),
),
linked: client.peerLink,
...(client.peerLink ? {} : { hostedAppUrl }),
},
Expand Down
8 changes: 8 additions & 0 deletions apps/server/src/mcp/McpHttpServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ import { EnvironmentToolkit } from "./toolkits/environment/tools.ts";
import * as EnvironmentHandlers from "./toolkits/environment/handlers.ts";
import { ThemeToolkit } from "./toolkits/theme/tools.ts";
import * as ThemeHandlers from "./toolkits/theme/handlers.ts";
import { AgentSessionsToolkit } from "./toolkits/agentSessions/tools.ts";
import * as AgentSessionsHandlers from "./toolkits/agentSessions/handlers.ts";
import { ProjectToolkit } from "./toolkits/project/tools.ts";
import * as ProjectHandlers from "./toolkits/project/handlers.ts";
import { AttachmentToolkit } from "./toolkits/attachment/tools.ts";
Expand Down Expand Up @@ -1283,6 +1285,11 @@ const layerThemeToolkit = toolkitRegistration(ThemeToolkit, ThemeHandlers.layer)
Layer.provide(ThreadCommandExecutor.layer),
);

const layerAgentSessionsToolkit = toolkitRegistration(
AgentSessionsToolkit,
AgentSessionsHandlers.layer,
);

export const layerProjectRegistration = toolkitRegistration(ProjectToolkit, ProjectHandlers.layer);

export const layerAttachmentToolkit = toolkitRegistration(
Expand Down Expand Up @@ -1349,6 +1356,7 @@ export const layerTools = Layer.mergeAll(
layerThreadToolkit,
layerAttachmentToolkit,
layerProjectRegistration,
layerAgentSessionsToolkit,
layerEnvironmentToolkit,
layerThemeToolkit,
layerPreviewControlsRegistration,
Expand Down
1 change: 1 addition & 0 deletions apps/server/src/mcp/McpInvocationContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export interface McpClientCaller {
readonly sessionId: string;
readonly label: string;
readonly access: AuthMcpClientAccess;
readonly checkActive?: Effect.Effect<void, OrchestratorMcpFailure>;
/**
* Another T3 Code environment's peer link. What it starts here carries its
* session as `linkOrigin`, and it changes only that work (`linkOrigin.ts`).
Expand Down
Loading
Loading