GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — MCP profile carry: Claude-only docs, no empty name, fail closed, requ… · scuttletoby/t3code@24186d4

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/server/src/fork
    • claudeMcpProfile.test.ts
    • claudeMcpProfile.ts
    • mcpProfile.test.ts
    • mcpProfile.ts
  • docs/fork
    • README.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/server/src/fork/claudeMcpProfile.test.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/fork/claudeMcpProfile.test.ts
+44-2Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ describe("makeClaudeMcpProfiles", () => {
163163
reads: ReadonlyArray<Record<string, unknown> | "fails">,
164164
file: string | undefined | "unreadable" = undefined,
165165
policy?: unknown,
166+
self: LineageThread = thread("t"),
166167
) =>
167168
Effect.gen(function* () {
168169
const { settingsPath } = yield* ServerConfig.ServerConfig;
@@ -184,10 +185,14 @@ describe("makeClaudeMcpProfiles", () => {
184185
const outcomes: Array<string> = [];
185186
for (const _ of reads) {
186187
outcomes.push(
187-
yield* plan(thread("t"), {}).pipe(
188+
yield* plan(self, {}).pipe(
188189
Effect.match({
189190
onFailure: (refusal) => refusal.message,
190-
onSuccess: (result) => result.name,
191+
// A carried profile cuts an `all` thread without renaming it.
192+
onSuccess: (result) =>
193+
result.name === "all" && result.servers !== "all"
194+
? `all cut to ${JSON.stringify(result.servers)}`
195+
: result.name,
191196
}),
192197
),
193198
);
@@ -233,6 +238,43 @@ describe("makeClaudeMcpProfiles", () => {
233238
}),
234239
);
235240

241+
it.effect(
242+
"a failed read with a settings.json that does not decode refuses a narrower carried task (#653)",
243+
() =>
244+
Effect.gen(function* () {
245+
// The file may say mcpCarriedProfiles "refuse", so it is not read as the default apply.
246+
const task: LineageThread = {
247+
...thread("task"),
248+
delegatedFrom: {
249+
environmentId: "environment-there" as never,
250+
threadId: ThreadId.make("thread-there"),
251+
title: "Parent there",
252+
mcpProfile: { name: "t3-only", servers: [], t3Tools: "all" },
253+
},
254+
};
255+
const broken = "{ not json";
256+
const runs = yield* plansFor(["fails", "fails"], broken, undefined, task);
257+
assert.strictEqual(runs.length, 2);
258+
for (const run of runs) assert.include(run, "set to refuse such tasks");
259+
// Settings read in full, a file that decodes, or no file: the default apply cuts it.
260+
const cut = ["all cut to []"];
261+
assert.deepStrictEqual(yield* plansFor([{}], broken, undefined, task), cut);
262+
assert.deepStrictEqual(yield* plansFor(["fails"], "{}", undefined, task), cut);
263+
assert.deepStrictEqual(yield* plansFor(["fails"], undefined, undefined, task), cut);
264+
// A task carrying all cuts nothing, so it is taken; a thread of this machine's own gets
265+
// the defaults, as before.
266+
const all: LineageThread = {
267+
...task,
268+
delegatedFrom: {
269+
...task.delegatedFrom!,
270+
mcpProfile: { name: "all", servers: "all", t3Tools: "all" },
271+
},
272+
};
273+
assert.deepStrictEqual(yield* plansFor(["fails"], broken, undefined, all), ["all"]);
274+
assert.deepStrictEqual(yield* plansFor(["fails"], broken), ["all"]);
275+
}),
276+
);
277+
236278
it.effect("refuses when settings.json cannot be read either, even after a read with none", () =>
237279
Effect.gen(function* () {
238280
const [first, second] = yield* plansFor([{}, "fails"], "unreadable");
Collapse file

‎apps/server/src/fork/claudeMcpProfile.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/fork/claudeMcpProfile.ts
+9-5Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import type {
1212
} from "@anthropic-ai/claude-agent-sdk";
1313
import {
1414
DEFAULT_SERVER_SETTINGS,
15+
MCP_CARRIED_PROFILES_REFUSE,
1516
MCP_PROFILE_ALL,
1617
type OrchestrationV2AppThread,
1718
type ServerSettings,
@@ -312,10 +313,9 @@ const planKey = (plan: ClaudeMcpProfilePlan): string | undefined =>
312313
plan.servers === "all" ? undefined : ["mcp", ...plan.servers].join("\u0000");
313314

314315
/**
315-
* The settings as a load decodes them from settings.json, without reading provider secrets: the
316-
* MCP profile keys hold none. `undefined` when this server has no settings file to read here.
317-
* As the load: no file means the policy's defaults, a file that does not decode loads as them too
318-
* (upstream's rule), and the policy's locks are laid over either. A file that cannot be read fails.
316+
* settings.json as a load decodes it (no provider secrets: MCP keys hold none); `undefined` with no
317+
* file to read here. No file gives the policy's defaults; a file that does not decode gives them
318+
* with `mcpCarriedProfiles` `refuse`, as it may say so. Locks are laid over both; a read error fails.
319319
*/
320320
const settingsFileReader = Effect.gen(function* () {
321321
const config = yield* Effect.serviceOption(ServerConfig.ServerConfig);
@@ -333,7 +333,11 @@ const settingsFileReader = Effect.gen(function* () {
333333
const decoded = ServerSettingsService.decodeSettingsFileText(raw, managed.withDefaults);
334334
const readable =
335335
Exit.isSuccess(decoded) && !ServerSettingsService.settingsFileLegacyKeysUnreadable(raw);
336-
return managed.applyLocks(readable ? decoded.value : managed.defaults);
336+
return managed.applyLocks(
337+
readable
338+
? decoded.value
339+
: { ...managed.defaults, mcpCarriedProfiles: MCP_CARRIED_PROFILES_REFUSE },
340+
);
337341
});
338342
});
339343

Collapse file

‎apps/server/src/fork/mcpProfile.test.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/fork/mcpProfile.test.ts
+43Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { describe, expect, it } from "vite-plus/test";
55
import {
66
MCP_PROFILE_MAX_LINEAGE,
77
type McpProfileResolution,
8+
type McpProfileSettings,
89
type McpProfileThread,
910
isEveryMcpTool,
1011
resolveMcpProfile,
@@ -489,6 +490,48 @@ describe("MCP profile resolver: a machine set to refuse carried profiles (#640)"
489490
}
490491
});
491492

493+
it("names no empty profile in a refusal: it says the profile cannot be read (#653)", () => {
494+
// Not an object, or no name: the carried value has no name to show.
495+
for (const value of [
496+
"t3-only",
497+
7,
498+
null,
499+
{ servers: [], t3Tools: "all" },
500+
carried([], "all", " "),
501+
]) {
502+
for (const file of [REFUSE, {}]) {
503+
const settings = fromFile(file);
504+
const task = refused(resolveMcpProfile(settings, [child("task")], value));
505+
const sub = refused(resolveMcpProfile(settings, [child("sub"), child("task")], value));
506+
for (const message of [task.message, sub.message]) {
507+
expect(message).not.toMatch(/profile\s*"\s*"/);
508+
expect(message).not.toContain('""');
509+
}
510+
expect(sub.message).toContain("The parent thread's MCP profile cannot be applied");
511+
if (file === REFUSE) {
512+
expect(task.message).toContain(
513+
"delegated here with an MCP profile this version cannot read, and",
514+
);
515+
} else {
516+
expect(task.message).toMatch(/^The MCP profile of the thread on another machine/);
517+
}
518+
}
519+
}
520+
// A carried name is still shown.
521+
const named = refused(resolveMcpProfile(fromFile(REFUSE), [child("task")], carried([])));
522+
expect(named.message).toContain('with its MCP profile "remote", and');
523+
});
524+
525+
it("makes every caller say what this machine does with a carried profile (#653)", () => {
526+
const { mcpCarriedProfiles, ...rest } = fromFile(REFUSE);
527+
expect(mcpCarriedProfiles).toBe("refuse");
528+
// Typecheck: settings without the key are not resolver settings, so no caller gets apply by
529+
// leaving it out.
530+
// @ts-expect-error mcpCarriedProfiles is required
531+
const partial: McpProfileSettings = rest;
532+
expect(partial).not.toHaveProperty("mcpCarriedProfiles");
533+
});
534+
492535
it("takes a task that carries all, which cuts nothing, as apply would", () => {
493536
const value = carried("all", "all", "all");
494537
const refuse = resolved(resolveMcpProfile(fromFile(REFUSE), [child("task")], value));
Collapse file

‎apps/server/src/fork/mcpProfile.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/fork/mcpProfile.ts
+14-10Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,13 @@ import {
1717
} from "@t3tools/contracts";
1818

1919
/**
20-
* The settings the resolver reads: the server's MCP profile keys. `mcpCarriedProfiles` absent is
21-
* its default, `apply`.
20+
* The settings the resolver reads: the server's MCP profile keys. Each is required, so a caller
21+
* must say what this machine does with a carried profile rather than get `apply` by leaving it out.
2222
*/
2323
export type McpProfileSettings = Pick<
2424
ServerSettings,
25-
"mcpProfiles" | "mcpProfile" | "mcpSubagentProfile" | "mcpThreadProfiles"
26-
> &
27-
Partial<Pick<ServerSettings, "mcpCarriedProfiles">>;
25+
"mcpProfiles" | "mcpProfile" | "mcpSubagentProfile" | "mcpThreadProfiles" | "mcpCarriedProfiles"
26+
>;
2827

2928
/** One thread of a lineage, as the resolver needs it. */
3029
export interface McpProfileThread {
@@ -351,28 +350,33 @@ const sameList = (a: "all" | ReadonlyArray<string>, b: "all" | ReadonlyArray<str
351350

352351
const FIX = `pick "${MCP_PROFILE_ALL}" for this thread, or fix the profile in Settings`;
353352

353+
/** ` "name"` for a message, or nothing when the name is empty (a carried value it cannot read). */
354+
const quoted = (profileName: string): string =>
355+
profileName.trim() === "" ? "" : ` "${profileName}"`;
356+
354357
function cannotApply(
355358
problem: McpProfileProblem,
356359
thread: McpProfileThread,
357360
profileName: string,
358361
issue: string,
359362
): McpProfileCannotApply {
363+
const name = quoted(profileName);
360364
const message =
361365
problem === "missing"
362-
? `MCP profile "${profileName}" is not set up, so this thread cannot start: ${FIX}.`
366+
? `MCP profile${name} is not set up, so this thread cannot start: ${FIX}.`
363367
: problem === "broken"
364-
? `MCP profile "${profileName}" cannot be read by this version (${issue}), so this thread cannot start: ${
368+
? `MCP profile${name} cannot be read by this version (${issue}), so this thread cannot start: ${
365369
// Only an entry under its name breaks a built-in; picking it again would not help.
366370
isBuiltInMcpProfileName(profileName)
367371
? `remove or rename that entry in the settings file`
368372
: FIX
369373
}.`
370374
: problem === "parent"
371-
? `The parent thread's MCP profile "${profileName}" cannot be applied, so this thread cannot start: ${FIX}.`
375+
? `The parent thread's MCP profile${name} cannot be applied, so this thread cannot start: ${FIX}.`
372376
: problem === "carried"
373-
? `The MCP profile "${profileName}" of the thread on another machine that delegated this one cannot be read by this version (${issue}), so this thread cannot start: update T3 here, or pick a profile for this thread in Settings.`
377+
? `The MCP profile${name} of the thread on another machine that delegated this one cannot be read by this version (${issue}), so this thread cannot start: update T3 here, or pick a profile for this thread in Settings.`
374378
: problem === "carried-refused"
375-
? `This thread is a task another machine delegated here with its MCP profile "${profileName}", and this machine is set to refuse such tasks (mcpCarriedProfiles is "${MCP_CARRIED_PROFILES_REFUSE}"), so it cannot start: delegate the task on that machine, set mcpCarriedProfiles to "apply" here, or pick a profile for this thread in Settings.`
379+
? `This thread is a task another machine delegated here with ${name === "" ? "an MCP profile this version cannot read" : `its MCP profile${name}`}, and this machine is set to refuse such tasks (mcpCarriedProfiles is "${MCP_CARRIED_PROFILES_REFUSE}"), so it cannot start: delegate the task on that machine, set mcpCarriedProfiles to "apply" here, or pick a profile for this thread in Settings.`
376380
: `This thread's parent threads ${issue}, so its MCP profile cannot be worked out: ${FIX}.`;
377381
return { _tag: "CannotApply", problem, profileName, threadId: thread.threadId, message };
378382
}
Collapse file

‎docs/fork/README.md‎

Copy file name to clipboardExpand all lines: docs/fork/README.md
+9-3Lines changed: 9 additions & 3 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -473,13 +473,19 @@ Whether this machine takes tasks that another machine delegated with a profile n
473473
([#640](https://github.com/scuttletoby/t3code/issues/640)). `apply` (the default) cuts such a task
474474
down to the carried profile, as `server.mcpProfiles` says. `refuse` takes no part in carrying: the
475475
features route answers `mcpProfileCarry: false`, so a narrower-profile thread on another machine is
476-
refused before it sends, and a task that arrives with one anyway (sent before the setting changed)
477-
does not start its turn, nor do its sub-agents, and says why. Neither value gives a task more than
476+
refused before it sends. A task that arrives with one anyway (sent before the setting changed), or
477+
with a profile this machine cannot read, does not start its turn on Claude, nor do its sub-agents,
478+
and says why. On Codex or any other provider such a task still runs, with every tool: only Claude
479+
threads apply profiles (see `server.mcpProfiles`). Neither value gives a task more than
478480
it would get: there is no "ignore the carried profile" value, as a thread could then get more tools
479481
by delegating to this machine. A task that carries `all`, or nothing (from an older T3), runs as
480482
before, and the owner's pick for a task here (`mcpThreadProfiles`) still stands. It is read again
481483
for each turn and each ask, so a change counts from the next one. A value it does not know reads as
482-
`apply`. Only the person can change it; agents cannot.
484+
`apply`. When a Claude turn cannot read the settings in full and falls back to `settings.json`
485+
alone, and that file does not decode either, it reads as `refuse`: the file may say `refuse`, so a
486+
narrower carried task is refused rather than cut. A file that did not decode when the server loaded
487+
it gives every setting its default, this one `apply` (a narrower carried task is still cut, never
488+
given more). Only the person can change it; agents cannot.
483489

484490
```json
485491
{ "mcpCarriedProfiles": "refuse" }

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.