Skip to content

Commit 5f96fcd

Browse files
fix(server): full-access MCP clients need settings and source-control scopes to approve
A full-access MCP client can change environment preferences and clone repositories, but approving one only required orchestration:read and orchestration:operate. A pairing code or browser session narrowed to thread control could therefore approve a client that changes settings it cannot change itself. Full-access MCP grants now hold settings:write and source-control:write, so the existing approval checks (pairing code, one-click browser session, and the approval page's one-click list) require the approver to hold them too. Limited access levels are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent f533e00 commit 5f96fcd

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

‎apps/server/src/auth/EnvironmentAuth.ts‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import {
44
AuthAdministrativeScopes,
55
AuthOrchestrationOperateScope,
66
AuthOrchestrationReadScope,
7+
AuthSettingsWriteScope,
8+
AuthSourceControlWriteScope,
79
AuthStandardClientScopes,
810
type AuthAccessTokenResult,
911
type AuthBrowserSessionResult,
@@ -74,7 +76,10 @@ export interface IssuedBearerSession {
7476
* token cannot reach the full RPC surface around that cap.
7577
*
7678
* A read-only grant holds `orchestration:read` alone. Any other grant also
77-
* holds `orchestration:operate` and carries its runtime-mode ceiling.
79+
* holds `orchestration:operate` and carries its runtime-mode ceiling. A
80+
* full-access client may also change environment preferences and clone
81+
* repositories, so it holds the scopes those need over RPC. Approving a grant
82+
* requires every scope it holds.
7883
*/
7984
const MCP_CLIENT_SUBJECT = "mcp-client";
8085
const MCP_CLIENT_SESSION_TTL = Duration.days(30);
@@ -84,7 +89,14 @@ export const mcpClientScopes = (
8489
): ReadonlyArray<AuthEnvironmentScope> =>
8590
access === "read-only"
8691
? [AuthOrchestrationReadScope]
87-
: [AuthOrchestrationReadScope, AuthOrchestrationOperateScope];
92+
: access === "full-access"
93+
? [
94+
AuthOrchestrationReadScope,
95+
AuthOrchestrationOperateScope,
96+
AuthSettingsWriteScope,
97+
AuthSourceControlWriteScope,
98+
]
99+
: [AuthOrchestrationReadScope, AuthOrchestrationOperateScope];
88100

89101
export interface McpClientSession {
90102
readonly sessionId: AuthSessionId;

‎apps/server/src/auth/McpOAuth.test.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,15 @@ it.live(
451451
const readOnlyResponse = yield* approveWith(readOnly.credential);
452452
expect(readOnlyResponse.status).toBe(400);
453453
expect(readOnlyResponse.message).toContain("cannot grant this access");
454+
const operator = yield* auth.issuePairingCredential({
455+
scopes: ["orchestration:read", "orchestration:operate"],
456+
});
457+
const operatorFull = yield* decide(handler, params, {
458+
_tag: "pairing-code",
459+
access: "full-access",
460+
code: operator.credential,
461+
});
462+
expect(operatorFull.status).toBe(400);
454463

455464
// A read-only code can approve read-only access.
456465
const readOnlyCode = yield* auth.issuePairingCredential({ scopes: ["orchestration:read"] });

0 commit comments

Comments
 (0)