Skip to content

fix: add an MCP status command and report discovered-config drift - #1160

Draft
sahrizvi wants to merge 1 commit into
fix/mcp-error-diagnosticsfrom
fix/mcp-status-drift
Draft

fix: add an MCP status command and report discovered-config drift#1160
sahrizvi wants to merge 1 commit into
fix/mcp-error-diagnosticsfrom
fix/mcp-status-drift

Conversation

@sahrizvi

@sahrizvi sahrizvi commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #790
Closes #878

Stacked on #1159. Base is fix/mcp-error-diagnostics, not main — this PR's own diff is just the second commit. delete_branch_on_merge is off on this repo, so GitHub will not auto-retarget when #1159 merges: someone has to run gh pr edit 1160 --base main at that point. Until then ci.yml (which triggers only on PRs targeting main) does not run here, so this PR shows no TypeScript or Marker Guard check.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

1. Adds mcp status (#790). status is the name people reach for when a server won't connect, and it was the one name that didn't exist.

Being straight about the size of this: the gap was narrower than the issue implies. mcp list already probed live (mcp.status() initialises the MCP service) and already printed the failure reason. The missing piece was the entry point, not the view — so status shares that handler rather than duplicating a view that would then need keeping in sync.

It's a sibling command rather than an alias because aliases: ["ls", "status"] widened yargs' alias column enough to rewrap an unrelated row (mcp auth list lost its [aliases: ls] onto a second line). As its own command the help output stays additive — the diff against the committed snapshot is exactly one added line.

2. Reports discovered-config drift (#878). Discovery is first-source-wins, so a server already in the user's config is skipped outright, and a changed .vscode/mcp.json — a new ALTIMATE_EXTENSION_RPC port, a moved command — was never mentioned. driftFields() now reports which fields disagree, naming nested keys individually (environment.ALTIMATE_EXTENSION_RPC) so the message points at the thing to fix rather than just environment. enabled is excluded, since discovery sets it for its own reasons.

The configured value still wins. This reports the disagreement and where to look, and leaves the decision to the user — silently overwriting someone's own config would be worse than the silence it replaces. That's the "detect and report" option of the three the issue offered.

How did you verify your code works?

  • Full opencode suite: no regressions.
  • e2e drives the real CLI against an isolated HOME plus a temp project containing a drifted .vscode/mcp.json, asserting both that the drifted field is named and that an agreeing config stays silent.
  • Mutation-tested: disabling drift recording, or the status registration, each fails exactly one test.
  • Marker Guard passes locally against origin/main; typecheck clean.

Flaky tests, flagged rather than hidden: the subprocess-heavy suites (test/pty, test/cli/run) fail intermittently under parallel load — different tests each run, all passing across repeated isolated runs. These flakes pre-date this PR, but it does make them more likely to surface: it adds two more e2e files that each spawn real CLI subprocesses.

Test-harness fix worth knowing about: the e2e pattern copied from mcp-add.test.ts uses bun run --cwd <pkg>, which makes the CLI's working directory the repo package — so it read the repo's own .opencode config and never saw the temp project, meaning discovery never ran and the drift assertion couldn't fire. Fixed here by setting the spawn cwd to the project. mcp-add.test.ts is unaffected in practice (it passes --global), so it's left alone.

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

🤖 Generated with Claude Code

https://claude.ai/code/session_018fJ3X7pcGT4R9yzjsJnqsV

`status` is the name people reach for when a server will not connect,
and it was the one name that did not exist. The gap was narrower than it
looks: `mcp list` already probed live and already printed the failure
reason, so `status` is registered as a sibling sharing that handler
rather than a second view to keep in sync. It is a distinct command
rather than an alias because an alias widens yargs' alias column enough
to rewrap unrelated sibling rows in the help output.

MCP discovery is first-source-wins, so a server already present in the
user's config was skipped outright and a changed `.vscode/mcp.json` — a
new port, a moved command — was never mentioned. `driftFields()` now
reports which fields disagree, naming nested keys individually
(`environment.ALTIMATE_EXTENSION_RPC`) so the message points at the
thing to fix. The configured value still wins; silently overwriting a
user's own config would be worse than the silence it replaces.

Closes #790
Closes #878

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018fJ3X7pcGT4R9yzjsJnqsV
@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

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

Copy link
Copy Markdown

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

Copy link
Copy Markdown

👋 This PR was automatically closed by our quality checks.

Common reasons:

  • New GitHub account with limited contribution history
  • PR description doesn't meet our guidelines
  • Contribution appears to be AI-generated without meaningful review

If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you.

@github-actions

Copy link
Copy Markdown

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant