Skip to content

Commit c81f6dc

Browse files
fix(server): MCP clients see the descriptions on title and clientRequestId
The descriptions sat on trimmed-string transformations, so they only reached the decoded side and tools/list advertised a bare string. Describe the optional fields instead, which the encoded JSON schema keeps. Fixes #35015 AI-assisted; verified with the tests and tools listed above.
1 parent f651e58 commit c81f6dc

4 files changed

Lines changed: 38 additions & 33 deletions

File tree

‎apps/server/src/mcp/toolkits/project/tools.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
ProjectCreatePayload,
1515
ProjectUpdatePayload,
1616
ProjectId,
17-
OrchestratorMcpClientRequestId,
17+
OrchestratorMcpOptionalClientRequestId,
1818
OrchestratorMcpEnvironmentTarget,
1919
OrchestratorMcpFailure,
2020
SourceControlCloneRepositoryInput,
@@ -150,7 +150,7 @@ const ThreadLaunchTool = Tool.make("t3_thread_launch", {
150150
}),
151151
),
152152
attachments: Schema.optional(Schema.Array(McpAttachmentInput).check(Schema.isMaxLength(8))),
153-
clientRequestId: Schema.optional(OrchestratorMcpClientRequestId),
153+
clientRequestId: OrchestratorMcpOptionalClientRequestId,
154154
/** Set by a linked environment launching its agent's delegated task here; ignored otherwise. */
155155
delegatedFrom: Schema.optional(OrchestrationV2DelegatedFrom),
156156
}),
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"claudeSystemAppendBytes": 5597,
33
"codexAdditionalContextBytes": 7327,
4-
"mcpToolListJsonBytes": 48131
4+
"mcpToolListJsonBytes": 48896
55
}

‎packages/contracts/src/orchestratorMcp.ts‎

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,19 @@ import { ProviderDriverKind, ProviderInstanceId } from "./providerInstance.ts";
4646

4747
const OrchestratorMcpPrompt = TrimmedNonEmptyString.check(Schema.isMaxLength(120_000));
4848
const OrchestratorMcpTitle = TrimmedNonEmptyString.check(Schema.isMaxLength(512));
49-
export const OrchestratorMcpClientRequestId = TrimmedNonEmptyString.check(Schema.isMaxLength(256))
50-
.check(
51-
Schema.makeFilter((value) =>
52-
hasOnlyPairedSurrogates(value)
53-
? true
54-
: "clientRequestId must contain valid paired Unicode surrogates.",
55-
),
56-
)
57-
.annotate({ description: "Reuse it to retry the same call. A new call gets a new key." });
49+
export const OrchestratorMcpClientRequestId = TrimmedNonEmptyString.check(
50+
Schema.isMaxLength(256),
51+
).check(
52+
Schema.makeFilter((value) =>
53+
hasOnlyPairedSurrogates(value)
54+
? true
55+
: "clientRequestId must contain valid paired Unicode surrogates.",
56+
),
57+
);
58+
// Described on the optional field: a description on a trimmed string misses its encoded JSON schema.
59+
export const OrchestratorMcpOptionalClientRequestId = Schema.optional(
60+
OrchestratorMcpClientRequestId,
61+
).annotate({ description: "Reuse it to retry the same call. A new call gets a new key." });
5862

