Repository navigation
Conversation
This branch has not been deployed
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.
Summary
This change adds an opt-in stdio MCP mode that allows one MCP session to serve multiple linked Git worktrees concurrently.
The router:
repo_root.data_dir.--multi-worktreeis explicitly enabled.Motivation
Parallel pull request reviews commonly use separate linked worktrees so that each review can inspect the exact pull request revision. The existing single-root MCP process could not accept another linked worktree after startup, which forced reviews to run serially and required repeatedly rebuilding or switching the checkout.
This mode lets one MCP session route concurrent requests to isolated child servers without mixing graph data from different worktrees or commits.
Usage
Start the server from the primary checkout:
Tool calls for linked worktrees must include that worktree's absolute path in
repo_root. Only the primary checkout and active worktrees reported bygit worktree listfor the same Git common directory are accepted.The mode is stdio-only and cannot be combined with a process-wide
CRG_DATA_DIR. External graph storage should instead use separate, non-overlapping Registrydata_direntries for each worktree.Security
The implementation keeps the existing repository boundary checks and adds explicit same-repository worktree authorization. Each child process is started with a restricted environment allowlist, and the router refuses database aliasing between worktrees. Unrelated repositories and inactive worktree paths cannot be routed through the session.
Validation
uv run ruff check code_review_graph/cli.py code_review_graph/multi_worktree.py tests/test_cli.py tests/test_e2e_mcp_client.py tests/test_multi_worktree.pyuv run pytest -q tests/test_multi_worktree.py tests/test_cli.py tests/test_e2e_mcp_client.py— 32 passedgit diff --checkprekwas not run because this repository does not contain a prek or pre-commit configuration.