fix(claude): isolate capability probe from user MCP servers#4015
fix(claude): isolate capability probe from user MCP servers#4015jbbottoms wants to merge 4 commits into
Conversation
The ~5m Claude capability probe loaded settingSources user/project/local without strictMcpConfig, so every refresh booted configured stdio MCP servers from the server cwd (often $HOME). That turned MCP-side hangs into host freezes (pingdotgg#3909). - Pass empty mcpServers + strictMcpConfig on the probe query - Disable claude.ai MCP connectors via ENABLE_CLAUDEAI_MCP_SERVERS=false - Run the probe from ~/.t3/claude-capability-probe instead of inheriting cwd - Add unit coverage for the probe option builder Fixes pingdotgg#3909
📝 WalkthroughWalkthroughClaude capability probes now use exported configuration helpers that disable user MCP loading, prevent session persistence, and apply a stable working directory under ChangesClaude probe isolation
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant CapabilityProbe
participant ProbeDirectory
participant ClaudeQuery
CapabilityProbe->>ProbeDirectory: create ~/.t3/claude-capability-probe
CapabilityProbe->>ClaudeQuery: provide isolated MCP options and probe cwd
ClaudeQuery-->>CapabilityProbe: execute capability probe
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
|
@coderabbitai review |
✅ Action performedReview finished.
|
ApprovabilityVerdict: Approved Targeted bug fix isolating capability probes from user MCP servers with comprehensive tests. The changes are defensive in nature, preventing unintended MCP server spawning during background probes. Open review comments appear already addressed in the current code. You can customize Macroscope's approvability policy. Learn more. |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/server/src/provider/Layers/ClaudeProvider.ts`:
- Around line 647-650: Remove the `.pipe(Effect.orDie)` from the
`Effect.tryPromise` handling `NodeFS.promises.mkdir` in the probe flow, allowing
directory creation failures to remain in the expected error channel and be
mapped to `undefined` capabilities by the existing downstream handling.
- Line 646: Update the call to resolveClaudeCapabilitiesProbeCwd in the Claude
provider probe flow to pass the configured HOME from claudeEnvironment, ensuring
account-specific or isolated environments use their intended probe directory
instead of the default system home.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: de151275-5b58-47e2-ae0c-690bb9ac5625
📒 Files selected for processing (2)
apps/server/src/provider/Layers/ClaudeCapabilitiesProbe.test.tsapps/server/src/provider/Layers/ClaudeProvider.ts
Keep capability-probe directory creation in the Effect error channel so mkdir failures map to undefined capabilities instead of fiber defects. Resolve the probe cwd from claudeEnvironment.HOME when set. Co-authored-by: Cursor <cursoragent@cursor.com>
Unexpanded ~ or relative HOME must not land the capability probe under the server CWD. Co-authored-by: Cursor <cursoragent@cursor.com>
Dismissing prior approval to re-evaluate fe6c6b4
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high 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 fe6c6b4. Configure here.
Normalize Claude HOME once for capability probes so SDK cwd and env.HOME share the same absolute home for setting/account discovery. Co-authored-by: Cursor <cursoragent@cursor.com>
doesn't this mean we miss skills/commands? |

What Changed
probeClaudeCapabilities) now passes emptymcpServerswithstrictMcpConfig: true, so the ~5 minute refresh loop does not boot user/project/local MCP servers.ENABLE_CLAUDEAI_MCP_SERVERS=falseto block claude.ai connectors on the same path.~/.t3/claude-capability-probeinstead of inheriting the server process cwd (often$HOME).Why
Fixes #3909. The capability probe loaded
settingSources: ["user","project","local"]without MCP isolation. Every refresh spawned configured stdio MCP servers from the server cwd. A wedged MCP (e.g. serena scanning$HOME) accumulated orphans and froze the host (~46 GiB RSS in the report).Real chat sessions are unchanged -- only the lightweight init probe is isolated.
Validation
pnpm exec vp test run src/provider/Layers/ClaudeCapabilitiesProbe.test.ts-> 2/2 passedNotes
Note
Isolate Claude capability probe from user MCP servers
probeClaudeCapabilitiesfunction now runs in a dedicated, isolated cwd (<HOME>/.t3/claude-capability-probe) with an explicitly resolvedHOME, suppressing all MCP server configs, tool usage, and session persistence.buildClaudeCapabilitiesProbeQueryOptionsin ClaudeProvider.ts to construct Claude Agent SDK query options withmcpServers: {},strictMcpConfig: true,allowedTools: [], andENABLE_CLAUDEAI_MCP_SERVERS=false.resolveClaudeCapabilitiesProbeHomeandresolveClaudeCapabilitiesProbeCwdhelpers to normalize and expand~in the probe HOME path and derive a stable working directory.Macroscope summarized 8a78447.
Summary by CodeRabbit
Bug Fixes
Tests
Note
Low Risk
Changes are limited to the background init probe path; real Claude chat sessions are untouched, and the fix reduces subprocess/MCP side effects rather than altering auth or conversation logic.
Overview
Fixes #3909 by changing only the periodic Claude capability probe (
probeClaudeCapabilities), not normal chat sessions.The probe still loads user/project/local settings for account and slash-command init, but SDK options now use
strictMcpConfigwith an emptymcpServersmap andENABLE_CLAUDEAI_MCP_SERVERS=false, so the ~5 minute refresh no longer spawns user MCP or claude.ai connectors.Probe runs from a dedicated
~/.t3/claude-capability-probecwd (with resolved absoluteHOME) instead of inheriting the server process cwd. HelpersbuildClaudeCapabilitiesProbeQueryOptions,resolveClaudeCapabilitiesProbeHome, andresolveClaudeCapabilitiesProbeCwdcentralize that behavior; the probe directory is created before launch.Unit tests cover option isolation and cwd/home resolution edge cases (
~,~/…, relative paths).Reviewed by Cursor Bugbot for commit 8a78447. Bugbot is set up for automated code reviews on this repo. Configure here.