feat(server): add Codex thread start MCP tool#3107
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Needs human review This PR introduces a new MCP tool for spawning child threads - a significant new capability. Additionally, there are unresolved medium-severity review comments identifying potential race conditions and incorrect output behavior that warrant human attention. You can customize Macroscope's approvability policy. Learn more. |
dd38768 to
7b14758
Compare
|
we can get this in before #2829 :) |
7b14758 to
3ae43a2
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 3 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 3ae43a2. Configure here.
| Effect.mapError((error) => | ||
| fail(error instanceof Error ? error.message : "Failed to start child thread."), | ||
| ), | ||
| ); |
There was a problem hiding this comment.
MCP bypasses startup command gate
Medium Severity
The t3_thread_start handler directly calls BootstrapTurnStartDispatcher.dispatchActive. This bypasses the command queuing mechanism that ensures server readiness for WebSocket commands. Consequently, MCP thread starts can execute prematurely during startup, risking race conditions and inconsistent orchestration compared to WS.
Reviewed by Cursor Bugbot for commit 3ae43a2. Configure here.
| prepareWorktree, | ||
| runSetupScript: input.runSetupScript ?? true, | ||
| } | ||
| : {}), |
There was a problem hiding this comment.
Setup script ignored existing worktree
Low Severity
The runSetupScript flag is only passed to BootstrapTurnStartDispatcher when mode is new_worktree. It's incorrectly nested within the prepareWorktree object, which is only created for new_worktree mode. This prevents setup scripts from running for existing_worktree threads, even when runSetupScript is specified in the input.
Reviewed by Cursor Bugbot for commit 3ae43a2. Configure here.
| projectId: project.id, | ||
| mode, | ||
| branch, | ||
| worktreePath, |
There was a problem hiding this comment.
New worktree path omitted from output
Medium Severity
For new_worktree, the handler keeps worktreePath as null in the tool response even though dispatchActive completes worktree creation and updates thread metadata with the real path. Codex is told the child has no worktree path after a successful start.
Reviewed by Cursor Bugbot for commit 3ae43a2. Configure here.


Summary
Adds a provider-scoped MCP tool,
t3_thread_start, that lets Codex start another T3 Code thread only when the user explicitly asks to start, spawn, or create another thread/agent.This keeps the tool available for intentional multi-thread workflows without encouraging autonomous delegation or background parallel work.
What changed
t3_thread_start.thread-managementMCP capability and grants it to provider-scoped MCP sessions.new_worktree: creates a temporary branch/worktree from the default branch by default.existing_worktree: starts a thread in a supplied worktree path.current_checkout: starts a thread on the current checkout and returns warning metadata.Implementation notes
BootstrapTurnStartDispatcher.Validation
vp checkvp run typecheckRisk
Moderate. This touches thread-start orchestration and WebSocket bootstrap routing, but the behavior is centralized behind the same command shape and covered with new thread-tool tests plus existing server type coverage.
Note
Add
t3_thread_startMCP tool for starting Codex child threadst3_thread_start) in tools.ts with validated input/output schemas supportingnew_worktree,existing_worktree, andcurrent_checkoutmodes.thread.turn.startvia a newBootstrapTurnStartDispatcher.thread-managementto the MCP capability set so bearer tokens authorize the new tool.t3_thread_startusage guidance to Codex developer instructions in CodexDeveloperInstructions.ts.Macroscope summarized 3ae43a2.
Note
Medium Risk
Touches thread creation, git worktrees, and orchestration bootstrap paths shared by WebSocket and MCP; behavior is centralized but still mutating and capability grants on all new MCP tokens may affect downstream checks.
Overview
Introduces
t3_thread_starton the T3 Code MCP server so Codex can spawn child threads when the user explicitly asks. Provider MCP sessions now include athread-managementcapability (alongside preview), and the tool requires it at invocation time.The tool supports
new_worktree(default),existing_worktree, andcurrent_checkoutmodes, inherits model/runtime/interaction settings from the invoking thread unless overridden, dispatches a bootstrappedthread.turn.startimmediately, and returns launch metadata (with a warning for same-checkout starts) without waiting for the child to finish.Bootstrap turn-start logic (thread create, optional worktree prep, setup script, failure cleanup, VCS refresh) is extracted from
ws.tsintoBootstrapTurnStartDispatcher, shared by WebSocket orchestration dispatch and the MCP handler. Server startup registers the dispatcher and thread-start runtime alongside MCP toolkit registration.Codex plan and default developer instructions now document when
t3_thread_startmay be used (explicit user intent only, not autonomous delegation).Reviewed by Cursor Bugbot for commit 3ae43a2. Bugbot is set up for automated code reviews on this repo. Configure here.