Skip to content
TypeScript

fix(server): t3_thread_organize rejects unknown arguments instead of archiving the caller (#26718)

Julius Marmingea773dc38ac75
diff --git a/apps/server/src/mcp/toolkits/core.test.ts b/apps/server/src/mcp/toolkits/core.test.ts
index a978dbc4d1f..93aee4d52f6 100644
--- a/apps/server/src/mcp/toolkits/core.test.ts
+++ b/apps/server/src/mcp/toolkits/core.test.ts
@@ -350,6 +350,48 @@ it.effect("records only failed calls of tools that hand off no work", () => {
);
});
+it.effect("rejects an unknown organize target instead of archiving the calling thread", () => {
+ const dispatched: Array<unknown> = [];
+ return Effect.gen(function* () {
+ const server = yield* McpServer.McpServer;
+ const outcome = yield* server
+ .callTool({
+ name: "t3_thread_organize",
+ arguments: { action: "archive", threadIds: ["other-thread"] },
+ })
+ .pipe(
+ Effect.provideService(McpInvocationContext.McpInvocationContext, scope),
+ Effect.provideService(McpSchema.McpServerClient, client),
+ Effect.result,
+ );
+ expect(dispatched).toEqual([]);
+ expect(outcome).toMatchObject({
+ _tag: "Failure",
+ failure: { message: expect.stringContaining("Expected no excess property") },
+ });
+ }).pipe(
+ Effect.provide(
+ layerThreadToolkit.pipe(
+ Layer.provideMerge(McpServer.McpServer.layer),
+ Layer.provide(NodeCrypto.layer),
+ Layer.provide(
+ Layer.mock(ThreadManagement.ThreadManagementService)({
+ getThreadShell: (id) => Effect.succeed(McpToolAccessTestkit.liveThreadShell(id)),
+ getProjectThreadRecords: ({ threadId: id }) =>
+ Effect.succeed(
+ McpToolAccessTestkit.idleThreadProjection(McpToolAccessTestkit.liveThreadShell(id)),
+ ),
+ dispatch: (command) => {
+ dispatched.push(command);
+ return Effect.succeed({ sequence: 1 } as never);
+ },
+ }),
+ ),
+ ),
+ ),
+ );
+});
+
it.effect("keeps unexpected handler defects private through the production registration", () =>
Effect.gen(function* () {
const server = yield* McpServer.McpServer;
diff --git a/apps/server/src/mcp/toolkits/thread/tools.ts b/apps/server/src/mcp/toolkits/thread/tools.ts
index 4b566c44a69..018acac5c71 100644
--- a/apps/server/src/mcp/toolkits/thread/tools.ts
+++ b/apps/server/src/mcp/toolkits/thread/tools.ts
@@ -61,6 +61,7 @@ const ThreadOrganizeTool = Tool.make("t3_thread_organize", {
],
})
.annotate(Tool.Title, "Organize a thread")
+ .annotate(Tool.Strict, true)
.annotate(Tool.Destructive, true);
const commandTool = {