Repository navigation
[Bug]: OpenCode 2 threads never get T3 Code's MCP tools (server name t3-code-<threadId> is too long for OpenCode) #16140
Description
Before submitting
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area
apps/server
Steps to reproduce
- Configure an OpenCode 2.0.22 provider instance (T3-spawned server, no
serverUrl, no OpenCode plugins). - Start a new thread with
opencode/big-pickleand ask it to callt3_thread_configuration, or ask any thread todelegate_taskto an OpenCode model and have the child call it. - Look at
~/.local/share/opencode/log/opencode.logand T3's server log.
Expected behavior
OpenCode 2 threads and delegated OpenCode 2 children can call T3's MCP tools (delegate_task, task_status, t3_thread_*, ...), like Claude, Codex and Cursor threads.
Actual behavior
The agent finds no T3 tools. OpenCode2AdapterV2.ts names the server t3-code-<threadId> (non-alphanumerics to _). With V2 thread ids that is 96 characters for a project thread (thread:project:<projectId>:<uuid>) and over 100 for a delegated child (thread:delegated-task:command%3Amcp%3A<uuid>%3Adelegate-task%3A<clientRequestId>). OpenCode 2 rejects both:
- Project threads (65-100 chars):
mcp.addsucceeds andGET /api/mcpshows the serverconnected, but OpenCode registers MCP tools under the server name as namespace and requires each namespace segment to match^[A-Za-z0-9_-]{1,64}$(packages/core/src/tool.tsnamespaceError). All 72 tools are skipped; only the OpenCode log says so. - Delegated children (over 100 chars): OpenCode's router (
maxParamLength100) answersPUT /api/experimental/mcp/:serverwith 404, so T3 logs "Could not add T3 Code's MCP server to OpenCode." and the child runs without T3 tools.
Reproduced on main @ e22c880 with the free opencode/big-pickle model and no OpenCode plugins, so no third-party provider is involved. supportsMcpTools: false in the adapter's capabilities is not the cause; prepareTurn registers the server either way.
Impact
Major degradation or frequent failure
Version or commit
main @ e22c880 (also nightly 0.0.46-nightly.20261004.2648 and .20261005.2667)
Environment
Linux x64 (NixOS VM), Node 24.21, OpenCode 2.0.22 spawned by T3, opencode/big-pickle; also seen with cursor/claude-opus-5-5-1m via cursor-opencode-provider 0.8.0
Logs or stack traces
# OpenCode log, project thread (72 such lines, one per tool)
level=ERROR message="Skipping invalid tool registration" name=create_threads namespace=t3-code-thread_project_ce04e4e2-6c29-4ff0-a1d7-b089dd63e258_d3b2d715-c4a1-4b63-bb65-1634c3a3a8c4 error="Invalid tool namespace: \"t3-code-thread_project_ce04e4e2-..._d3b2d715-...\""
# T3 server log, delegated child
WARN Could not add T3 Code's MCP server to OpenCode.
ClientError:
[cause]: HttpClientError: Decode error (404 PUT http://127.0.0.1:34513/api/experimental/mcp/t3-code-thread_delegated-task_command_3Amcp_3A7ca20ace-cbf6-4ffc-bbf8-69558d406fca_3Adelegate-task_3Aoc-child-check-1)The agent's answer in both cases: "NO_T3_TOOLS" (main thread thread:project:ce04e4e2-…:d3b2d715-…), "CHILD_NO_T3_TOOLS" (child of thread:project:760891bb-…:924738ca-…).
Workaround
None for delegated children. For main threads, an OpenCode 2 plugin can re-register long t3-code-* servers under a short alias and re-apply T3's per-thread permission rules to it.
Related: #8860 (same class of bug: long V2 ids over a 100-char route limit, fixed in T3's own routes by #8898); #15736 (Code Mode catalog flapping on the same prepareTurn/mcp.add path, with a 44-char name, so a different bug).
Model: Claude Opus 5.5 (1M). Harness: Claude Code in T3 Code.
Activity
OCPdev25 commentedon Oct 6, 2026
Independent reproduction on macOS 26.5.1, T3 Code Nightly 0.0.46-nightly.20261005.2702, and OpenCode 2.0.23. This also blocks the newly added inline HTML visualization tools, so it can look like a model cannot use that feature.
We delegated the same small visualization task to four OpenCode models:
opencode/space-bunny-free,opencode/mimo-v2.6-flash-free,opencode/nemotron-3.5-lightning-free, andopencode/fledge-alpha-free. Each searched its Code Mode catalog for the exacthtml_previewandhtml_rendertools. None found them, including after follow-up turns with explicit discovery instructions; the available namespaces were browser, gateway, and opencode.tools.browser.previewwas present, but is the separate Review-pane action.The live OpenCode log corroborates the delegated-child failure described here. Field-selected summaries, with thread identifiers and local paths omitted:
Later follow-up turns produced the same child-specific 404s. The server-name lengths above were measured from the actual failed request paths, rather than reconstructed from example IDs.
A Codex-backed child in the same T3 environment successfully called
html_previewandhtml_render, receiving a screenshot,contentHeight, console results, an attachment ID, and nine measured widths. This is a working feature control, not a same-model cross-harness comparison.This matches #16140 more closely than the first-turn race in #16141: our child server names exceed 100 characters, registration requests return 404, and additional turns do not recover the tools. Current
mainat9422e2ee12fd3e3bfdf6fe5c377672badf7b20castill has the unboundedt3McpServerNamehelper. We have not tested #16142, so this comment corroborates the failure rather than validating the proposed fix. No configuration changes or workaround were applied during this diagnostic.Investigated with GPT-6.1-Sol through the Codex harness in T3 Code, with the four OpenCode models above supplying their catalog results.