fix: MCP roots take priority over CRB_WORKSPACE for multi-window support#164
Merged
ichoosetoaccept merged 1 commit intomainfrom Feb 16, 2026
Conversation
MCP roots are per-window (sent by the client), so they correctly identify the project in each IDE window. CRB_WORKSPACE is now an internal fallback for CI/scripts where MCP roots are unavailable — removed from all README config examples and settings table. - Flip priority: MCP roots → CRB_WORKSPACE → process cwd - Simplify README: single config snippet, no CRB_WORKSPACE - Expanded dev setup with all config options commented - Add fallback tests for roots-empty and roots-exception cases
Member
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Greptile SummaryFlips workspace detection priority so MCP roots take precedence over
The change is well-motivated: MCP roots are sent per-window by the client and provide the correct workspace for multi-window scenarios, while Confidence Score: 5/5
Important Files Changed
Flowchartflowchart TD
Start[Tool call needs workspace] --> CheckCtx{Context available?}
CheckCtx -->|Yes| CheckRoots[Try ctx.list_roots]
CheckCtx -->|No| CheckEnv[Check CRB_WORKSPACE]
CheckRoots --> RootsException{Exception?}
RootsException -->|No| RootsEmpty{Roots empty?}
RootsException -->|Yes| LogWarning[Log warning]
RootsEmpty -->|No| ParseRoot[Parse first root URI]
RootsEmpty -->|Yes| CheckEnv
LogWarning --> CheckEnv
ParseRoot --> ValidFile{Valid file:// URI?}
ValidFile -->|Yes| ReturnRoot[Return root path]
ValidFile -->|No| CheckEnv
CheckEnv --> EnvSet{CRB_WORKSPACE set?}
EnvSet -->|Yes| ReturnEnv[Return env var path]
EnvSet -->|No| ReturnNone[Return None]
ReturnRoot --> Success[Workspace detected]
ReturnEnv --> Success
ReturnNone --> UseCwd[Falls back to process cwd]
style ReturnRoot fill:#90EE90
style ReturnEnv fill:#FFD700
style ReturnNone fill:#FFB6C1
style Success fill:#90EE90
Last reviewed commit: 761dba5 |
Member
Author
f6e8eec to
761dba5
Compare
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
Flips workspace detection priority so MCP roots (per-window) take precedence over
CRB_WORKSPACE(static env var). This fixes multi-window setups where a single shared MCP client config JSON would hardcode the wrong project path.Problem
CRB_WORKSPACEwas priority #1 in workspace detection. But MCP client config JSON is shared across all IDE windows — setting a static project path breaks when you have multiple windows open on different projects simultaneously.Changes
server.py: Flip_get_workspace_cwdpriority: MCP roots →CRB_WORKSPACE→ process cwdserver.py: Update instructions to explain auto-detection from MCP rootsREADME.md: RemoveCRB_WORKSPACEfrom default config snippet and settings table — it is an internal fallback for CI/scripts, not user-facing configtest_server.py: RewriteTestGetWorkspaceCwd— roots now win over env var; added fallback tests for roots-empty and roots-exception cases (6 → 8 tests)Detection cascade
Verified: Windsurf sends MCP roots correctly — workspace detection works across multiple windows without any env var config.