5963
// OpenCode 1.15 serializes nested MCP union objects as JSON strings; decode that form at the boundary.
6064
const OrchestratorMcpScheduleFromJsonString = Schema.fromJsonString(
@@ -186,7 +190,7 @@ export const OrchestratorMcpDelegateTaskInput = Schema.Struct({
186190
timeoutMs: Schema.optional(Schema.Finite).annotate({
187191
description: "Mode 'wait' only. Default 10 min. A timeout does not cancel the child.",
188192
}),
189-
clientRequestId: Schema.optional(OrchestratorMcpClientRequestId),
193+
clientRequestId: OrchestratorMcpOptionalClientRequestId,
190194
runtimeMode: Schema.optional(
191195
OrchestratorMcpRuntimeMode.annotate({
192196
description:
@@ -256,7 +260,7 @@ export type OrchestratorMcpTaskStatusInput = typeof OrchestratorMcpTaskStatusInp
256260
export const OrchestratorMcpTaskCancelInput = Schema.Struct({
257261
taskId: NodeId,
258262
reason: Schema.optional(Schema.String.check(Schema.isMaxLength(2_000))),
259-
clientRequestId: Schema.optional(OrchestratorMcpClientRequestId),
263+
clientRequestId: OrchestratorMcpOptionalClientRequestId,
260264
});
261265
export type OrchestratorMcpTaskCancelInput = typeof OrchestratorMcpTaskCancelInput.Type;
262266

@@ -280,7 +284,7 @@ export const OrchestratorMcpCreateThreadsInput = Schema.Struct({
280284
Schema.isMinLength(1),
281285
Schema.isMaxLength(20),
282286
),
283-
clientRequestId: Schema.optional(OrchestratorMcpClientRequestId),
287+
clientRequestId: OrchestratorMcpOptionalClientRequestId,
284288
});
285289
export type OrchestratorMcpCreateThreadsInput = typeof OrchestratorMcpCreateThreadsInput.Type;
286290

@@ -524,7 +528,7 @@ export const OrchestratorMcpThreadSendInput = Schema.Struct({
524528
"Start a new provider session without the thread's earlier context, like /clear. Never steers.",
525529
}),
526530
),
527-
clientRequestId: Schema.optional(OrchestratorMcpClientRequestId),
531+
clientRequestId: OrchestratorMcpOptionalClientRequestId,
528532
});
529533
export type OrchestratorMcpThreadSendInput = typeof OrchestratorMcpThreadSendInput.Type;
530534

@@ -575,7 +579,7 @@ export const OrchestratorMcpThreadInterruptInput = Schema.Struct({
575579
* watches and stop every task it delegated. `runId` is then not used.
576580
*/
577581
stop: Schema.optional(Schema.Boolean),
578-
clientRequestId: Schema.optional(OrchestratorMcpClientRequestId),
582+
clientRequestId: OrchestratorMcpOptionalClientRequestId,
579583
});
580584
export type OrchestratorMcpThreadInterruptInput = typeof OrchestratorMcpThreadInterruptInput.Type;
581585

@@ -688,7 +692,7 @@ export const OrchestratorMcpScheduleTaskInput = Schema.Struct({
688692
"Runs share one thread but each starts a fresh session without earlier runs' context. Unbound: the first run makes the thread.",
689693
}),
690694
),
691-
clientRequestId: Schema.optional(OrchestratorMcpClientRequestId),
695+
clientRequestId: OrchestratorMcpOptionalClientRequestId,
692696
});
693697
export type OrchestratorMcpScheduleTaskInput = typeof OrchestratorMcpScheduleTaskInput.Type;
694698

@@ -837,7 +841,7 @@ export const OrchestratorMcpEnvironmentLinkInput = Schema.Struct({
837841
requestedAccess: Schema.optional(AuthMcpClientAccess).annotate({
838842
description: "Suggested access. The user picks; default approval-required.",
839843
}),
840-
clientRequestId: Schema.optional(OrchestratorMcpClientRequestId),
844+
clientRequestId: OrchestratorMcpOptionalClientRequestId,
841845
});
842846
export type OrchestratorMcpEnvironmentLinkInput = typeof OrchestratorMcpEnvironmentLinkInput.Type;
843847

‎packages/contracts/src/threadMetadataMcp.ts‎

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,29 @@ export function hasOnlyPairedSurrogates(value: string): boolean {
2626
return true;
2727
}
2828

29-
const ThreadMetadataTitle = TrimmedNonEmptyString.check(Schema.isMaxLength(512)).annotate({
30-
description: "New concise display title. Required only when action is rename.",
31-
});
29+
const ThreadMetadataTitle = TrimmedNonEmptyString.check(Schema.isMaxLength(512));
3230

33-
const ThreadMetadataClientRequestId = TrimmedNonEmptyString.check(Schema.isMaxLength(256))
34-
.check(
35-
Schema.makeFilter((value) =>
36-
hasOnlyPairedSurrogates(value)
37-
? true
38-
: "clientRequestId must contain valid paired Unicode surrogates.",
39-
),
40-
)
41-
.annotate({ description: "Stable idempotency key to reuse when retrying this mutation." });
31+
const ThreadMetadataClientRequestId = TrimmedNonEmptyString.check(Schema.isMaxLength(256)).check(
32+
Schema.makeFilter((value) =>
33+
hasOnlyPairedSurrogates(value)
34+
? true
35+
: "clientRequestId must contain valid paired Unicode surrogates.",
36+
),
37+
);
4238

4339
export const ThreadMetadataMcpAction = Schema.Literals(["rename", "regenerate_title"]);
4440
export type ThreadMetadataMcpAction = typeof ThreadMetadataMcpAction.Type;
4541

4642
export const ThreadMetadataMcpUpdateInput = Schema.Struct({
4743
threadId: Schema.optional(ThreadId),
4844
action: ThreadMetadataMcpAction,
49-
title: Schema.optional(ThreadMetadataTitle),
50-
clientRequestId: Schema.optional(ThreadMetadataClientRequestId),
45+
// Described on the optional fields: a description on a trimmed string misses its encoded JSON schema.
46+
title: Schema.optional(ThreadMetadataTitle).annotate({
47+
description: "New concise display title. Required only when action is rename.",
48+
}),
49+
clientRequestId: Schema.optional(ThreadMetadataClientRequestId).annotate({
50+
description: "Stable idempotency key to reuse when retrying this mutation.",
51+
}),
5152
}).check(
5253
Schema.makeFilter((input) =>
5354
(input.action === "rename") === (input.title !== undefined)

0 commit comments

Comments
 (0)