Open History to see the last commit
1export type T3McpToolLogo = "t3-code";
2
3export interface T3McpToolPresentation {
4 readonly displayName: string;
5 readonly logo: T3McpToolLogo;
6}
7
8export type T3McpToolSummaryAction =
9 | "capabilities"
10 | "delegate"
11 | "task-status"
12 | "task-cancel"
13 | "schedule-run"
14 | "schedule-create"
15 | "schedule-list"
16 | "schedule-update"
17 | "schedule-delete"
18 | "thread-create"
19 | "thread-list"
20 | "thread-read"
21 | "thread-send"
22 | "thread-wait"
23 | "thread-interrupt"
24 | "workflow-stop"
25 | "background-wait"
26 | "thread-configuration"
27 | "thread-configure"
28 | "thread-fork"
29 | "thread-merge"
30 | "thread-search"
31 | "thread-transfers"
32 | "thread-organize"
33 | "thread-update"
34 | "queue-list"
35 | "queue-read"
36 | "queue-edit"
37 | "queue-cancel"
38 | "queue-reorder"
39 | "queue-steer"
40 | "question-list"
41 | "question-read"
42 | "question-respond"
43 | "secret-request"
44 | "worktree-handoff"
45 | "worktree-list"
46 | "worktree-status"
47 | "project-list"
48 | "project-read"
49 | "project-create"
50 | "project-update"
51 | "project-delete"
52 | "project-clone"
53 | "environment-read"
54 | "environment-update"
55 | "attachment-prepare"
56 | "attachment-discard"
57 | "attachment-send"
58 | "link-pr"
59 | "unlink-pr"
60 | "list-prs"
61 | "watch-pr"
62 | "unwatch-pr"
63 | "write-pr-guides"
64 | "read-pr-guide"
65 | "browser"
66 | "device"
67 | "html-preview"
68 | "html-render";
69
70export interface T3McpToolDefinition {
71 readonly displayName: string;
72 readonly labels: readonly [action: string, running: string, completed: string, detail: string];
73 readonly icon: "t3-code" | "browser" | "device" | "pull-request";
74 readonly summaryAction: T3McpToolSummaryAction;
75}
76
77function tool(
78 labels: T3McpToolDefinition["labels"],
79 summaryAction: T3McpToolSummaryAction,
80 icon: T3McpToolDefinition["icon"] = "t3-code",
81 displayName = `${labels[0]} ${labels[3]}`,
82): T3McpToolDefinition {
83 return { displayName, labels, icon, summaryAction };
84}
85
86const T3_MCP_SERVER_ALIASES = new Set(["t3-code", "t3_code", "t3code"]);
87
88const T3_MCP_TOOLS: Readonly<Record<string, T3McpToolDefinition>> = {
89 link_pull_request: tool(
90 ["Link", "Linking", "Linked", "a pull request"],
91 "link-pr",
92 "pull-request",
93 ),
94 unlink_pull_request: tool(
95 ["Unlink", "Unlinking", "Unlinked", "a pull request"],
96 "unlink-pr",
97 "pull-request",
98 ),
99 list_thread_pull_requests: tool(
100 ["Check", "Checking", "Checked", "linked pull requests"],
101 "list-prs",
102 "pull-request",
103 ),
104 watch_pull_request: tool(
105 ["Watch", "Watching", "Watching", "a pull request"],
106 "watch-pr",
107 "pull-request",
108 ),
109 unwatch_pull_request: tool(
110 ["Stop watching", "Unwatching", "Stopped watching", "a pull request"],
111 "unwatch-pr",
112 "pull-request",
113 ),
114 write_pull_request_guides: tool(
115 ["Write", "Writing", "Started writing", "review guides"],
116 "write-pr-guides",
117 "pull-request",
118 ),
119 read_pull_request_guide: tool(
120 ["Read", "Reading", "Read", "a review guide"],
121 "read-pr-guide",
122 "pull-request",
123 ),
124 orchestrator_capabilities: tool(
125 ["Get", "Getting", "Got", "orchestration capabilities"],
126 "capabilities",
127 ),
128 delegate_task: tool(["Delegate", "Delegating", "Delegated", "a child task"], "delegate"),
129 task_status: tool(["Get", "Getting", "Got", "delegated task status"], "task-status"),
130 task_cancel: tool(
131 ["Cancel", "Canceling", "Requested cancellation of", "a delegated task"],
132 "task-cancel",
133 ),
134 schedule_task: tool(
135 ["Schedule", "Scheduling", "Scheduled", "a recurring task"],
136 "schedule-create",
137 ),
138 list_scheduled_tasks: tool(["List", "Listing", "Listed", "scheduled tasks"], "schedule-list"),
139 update_scheduled_task: tool(
140 ["Update", "Updating", "Updated", "a scheduled task"],
141 "schedule-update",
142 ),
143 delete_scheduled_task: tool(
144 ["Delete", "Deleting", "Requested deletion of", "a scheduled task"],
145 "schedule-delete",
146 ),
147 request_secret: tool(["Ask for", "Asking for", "Asked for", "a secret"], "secret-request"),
148 create_threads: tool(["Create", "Creating", "Created", "T3 threads"], "thread-create"),
149 t3_thread_start: tool(["Start", "Starting", "Started", "a T3 thread"], "thread-create"),
150 t3_thread_list: tool(["List", "Listing", "Listed", "T3 threads"], "thread-list"),
151 t3_thread_read: tool(["Read", "Reading", "Read", "a T3 thread"], "thread-read"),
152 t3_thread_send: tool(["Send", "Sending", "Sent", "to a T3 thread"], "thread-send"),
153 t3_thread_wait: tool(["Wait", "Waiting", "Waited", "for a T3 thread"], "thread-wait"),
154 t3_workflow_stop: tool(
155 ["Stop", "Stopping", "Requested a stop for", "a workflow"],
156 "workflow-stop",
157 ),
158 t3_background_wait: tool(
159 ["Update", "Updating", "Updated", "background waits"],
160 "background-wait",
161 ),
162 t3_thread_interrupt: tool(
163 ["Interrupt", "Interrupting", "Requested an interrupt of", "a T3 thread"],
164 "thread-interrupt",
165 ),
166 t3_worktree_handoff: tool(
167 ["Hand off", "Handing off", "Handed off", "thread to a git worktree"],
168 "worktree-handoff",
169 ),
170 t3_worktree_status: tool(["Get", "Getting", "Got", "thread worktree status"], "worktree-status"),
171 preview_status: tool(["Get", "Getting", "Got", "preview browser status"], "browser", "browser"),
172 preview_open: tool(
173 ["Open", "Opening", "Opened", "a page in the preview browser"],
174 "browser",
175 "browser",
176 ),
177 preview_navigate: tool(
178 ["Navigate", "Navigating", "Navigated", "the preview browser"],
179 "browser",
180 "browser",
181 ),
182 preview_dialog: tool(
183 ["Respond", "Responding", "Responded", "to a preview browser dialog"],
184 "browser",
185 "browser",
186 ),
187 preview_snapshot: tool(
188 ["Take a snapshot of", "Taking a snapshot of", "Took a snapshot of", "the preview page"],
189 "browser",
190 "browser",
191 "Snapshot the preview page",
192 ),
193 preview_click: tool(
194 ["Click", "Clicking", "Clicked", "in the preview browser"],
195 "browser",
196 "browser",
197 ),
198 preview_press: tool(
199 ["Press", "Pressing", "Pressed", "a key in the preview browser"],
200 "browser",
201 "browser",
202 ),
203 preview_type: tool(["Type", "Typing", "Typed", "in the preview browser"], "browser", "browser"),
204 preview_hover: tool(
205 ["Hover", "Hovering", "Hovered", "in the preview browser"],
206 "browser",
207 "browser",
208 ),
209 preview_select: tool(
210 ["Choose", "Choosing", "Chose", "an option in the preview browser"],
211 "browser",
212 "browser",
213 ),
214 preview_drag: tool(
215 ["Drag", "Dragging", "Dragged", "in the preview browser"],
216 "browser",
217 "browser",
218 ),
219 preview_upload: tool(
220 ["Upload", "Uploading", "Uploaded", "files to the preview browser"],
221 "browser",
222 "browser",
223 ),
224 preview_scroll: tool(
225 ["Scroll", "Scrolling", "Scrolled", "the preview browser"],
226 "browser",
227 "browser",
228 ),
229 preview_resize: tool(
230 ["Resize", "Resizing", "Resized", "the preview browser"],
231 "browser",
232 "browser",
233 ),
234 preview_evaluate: tool(
235 ["Evaluate", "Evaluating", "Evaluated", "script in the preview browser"],
236 "browser",
237 "browser",
238 ),
239 preview_wait_for: tool(
240 ["Wait", "Waiting", "Waited", "for the preview page"],
241 "browser",
242 "browser",
243 ),
244 preview_set_appearance: tool(
245 ["Set", "Setting", "Set", "preview browser appearance"],
246 "browser",
247 "browser",
248 ),
249 preview_recording_start: tool(
250 ["Start", "Starting", "Started", "recording the preview browser"],
251 "browser",
252 "browser",
253 ),
254 preview_recording_stop: tool(
255 ["Stop", "Stopping", "Stopped", "recording the preview browser"],
256 "browser",
257 "browser",
258 ),
259 device_list: tool(["List", "Listing", "Listed", "simulators and emulators"], "device", "device"),
260 device_open: tool(
261 ["Open", "Opening", "Opened", "a device in the Device panel"],
262 "device",
263 "device",
264 ),
265 device_screenshot: tool(
266 ["Take a screenshot of", "Taking a screenshot of", "Took a screenshot of", "the device"],
267 "device",
268 "device",
269 ),
270 device_close: tool(["Close", "Closing", "Closed", "a device"], "device", "device"),
271 run_scheduled_task_now: tool(
272 ["Run", "Running", "Requested a run of", "a scheduled task"],
273 "schedule-run",
274 ),
275 t3_queue_list: tool(["List", "Listing", "Listed", "queued messages"], "queue-list"),
276 t3_queue_read: tool(["Read", "Reading", "Read", "a queued message"], "queue-read"),
277 t3_queue_edit: tool(["Edit", "Editing", "Edited", "a queued message"], "queue-edit"),
278 t3_queue_cancel: tool(
279 ["Cancel", "Canceling", "Requested cancellation of", "a queued run"],
280 "queue-cancel",
281 ),
282 t3_queue_reorder: tool(["Reorder", "Reordering", "Reordered", "a queued run"], "queue-reorder"),
283 t3_queue_promote_to_steer: tool(
284 ["Steer with", "Steering with", "Requested steering with", "a queued message"],
285 "queue-steer",
286 ),
287 t3_pending_request_list: tool(
288 ["List", "Listing", "Listed", "pending questions"],
289 "question-list",
290 ),
291 t3_pending_request_read: tool(["Read", "Reading", "Read", "pending questions"], "question-read"),
292 t3_pending_request_respond: tool(
293 ["Answer", "Answering", "Answered", "pending questions"],
294 "question-respond",
295 ),
296 t3_thread_configuration: tool(
297 ["Read", "Reading", "Read", "thread configuration"],
298 "thread-configuration",
299 ),
300 t3_thread_configure: tool(["Set", "Setting", "Set", "thread model"], "thread-configure"),
301 t3_thread_fork: tool(["Fork", "Forking", "Requested a fork of", "this thread"], "thread-fork"),
302 t3_thread_merge_back: tool(
303 ["Merge", "Merging", "Requested a merge of", "thread context"],
304 "thread-merge",
305 ),
306 t3_thread_search: tool(["Search", "Searching", "Searched", "thread content"], "thread-search"),
307 t3_thread_transfers: tool(["Read", "Reading", "Read", "thread transfers"], "thread-transfers"),
308 t3_thread_organize: tool(["Organize", "Organizing", "Organized", "a thread"], "thread-organize"),
309 t3_thread_update: tool(["Update", "Updating", "Updated", "T3 thread metadata"], "thread-update"),
310 t3_worktree_list: tool(["List", "Listing", "Listed", "workspace branches"], "worktree-list"),
311 t3_preview_list: tool(["List", "Listing", "Listed", "preview tabs"], "browser", "browser"),
312 t3_preview_close: tool(["Close", "Closing", "Closed", "a preview tab"], "browser", "browser"),
313 t3_environment_read: tool(
314 ["Read", "Reading", "Read", "environment preferences"],
315 "environment-read",
316 ),
317 t3_environment_preferences_update: tool(
318 ["Update", "Updating", "Updated", "environment preferences"],
319 "environment-update",
320 ),
321 t3_thread_launch: tool(["Launch", "Launching", "Launched", "a project thread"], "thread-create"),
322 t3_project_list: tool(["List", "Listing", "Listed", "projects"], "project-list"),
323 t3_project_read: tool(["Read", "Reading", "Read", "a project"], "project-read"),
324 t3_project_create: tool(["Register", "Registering", "Registered", "a project"], "project-create"),
325 t3_project_update: tool(["Update", "Updating", "Updated", "a project"], "project-update"),
326 t3_project_delete: tool(["Delete", "Deleting", "Deleted", "a project"], "project-delete"),
327 t3_project_clone: tool(["Clone", "Cloning", "Cloned", "a repository"], "project-clone"),
328 t3_attachment_prepare_upload: tool(
329 ["Prepare", "Preparing", "Prepared", "an attachment upload"],
330 "attachment-prepare",
331 ),
332 t3_attachment_discard: tool(
333 ["Discard", "Discarding", "Discarded", "a pending attachment"],
334 "attachment-discard",
335 ),
336 t3_thread_send_attachments: tool(["Send", "Sending", "Sent", "attachments"], "attachment-send"),
337 html_preview: tool(["Preview", "Previewing", "Previewed", "an HTML page"], "html-preview"),
338 html_render: tool(["Render", "Rendering", "Rendered", "an HTML page"], "html-render"),
339};
340
341export const T3_MCP_TOOL_NAMES: ReadonlySet<string> = new Set(Object.keys(T3_MCP_TOOLS));
342
343function normalizeT3McpToolLabel(value: string): string {
344 return value.replace(/\s+(?:complete|completed)\s*$/i, "").trim();
345}
346
347// ACP tool prefixes vary; match loosely but require a known display-name entry.
348function resolveT3McpToolName(value: string): string | null {
349 const label = normalizeT3McpToolLabel(value);
350 const mcpMatch = /^mcp__(?<server>.+?)__(?<tool>.+)$/i.exec(label);
351 if (mcpMatch?.groups) {
352 const { server, tool } = mcpMatch.groups;
353 return server !== undefined &&
354 tool !== undefined &&
355 T3_MCP_SERVER_ALIASES.has(server.toLowerCase())
356 ? tool
357 : null;
358 }
359
360 const namespaceMatch = /^(?<server>t3-code|t3_code|t3code)(?:[.:/]|\s*·\s*)(?<tool>.+)$/i.exec(
361 label,
362 );
363 if (namespaceMatch?.groups) {
364 return namespaceMatch.groups.tool ?? null;
365 }
366
367 const prefixed = /^(?:mcp[-_]{1,2})?t3[-_ ]?code(?:__|[-_.:/ ])(?<tool>.+)$/i.exec(label);
368 const candidate = prefixed?.groups?.tool ?? label;
369 if (Object.hasOwn(T3_MCP_TOOLS, candidate)) return candidate;
370 // OpenCode 2 thread prefixes can contain underscores; choose the longest known tool-name suffix.
371 if (!/^t3-code-/i.test(label)) return null;
372 let longest: string | null = null;
373 for (const tool of Object.keys(T3_MCP_TOOLS)) {
374 if (label.endsWith(`_${tool}`) && tool.length > (longest?.length ?? 0)) longest = tool;
375 }
376 return longest;
377}
378
379export function resolveT3McpToolId(toolName: string | null | undefined): string | null {
380 const name = toolName == null ? null : resolveT3McpToolName(toolName);
381 return name !== null && Object.hasOwn(T3_MCP_TOOLS, name) ? name : null;
382}
383
384export function resolveT3McpToolDefinition(
385 toolName: string | null | undefined,
386): T3McpToolDefinition | null {
387 const name = toolName == null ? null : resolveT3McpToolName(toolName);
388 return name !== null && Object.hasOwn(T3_MCP_TOOLS, name) ? T3_MCP_TOOLS[name]! : null;
389}
390
391export function resolveT3McpToolPresentation(
392 toolName: string | null | undefined,
393): T3McpToolPresentation | null {
394 const definition = resolveT3McpToolDefinition(toolName);
395 return definition === null ? null : { displayName: definition.displayName, logo: "t3-code" };
396}