The best way to control Claude Code, Codex and more from any computer or phone
fix(server): t3_project_create names the link that refuses it and rejects a model default it would drop (#30471)
Julius Marminge committed
Nov 19, 2026 at 12:16 UTC
d6b5aac30a5444936dc66f35a8f1cb6cde1d6895
5 files changed
+71
-6
apps/server/src/mcp/McpToolAccess.ts
+11
-3
@@ -23,7 +23,12 @@ import {
23
type DispatchModeRefusal,
24
} from "../orchestration-v2/DispatchModeLimit.ts";
25
import * as PeerForwarding from "../peer/PeerForwarding.ts";
26
-import { assertNotLinked, assertSameLink, callerLinkOrigin } from "./linkOrigin.ts";
26
+import {
27
+ assertFullAccessNamingLink,
28
+ assertNotLinked,
29
+ assertSameLink,
30
+ callerLinkOrigin,
31
+} from "./linkOrigin.ts";
32
import * as McpInvocationContext from "./McpInvocationContext.ts";
33
import { resolveInteractionMode, resolveRuntimeMode } from "./delegatedTaskModes.ts";
34
import {
@@ -320,6 +325,7 @@ export const afterForwarding = <P, A, E, R, E2, R2>(
325
326
const fullAccessRequired =
327
"Changing projects or environment settings needs a live full-access/default calling thread or a full-access client.";
328
+const changesEnvironment = "change projects or environment settings";
329
330
/** Recheck after waits before writing; caller modes may have changed. */
331
export const writesEnvironment = <P, A, E, R>(
@@ -339,9 +345,11 @@ export const writesEnvironment = <P, A, E, R>(
345
Effect.tap((caller) =>
346
options?.linkedCallers === "allowed"
347
? Effect.void
342
- : assertNotLinked(caller, "change projects or environment settings"),
348
+ : assertNotLinked(caller, changesEnvironment),
349
+ ),
350
+ Effect.tap((caller) =>
351
+ assertFullAccessNamingLink(caller, fullAccessRequired, changesEnvironment),
352
),
344
- Effect.tap((caller) => assertFullAccess(caller, fullAccessRequired)),
353
);
354
return declare(
355
(params: P) => check.pipe(Effect.flatMap(() => handle(params, check))),
apps/server/src/mcp/linkOrigin.ts
+19
-2
@@ -6,7 +6,7 @@ import {
6
} from "@t3tools/contracts";
7
import * as Effect from "effect/Effect";
8
9
-import type { Caller } from "./threadAccess.ts";
9
+import { assertFullAccess, type Caller } from "./threadAccess.ts";
10
11
/**
12
* Below full access, work a link starts here (all of it carries that session in `linkOrigin`)
@@ -34,10 +34,13 @@ export const fencingLinkOrigin = (caller: Pick<Caller, "scope" | "caller">) => {
34
return origin !== undefined && linkOriginIsFenced(origin) ? origin : undefined;
35
};
36
37
+const outsideLinkMessage = (origin: OrchestrationV2LinkOrigin, message: string) =>
38
+ `This work was started from ${origin.label} through a linked environment, so ${message} A link paired with full access is not limited this way.`;
39
+
40
const outsideLink = (origin: OrchestrationV2LinkOrigin, message: string) =>
41
new OrchestratorMcpFailure({
42
code: "capability_denied",
40
- message: `This work was started from ${origin.label} through a linked environment, so ${message} A link paired with full access is not limited this way.`,
43
+ message: outsideLinkMessage(origin, message),
44
});
45
46
/** A thread a fenced caller may change: one its own link started. */
@@ -58,3 +61,17 @@ export const assertNotLinked = (caller: Pick<Caller, "scope" | "caller">, what:
61
? Effect.void
62
: Effect.fail(outsideLink(origin, `it cannot ${what}.`));
63
};
64
+
65
+/** A fenced caller is held below full access by its link, not its thread, so the refusal names the link. */
66
+export const assertFullAccessNamingLink = (caller: Caller, message: string, what: string) => {
67
+ const origin = fencingLinkOrigin(caller);
68
+ return assertFullAccess(
69
+ caller,
70
+ origin === undefined
71
+ ? message
72
+ : outsideLinkMessage(
73
+ origin,
74
+ `it has that link's ${origin.access === undefined ? "" : `${origin.access} `}access, which is below the full access needed to ${what}.`,
75
+ ),
76
+ );
77
+};
apps/server/src/mcp/toolkits/project/handlers.test.ts
+30
@@ -986,6 +986,36 @@ it.effect("a client launches with the fallback for an exhausted default", () =>
986
}),
987
);
988
989
+it.effect("creating a project through MCP refuses a model default instead of dropping it", () =>
990
+ Effect.gen(function* () {
991
+ const harness = clientLaunchHarness({ runtimeModeCeiling: "full-access", launched: [] });
992
+ const dependencies = Layer.merge(
993
+ harness.dependencies,
994
+ Layer.mock(Project.ProjectService)({
995
+ create: () => Effect.die("the project was created without its model default"),
996
+ }),
997
+ );
998
+ const toolkit = yield* ProjectToolkit.pipe(
999
+ Effect.provide(
1000
+ McpToolAccess.HandlersLayer.layer(ProjectHandlers.layer).pipe(Layer.provide(dependencies)),
1001
+ ),
1002
+ );
1003
+
1004
+ const refused = yield* toolkit
1005
+ .handle("t3_project_create", {
1006
+ title: "client-target",
1007
+ workspaceRoot: "/projects/client-target",
1008
+ defaultModelSelection: harness.modelSelection,
1009
+ })
1010
+ .pipe(Stream.unwrap, Stream.runCollect, Effect.provide(dependencies));
1011
+
1012
+ expect(refused.at(-1)?.result).toMatchObject({
1013
+ code: "invalid_request",
1014
+ message: expect.stringContaining("t3_project_update"),
1015
+ });
1016
+ }),
1017
+);
1018
+
1019
it.effect("an agent's clone is not cut off while git is still transferring", () =>
1020
Effect.gen(function* () {
1021
const fs = yield* FileSystem.FileSystem;
apps/server/src/mcp/toolkits/project/handlers.ts
+6
@@ -526,6 +526,12 @@ export const layer = McpToolAccess.toLayer(ProjectToolkit, {
526
...(created.commitError === undefined ? {} : { commitError: created.commitError }),
527
};
528
}
529
+ if (input.defaultModelSelection !== undefined && input.defaultModelSelection !== null)
530
+ return yield* new OrchestratorMcpFailure({
531
+ code: "invalid_request",
532
+ message:
533
+ "Creating a project does not set its default model; set defaultModelSelection afterwards with t3_project_update.",
534
+ });
535
const commandId = yield* newCommandId();
536
return yield* projects
537
.create({ ...input, workspaceRoot, commandId, projectId: ProjectId.make(commandId) })
apps/server/src/peer/PeerForwarding.test.ts
+5
-1
@@ -593,7 +593,11 @@ it.effect("brings a repository to a linked environment, only through full access
593
environmentId: box.environmentId,
594
...args,
595
});
596
- expect(failureOf(refused), name).toMatchObject({ code: "capability_denied" });
596
+ const failure = failureOf(refused);
597
+ expect(failure, name).toMatchObject({ code: "capability_denied" });
598
+ // The agent's thread is full access; what holds it is the link's access.
599
+ expect(failure.message, name).toContain("linked environment");
600
+ expect(failure.message, name).not.toContain("calling thread");
601
}
602
expect((yield* Ref.get(seen)).clones).toHaveLength(1);
603
expect((yield* Ref.get(seen)).projects).toHaveLength(1);