Skip to content

[BR-2276] Detect MCP config capability across operating systems - #1363

Open
sunishsheth2009 wants to merge 5 commits into
databricks:mainfrom
sunishsheth2009:sunish/br-2276-agent-detection
Open

sunishsheth2009 wants to merge 5 commits into
databricks:mainfrom
sunishsheth2009:sunish/br-2276-agent-detection

Conversation

@sunishsheth2009

@sunishsheth2009 sunishsheth2009 commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

BR-2276

UG could report Claude Code or Codex as unavailable when their CLI was off PATH, even though UG could write the agent's user MCP config. The previous macOS app-path check also missed other install layouts and did not cover Windows or Linux.

This change detects MCP configuration capability through each agent's existing config path resolver:

  • A CLI on PATH remains the source for native mcp list status.
  • An existing Claude Code or Codex user config makes that client discoverable on macOS, Windows, and Linux. CLAUDE_CONFIG_DIR and CODEX_HOME remain supported.
  • Explicit ug mcp add --agents claude or --agents codex can create user MCP config even with no CLI on PATH and no prior config. Removal uses the same direct writers.
  • Config-only status reports file state and says it is not a live health check. It does not claim an OAuth login or successful tool call.

This PR is based on main and contains only BR-2276 changes. The MCP workspace-selection prerequisite, #1364, has merged.

Validation

  • tests/test_mcp.py tests/test_cli.py tests/test_agent_vscode.py: 1,062 passed on the rebased branch.
  • Ruff check and format for src/ and tests/, Ty check for src/, and git diff --check passed.
  • Component tests use temporary config files and cover explicit add without a CLI or existing config. Native desktop behavior on macOS, Windows, and Linux has not been validated in this revision. LiteSwap cannot exercise local agent configuration.

Limit

A config file can survive an uninstallation. Config-only detection means UG can write that client's user MCP configuration; it does not prove the app is currently installed. Fresh installs with no CLI and no config require explicit --agents selection.

@sunishsheth2009
sunishsheth2009 force-pushed the sunish/br-2276-agent-detection branch from f9e62ad to f2589d1 Compare October 29, 2026 23:29
@sunishsheth2009 sunishsheth2009 changed the title [BR-2276] Detect installed Claude Code and Codex apps for MCP setup [BR-2276] Detect MCP config capability across operating systems Oct 30, 2026
@sunishsheth2009
sunishsheth2009 changed the base branch from main to sunish/br-2167-mcp-only October 30, 2026 03:43
@sunishsheth2009
sunishsheth2009 marked this pull request as ready for review October 30, 2026 04:06
@sunishsheth2009
sunishsheth2009 deleted the branch databricks:sunish/br-2167-mcp-only October 30, 2026 19:09
@sunishsheth2009
sunishsheth2009 changed the base branch from sunish/br-2167-mcp-only to main October 30, 2026 19:23
@sunishsheth2009
sunishsheth2009 force-pushed the sunish/br-2276-agent-detection branch from f55b388 to edb6048 Compare October 30, 2026 19:24
sunishsheth2009 added a commit to sunishsheth2009/ucode that referenced this pull request Oct 30, 2026
…cks#1364)

## BR-2167

Coding agents keep MCP registrations in a global config keyed by server
name. Adding workspace B's MCP server while workspace A remains active
can expose B's tools to an A session; appending a workspace suffix does
not isolate the sessions. Model configuration already selects one active
workspace.

This PR makes MCP registration follow that active-workspace boundary:

- `ug mcp add --workspace B` refuses to register while A is active and
points to `ug configure --workspace B`. On first setup, MCP add selects
its workspace without configuring agent models.
- An explicit configure switch saves the destination workspace's own MCP
selections, removes registrations left from the previous workspace,
configures models and policy, then restores the destination's saved user
MCP entries. Managed MCPs are reconciled before user entries are
restored, including the single-agent Codex path.
- Switching back restores A's saved MCP entries. A and B can use the
same server name; the active agent config contains the selected
workspace's URL under that name, with no workspace suffix.
- MCP-only configure paths and Claude Cowork sync use the selected
workspace. README documents the switch.

Example: with A active and `system-ai-github` saved for A, first run `ug
configure --workspace B --agent codex`. A's registration is removed and
B's saved registration is installed, if one exists. Run `ug mcp add
--agents codex --names system.ai.github` if B has no saved selection.
Start a new Codex session to use B's tools. Running `ug configure
--workspace A --agent codex` restores A's saved URL.

## Validation

- `tests/test_mcp.py tests/test_cli.py tests/test_agent_vscode.py`:
1,023 passed locally after the review fixes.
- Workspace-switch regression covers A → B → A, including identical MCP
names with different workspace URLs, and the active workspace on first
MCP setup.
- Ruff check/format on `src/` and `tests/`, Ty check on `src/`, and `git
diff --check` passed.
- Fixed the Linux/Windows VS Code unit fixture and preserved
source-workspace managed MCP delivery state until reconciliation. The
new regression verifies removal of a stale managed fallback while
retaining destination user choices.
- Review fixes: stale entries are matched per (name, client);
restoration reads post-reconciliation state; and a saved workspace is
restored after revert leaves no active workspace. Focused regressions
cover all three.
- The preceding CI run passed Linux and Windows unit tests, the Claude
managed-config workspace-switch journey, CUJ 6 repeated config/removal,
and the full Codex Linux journey. CI for the review-fix commit is
pending.
- The earlier live staging test covered MCP registration with a
disposable HOME and unchanged machine-wide files. A live A → B → A agent
session/tool call was not rerun for this revision. LiteSwap does not
exercise local CLI/agent config paths.

BR-2276 PR databricks#1363 changes nearby MCP client detection and registration
code but has no functional dependency. Rebase it after this PR if this
merges first.
Comment thread src/ucode/mcp.py Resolved
Comment thread src/ucode/mcp.py Resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants