Repository navigation
feat(t3code): move the backend onto T3 Orchestrator V2's /mcp transport - #5
Merged
bryceeppler merged 1 commit intoOct 10, 2026
Conversation
T3's Orchestrator V2 removed POST /api/orchestration/dispatch, and an OAuth mcp-client session is accepted only on /mcp. Add bin/fm-t3-mcp.mjs, a dependency-free MCP client with the captain-run PKCE sign-in, a tools/list capability gate pinned to the signed-in environment id, and the thread verbs the adapter needs, and port bin/backends/t3code.sh onto it: launch, send, read, interrupt, archive with a proven close, and the away-mode thread lookup. The transport forces three changes: fm-control exit refuses on t3code (V2 has no session stop), the WebSocket push path is removed (an mcp-client is refused on it, so T3 windows poll), and a launch whose reply is lost keeps its lease instead of retrying (t3_thread_launch has no idempotency key). Fixes kunchenguid#6904
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Moves this branch's
t3codebackend from the pre-V2 HTTP transport onto T3 Code's Orchestrator V2/mcpendpoint, signed in as an OAuthmcp-client.T3's Orchestrator V2 (pingdotgg/t3code#2829) removed
POST /api/orchestration/dispatch: the 0.0.46 nightly answers 404 for it, and anmcp-clientsession is accepted only on/mcp, so the shell snapshot, thread detail, and WebSocket stream are unavailable to it as well.Reference: kunchenguid#6904
Fixes kunchenguid#6904
What changes
Transport. New
bin/fm-t3-mcp.mjs, a dependency-free MCP streamable-HTTP client (protocol 2025-06-18, JSON or SSE replies) that the adapter calls as a compact CLI.loginis the captain-run sign-in: a two-minute pairing code fromt3 auth pairing create --scope orchestration:read --scope orchestration:operate, the OAuth decision at the full-access ceiling, and a PKCE token exchange.The credential, origin, environment id, and server version are written to the existing
config/t3code-token(mode 0600, never printed); expiry warns five days ahead and refuses once expired.The origin still defaults to
FM_T3CODE_ORIGIN, then~/.t3/userdata/server-runtime.json.Capability gate. Every call runs
tools/listand requires thet3_thread_*,t3_project_list/create, andt3_environment_readtools, then refuses unlesst3_environment_readreports the environment id recorded at sign-in.This replaces the dispatch probe, version floor, and
threadAutoSettleOptOutcheck.Primitive mapping in
bin/backends/t3code.sh, keeping its function names, the status-table shape,config/t3code-instances, model and effort selection, and every spawn, lease, environment, and teardown call site:project.createt3_project_list(real-path match) +t3_project_createthread.create+thread.auto-settle.sett3_thread_launch(existing_worktree, orrootfor a secondmate home) with a binding read-back; T3 assignsmcp:<uuid>thread.turn.startt3_thread_sendmodeautowith aclientRequestIdbackgroundLivenesst3_thread_readV2 status and latest run timesthread.turn.interruptt3_thread_interruptconfirmed byt3_thread_waitthread.session.stop+thread.archivet3_thread_organize archive, then read backarchived:truewith no active runt3_thread_list(active statuses) +t3_thread_readon the home's projectBehavior the transport forces
fm-control.sh exitont3codenow refuses before sending anything: the V2 tools have no session stop, and an interrupt leaves the thread idle and alive, so no stop can be proven.interruptandrelaunchbehave as before.t3code-eventwait.cjs,t3code-thread-status.cjs, and the events suite) is removed, because T3 rejects anmcp-clienton it; T3 windows stay on the watcher's poll loop, and pending approvals read busy rather thanblocked.t3_thread_launchhas no idempotency key, so a launch whose response is lost is never retried; spawn keeps the lease and names the slot to check, replacing the two-attemptcommandIdretry.thread_createnow prints the id T3 assigned, and endpoint validation accepts themcp:prefix.docs/t3code-backend.mdsetup (sign-in, expiry, revocation, telemetry off, capability gate), lifecycle, status table, push, away mode, and limits are rewritten for V2; cross-references inagent-control.md,architecture.md,configuration.md,scripts.md, andREADME.mdare updated.Verification
tests/fm-t3-mcp.test.sh(new, 15 cases) drives the helper againsttests/t3-fake-server.mjs, a fake V2/mcpand OAuth server shared with the backend suite.tests/fm-backend-t3code.test.shis ported onto the same fake server: 55 cases, including spawn, secondmate spawn, abort and uncertain-launch lease retention, teardown ordering, the exit and relaunch refusals, the watcher wedge and dead-agent paths, and away-mode stale-alert retention.tests/fm-backend-t3code-live-e2e.test.shis now a token-free, read-only guard (gate, project catalog, missing-thread read, supervisor lookup) that skips cleanly without a credential.fm-backend,fm-control,fm-control-relaunch,fm-send-inbox,fm-teardown-endpoint-safety,fm-test-run,fm-bootstrap,fm-daemon,fm-secondmate-harness,fm-watch-inbox-meta;bin/fm-lint.shon the changed shell files andbin/fm-doc-audience-check.shpass.t3 0.0.46-nightly.20261008.2833(telemetry off, Claude Code 2.1.295, codex-cli 0.160.1) through an earlier standalone wiring of the same helper: a realfm-brief.shClaude scout from spawn to report, an inbox steer, a confirmed interrupt, a proven archive on teardown, and a Codex scout smoke;docs/verification/runtime-backends.mdrecords it.This branch's own wiring has fake-server coverage only and has not yet been run against a live server.
Follow-ups (not in this PR)
t3_thread_launch(anenvoverlay ask to T3), which would replace the per-directory.claude/settings.local.jsonand.codex/config.tomlchannel.T3CODE_TELEMETRY_ENABLED=false.pendingRequestCount), watcher push throught3_thread_wait, a recovery-gradeexitand relaunch, restart reconciliation, and the wedge alarm.