Uh oh!
There was an error while loading. Please reload this page.
fix(mcp): default omitted path to workspace, not process cwd/$HOME - #41
Conversation
MCP hosts often start oxcode with cwd=$HOME even when the agent is in a project folder. Omitting `path` previously resolved "." to that process cwd, so oxcode_watch could cold-index the entire home directory. Prefer OXCODE_ROOT / CLAUDE_PROJECT_DIR / WORKSPACE_FOLDER_PATHS, then MCP roots/list; refuse $HOME unless path was explicit. Co-authored-by: Michael Assaf <snowmead@users.noreply.github.com>
Co-authored-by: Michael Assaf <snowmead@users.noreply.github.com>
RUSTSEC-2026-0190 / RUSTSEC-2026-0204 fail the deny gate on a stale lockfile. Co-authored-by: Michael Assaf <snowmead@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Fetch MCP roots only from on_initialized / roots/list_changed. Tool handlers wait briefly for that in-flight fetch and never issue nested roots/list (which can hang some hosts). Empty successful lists leave the cache as None so a later list_changed can still populate it. Co-authored-by: Michael Assaf <snowmead@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Cold resolves wait on the fetch lock so roots/list_changed updates are observed. Explicitly empty client lists clear the cache; unparseable URI payloads leave a previously good root in place. Co-authored-by: Michael Assaf <snowmead@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.
When roots/list_changed is running, cold and warm omitted-path resolves wait on the fetch lock so tools do not keep using the previous workspace. Co-authored-by: Michael Assaf <snowmead@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Split path defaulting and RootsCache (Pending/Ready watch) out of the MCP server module. On fetch timeout skip stale cache; parse Windows file:///C:/... roots; flatten OptionalProjectRoot docs; keep prior root on unparseable URI lists. Co-authored-by: Michael Assaf <snowmead@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
CLAUDE_PROJECT_DIR / WORKSPACE_FOLDER_PATHS are process-start snapshots and must not outrank a refreshed roots cache after a folder switch. Keep OXCODE_ROOT as an explicit pin above roots. Co-authored-by: Michael Assaf <snowmead@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.
Overlapping roots/list fetches could wipe a good Ready root when a late failure saw Pending. Hold a fetch mutex and keep last-good under Refreshing. On wait timeout during refresh, skip sticky host env so an older CLAUDE_PROJECT_DIR cannot win mid-switch. Co-authored-by: Michael Assaf <snowmead@users.noreply.github.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 2bb2f08. Configure here.
Uh oh!
There was an error while loading. Please reload this page.
RefreshInFlight (and host-env suppression) only applies when replacing a previously ready MCP root. Refreshing(None) on first fetch still falls through to CLAUDE_PROJECT_DIR / WORKSPACE_FOLDER_PATHS. Co-authored-by: Michael Assaf <snowmead@users.noreply.github.com>
Parallel tests mutated CLAUDE_PROJECT_DIR / OXCODE_ROOT without the same mutex as integration tests, racing resolve_project_root assertions in CI. Co-authored-by: Michael Assaf <snowmead@users.noreply.github.com>
There was a problem hiding this comment.
Thermos review @ 2becdd6
No medium+ findings. Security/correctness and code-quality passes agree after re-checking prior threads against HEAD.
Prior findings — verified fixed
- Concurrent
RootsCache::fetchwipe/restore →fetch_lock+Cold/Refreshing/Ready - Refresh timeout falling through to sticky host env →
RefreshInFlight+allow_host_env: false - Cold-start
Refreshing(None)blocking host env → onlyRefreshing(Some(_))yieldsRefreshInFlight(1ab8c7b) - Live MCP roots vs sticky host env priority, Windows
file:///C:/, module split,OptionalProjectRoot
Rejected near-misses
- CQ:
allow_host_envduplicatesRootsWaitpolicy — single production call site, documented, speculative misuse only - Unbounded
peer.list_roots()during notification fetch — intentional fail-closed vs sticky env; hosts that answer after in-flight tools recover
cargo test -p oxcode-cli --bin oxcode -- mcp:: — 19 passed.
Sent by Cursor Automation: Find vulnerabilities



Summary
MCP hosts (Cursor/Claude) often start the oxcode MCP server with
cwd=$HOMEeven when the agent workspace is a project folder. Omittingpathpreviously resolved to process cwd, sooxcode_watchcould cold-index the home directory.Default root resolution (omitted
path)pathOXCODE_ROOT(explicit pin)roots/list, refreshed onroots/list_changed)CLAUDE_PROJECT_DIR/WORKSPACE_FOLDER_PATHS(host env snapshots; cold-start only when roots are not ready)$HOMEunlesspathwas explicitLive MCP roots sit above sticky host env so a folder switch that only updates roots does not keep querying the previous project. While replacing a previously ready root, a wait timeout suppresses host-env fallback (cold-start still allows it).
Implementation notes
on_initialized/on_roots_list_changed(never nestedroots/listin tool handlers).RootsCache:Cold/Refreshing(previous)/Ready, with a fetch mutex so overlapping notifications cannot wipe/restore the wrong root.file:///C:/...URIs normalize toC:/....mcp/mod.rs,mcp/project_root.rs,mcp/roots.rs,mcp/integration_tests.rs.OptionalProjectRootvia#[serde(flatten)].Docs
README.md, server instructions, andprompts/arms/oxcode-mcp.mdupdated for the new default order.Test plan
cargo test -p oxcode-cli(omitted-path roots, priority, refresh/cold-start wait outcomes)cargo clippy -p oxcode-cli --all-targets -- -D warningsCHANGES_REQUESTEDreviews (all threads resolved; bot token cannot dismiss) or re-run Thermos approvepathwatches the open workspace, not$HOME