# Files changed · PR \#10561 · pingdotgg/t3code

[View on GitCafe](https://git.cafe/pingdotgg/t3code/pull/10561/diffs)

Repository: [pingdotgg/t3code](https://git.cafe/pingdotgg/t3code)

Visibility: public

[feat\(mcp\): expose the existing thread search query](https://git.cafe/pingdotgg/t3code/pull/10561.md)

Version: 3

Head commit: 6342c1cb4b4f4484047fb16175163020b27dbab2

Base commit: d971e17ad8998b8147cac026bf213707dfc0f571

Comparison base: d971e17ad8998b8147cac026bf213707dfc0f571

Showing up to 20 entries from this revision. If the pull request changes, reopen the first page before continuing.

## apps/server/src/mcp/toolkits/thread/handlers.ts

Status: modified; +15; −1

```diff
@@ -10,7 +10,14 @@
 import * as Effect from "effect/Effect";
 import { modelSelectionCommandType } from "@t3tools/shared/model";
 
-import { newCommandId, readThread, readWritableThread, unavailable } from "../../threadAccess.ts";
+import {
+  newCommandId,
+  readCaller,
+  readThread,
+  readWritableThread,
+  unavailable,
+} from "../../threadAccess.ts";
+import * as ProjectionSnapshotQuery from "../../../orchestration/Services/ProjectionSnapshotQuery.ts";
 import { queuedRunsInDeliveryOrder } from "../../../orchestration-v2/QueuedRunOrder.ts";
 import { ThreadToolkit } from "./tools.ts";
 
@@ -61,6 +68,13 @@
   return { ...context, request, item };
 });
 export const ThreadToolkitHandlersLive = ThreadToolkit.toLayer({
+  t3_thread_search: (input) =>
+    Effect.gen(function* () {
+      const { caller } = yield* readCaller();
+      const query = yield* ProjectionSnapshotQuery.ProjectionSnapshotQuery;
+      const result = yield* query.searchThreads(input).pipe(Effect.mapError(unavailable));
+      return { matches: result.matches.filter((match) => match.projectId === caller.projectId) };
+    }),
   t3_thread_fork: (input) =>
     Effect.gen(function* () {
       const { threads, projection } = yield* readWritableThread();
```

## apps/server/src/mcp/toolkits/thread/tools.ts

Status: modified; +15; −0

```diff
@@ -1,4 +1,6 @@
 import {
+  OrchestrationSearchThreadsInput,
+  OrchestrationSearchThreadsResult,
   OrchestrationV2ThreadForkSourcePoint,
   OrchestrationV2ContextTransfer,
   TrimmedNonEmptyString,
@@ -18,6 +20,7 @@
 import * as Schema from "effect/Schema";
 import { Tool, Toolkit } from "effect/unstable/ai";
 
+import { ProjectionSnapshotQuery } from "../../../orchestration/Services/ProjectionSnapshotQuery.ts";
 import { ThreadManagementService } from "../../../orchestration-v2/ThreadManagementService.ts";
 import { McpInvocationContext } from "../../McpInvocationContext.ts";
 
@@ -216,7 +219,19 @@
   .annotate(Tool.Readonly, true)
   .annotate(Tool.Destructive, false);
 
+export const ThreadSearchTool = Tool.make("t3_thread_search", {
+  ...commandTool,
+  description:
+    "Search active thread titles and content with the app's existing bounded search. Returns matches in the calling project from the global top matches; other-project matches are omitted, so this may return fewer than limit. No pagination or exhaustive-result guarantee.",
+  parameters: OrchestrationSearchThreadsInput,
+  success: OrchestrationSearchThreadsResult,
+  dependencies: [...commandTool.dependencies, ProjectionSnapshotQuery],
+})
+  .annotate(Tool.Readonly, true)
+  .annotate(Tool.Destructive, false);
+
 export const ThreadToolkit = Toolkit.make(
+  ThreadSearchTool,
   ThreadForkTool,
   ThreadMergeBackTool,
   ThreadTransfersTool,
```

## apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts

Status: modified; +1; −0

```diff
@@ -812,6 +812,7 @@
   "mcp__t3-code__t3_pending_request_read",
   "mcp__t3-code__t3_thread_configuration",
   "mcp__t3-code__t3_thread_transfers",
+  "mcp__t3-code__t3_thread_search",
   "mcp__t3-code__t3_preview_list",
   "mcp__t3-code__t3_environment_read",
   "mcp__t3-code__t3_queue_list",
```

## packages/shared/src/t3McpToolPresentation.ts

Status: modified; +1; −0

```diff
@@ -61,6 +61,7 @@
   t3_thread_configure: { displayName: "Set thread model" },
   t3_thread_fork: { displayName: "Fork this thread" },
   t3_thread_merge_back: { displayName: "Merge thread context" },
+  t3_thread_search: { displayName: "Search thread content" },
   t3_thread_transfers: { displayName: "Read thread transfers" },
   t3_thread_organize: { displayName: "Organize a thread" },
   t3_thread_update: { displayName: "Update T3 thread metadata" },
```
