fix(mcp): show all editors and treat selection as desired state#1144
fix(mcp): show all editors and treat selection as desired state#1144runeb wants to merge 1 commit into
Conversation
Closes AIGRO-4989
|
Claude finished @runeb's task in 3m 23s —— View job ReviewA few small things to consider; nothing blocking. Test coverage gaps
Test fixtures
Behavior
Changeset — looks fine. Patch bump matches a UX-only fix; summary is one user-facing sentence in developer voice. Could split the semicolon clause for readability but not required.
|
📦 Bundle Stats —
|
| Metric | Value | vs main (7d2118d) |
|---|---|---|
| Internal (raw) | 2.1 KB | - |
| Internal (gzip) | 799 B | - |
| Bundled (raw) | 10.97 MB | - |
| Bundled (gzip) | 2.06 MB | - |
| Import time | 841ms | -7ms, -0.9% |
bin:sanity
| Metric | Value | vs main (7d2118d) |
|---|---|---|
| Internal (raw) | 1023 B | - |
| Internal (gzip) | 486 B | - |
| Bundled (raw) | 9.87 MB | - |
| Bundled (gzip) | 1.77 MB | - |
| Import time | 1.98s | +2ms, +0.1% |
🗺️ View treemap · Artifacts
Details
- Import time regressions over 10% are flagged with
⚠️ - Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.
📦 Bundle Stats — @sanity/cli-core
Compared against main (7d2118d4)
| Metric | Value | vs main (7d2118d) |
|---|---|---|
| Internal (raw) | 96.3 KB | - |
| Internal (gzip) | 22.7 KB | - |
| Bundled (raw) | 21.64 MB | - |
| Bundled (gzip) | 3.43 MB | - |
| Import time | 808ms | +1ms, +0.2% |
🗺️ View treemap · Artifacts
Details
- Import time regressions over 10% are flagged with
⚠️ - Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.
📦 Bundle Stats — create-sanity
Compared against main (7d2118d4)
| Metric | Value | vs main (7d2118d) |
|---|---|---|
| Internal (raw) | 908 B | - |
| Internal (gzip) | 483 B | - |
| Bundled (raw) | 931 B | - |
| Bundled (gzip) | 491 B | - |
| Import time | ❌ ChildProcess denied: node | - |
Details
- Import time regressions over 10% are flagged with
⚠️ - Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.
Coverage Delta
Comparing 8 changed files against main @ Overall Coverage
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes 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 ce008ce. Configure here.
| const validEditor = editors.find((e) => e.authStatus === 'valid' && e.existingToken) | ||
| if (validEditor?.existingToken) { | ||
| mcpDebug('Reusing valid token from %s', validEditor.name) | ||
| token = validEditor.existingToken |
There was a problem hiding this comment.
Token creation failure silently skips pending editor removals
Medium Severity
When createMCPToken() fails, the early return at line 117 skips processing editorsToRemove, reporting removedEditors: []. Removal is a purely local file operation that doesn't need a token, so deselected editors could still have their Sanity entries removed. This silently drops the user's explicit intent to remove a configuration. The scenario is reachable when the only configured editor is oauthOnly (e.g. Cursor) — it has no existingToken, so no reusable token is found, and token creation is attempted for a newly-selected non-oauthOnly editor.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit ce008ce. Configure here.


Now
sanity mcp configure(and thesanity initstep) lists every detected editor, pre-checked by its current state. The selection is the desired final state: selecting an editor writes/updates its config, deselecting a configured one removes its Sanity entry.Tested: targeted unit tests for prompt labels, setup orchestration (add/remove/no-op + per-editor error handling), and the new
removeMCPConfig.Closes AIGRO-4989
Note
Medium Risk
The CLI reads and rewrites local editor MCP config files (including bearer tokens) and can delete Sanity entries; behavior is well covered by tests but mis-edits could affect developer tooling setup.
Overview
sanity mcp configure(and the init MCP step) now treats the checkbox list as the desired end state: every detected editor is shown, pre-checked only if it is already configured, and the prompt always runs when editors exist (including when everything already looks valid).Selecting an editor writes or updates its Sanity MCP entry; deselecting one that was configured removes only the Sanity server from that editor’s JSONC/TOML config via new
removeMCPConfig, leaving other MCP servers and JSONC comments intact.writeMCPConfigskips disk writes when the existing Sanity block already matches (canonical compare) and returns whether a write happened, sosetupMCPcan distinguish newly configured vs already configured editors.Orchestration now applies adds and removals per editor with continued processing on partial failures, surfaces
removedEditorsin CLI output and telemetry, and adjusts labels (e.g. OAuth-only editors as “(configured)” rather than “missing credentials”).Reviewed by Cursor Bugbot for commit ce008ce. Bugbot is set up for automated code reviews on this repo. Configure here.