Skip to content

fix(claude): isolate capability probe from user MCP servers#4015

Open
jbbottoms wants to merge 4 commits into
pingdotgg:mainfrom
jbbottoms:fix/claude-capability-probe-no-mcp
Open

fix(claude): isolate capability probe from user MCP servers#4015
jbbottoms wants to merge 4 commits into
pingdotgg:mainfrom
jbbottoms:fix/claude-capability-probe-no-mcp

Conversation

@jbbottoms

@jbbottoms jbbottoms commented Jul 15, 2026

Copy link
Copy Markdown

What Changed

  • Claude capability probe (probeClaudeCapabilities) now passes empty mcpServers with strictMcpConfig: true, so the ~5 minute refresh loop does not boot user/project/local MCP servers.
  • Probe env sets ENABLE_CLAUDEAI_MCP_SERVERS=false to block claude.ai connectors on the same path.
  • Probe runs from ~/.t3/claude-capability-probe instead of inheriting the server process cwd (often $HOME).
  • Added unit coverage for the probe option builder.

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 passed

Notes

Note

Isolate Claude capability probe from user MCP servers

  • The probeClaudeCapabilities function now runs in a dedicated, isolated cwd (<HOME>/.t3/claude-capability-probe) with an explicitly resolved HOME, suppressing all MCP server configs, tool usage, and session persistence.
  • Adds buildClaudeCapabilitiesProbeQueryOptions in ClaudeProvider.ts to construct Claude Agent SDK query options with mcpServers: {}, strictMcpConfig: true, allowedTools: [], and ENABLE_CLAUDEAI_MCP_SERVERS=false.
  • Adds resolveClaudeCapabilitiesProbeHome and resolveClaudeCapabilitiesProbeCwd helpers to normalize and expand ~ in the probe HOME path and derive a stable working directory.
  • Behavioral Change: the probe no longer inherits user or project MCP server configurations; the probe directory is created on demand if missing.

Macroscope summarized 8a78447.

Summary by CodeRabbit

  • Bug Fixes

    • Improved Claude capability detection reliability by isolating probes from user and project MCP configurations.
    • Prevented capability checks from persisting sessions or invoking unintended tools.
    • Ensured probe data uses a stable working directory and avoids repeated side effects.
  • Tests

    • Added coverage for Claude probe configuration, environment handling, and working-directory resolution.

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 strictMcpConfig with an empty mcpServers map and ENABLE_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-probe cwd (with resolved absolute HOME) instead of inheriting the server process cwd. Helpers buildClaudeCapabilitiesProbeQueryOptions, resolveClaudeCapabilitiesProbeHome, and resolveClaudeCapabilitiesProbeCwd centralize 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.

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
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Claude capability probes now use exported configuration helpers that disable user MCP loading, prevent session persistence, and apply a stable working directory under ~/.t3. Tests cover query isolation and probe CWD resolution.

Changes

Claude probe isolation

Layer / File(s) Summary
Probe configuration helpers and tests
apps/server/src/provider/Layers/ClaudeProvider.ts, apps/server/src/provider/Layers/ClaudeCapabilitiesProbe.test.ts
Adds settings-source configuration, stable CWD resolution, isolated query options, and tests for MCP suppression, environment wiring, and path resolution.
Stable probe-directory execution
apps/server/src/provider/Layers/ClaudeProvider.ts
Creates the probe directory and passes its CWD and generated options into probeClaudeCapabilities.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: juliusmarminge, marve10s

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
Loading

Poem

I’m a rabbit with a tidy new trail,
No MCP servers leap through the veil.
A quiet CWD, a cautious query,
Keeps each probe small, calm, and cheery.
Hop hop—safe checks prevail!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes satisfy #3909 by disabling MCP loading for probes and using a dedicated probe cwd.
Out of Scope Changes check ✅ Passed The added helper extraction, environment flag, and tests all support the linked probe-isolation fix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly summarizes the main change: isolating the Claude capability probe from user MCP servers.
Description check ✅ Passed The description covers what changed, why, validation, and notes, and is complete enough despite missing the optional UI section.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Jul 15, 2026
@jbbottoms

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Comment thread apps/server/src/provider/Layers/ClaudeProvider.ts Outdated
@macroscopeapp

macroscopeapp Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between ecb35f7 and 1baa467.

📒 Files selected for processing (2)
  • apps/server/src/provider/Layers/ClaudeCapabilitiesProbe.test.ts
  • apps/server/src/provider/Layers/ClaudeProvider.ts

Comment thread apps/server/src/provider/Layers/ClaudeProvider.ts Outdated
Comment thread apps/server/src/provider/Layers/ClaudeProvider.ts Outdated
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>
Comment thread apps/server/src/provider/Layers/ClaudeProvider.ts Outdated
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Jul 15, 2026
Unexpanded ~ or relative HOME must not land the capability probe under the server CWD.

Co-authored-by: Cursor <cursoragent@cursor.com>
@macroscopeapp macroscopeapp Bot dismissed their stale review July 15, 2026 19:35

Dismissing prior approval to re-evaluate fe6c6b4

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread apps/server/src/provider/Layers/ClaudeProvider.ts Outdated
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>
@juliusmarminge

Copy link
Copy Markdown
Member

Probe runs from ~/.t3/claude-capability-probe instead of inheriting the server process cwd (often $HOME).

doesn't this mean we miss skills/commands?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

2 participants