Skip to content

feat(cli): expand MCP editor detection coverage#883

Open
joneidejohnsen wants to merge 6 commits intomainfrom
cursor/ai-dev-tools-support-2783
Open

feat(cli): expand MCP editor detection coverage#883
joneidejohnsen wants to merge 6 commits intomainfrom
cursor/ai-dev-tools-support-2783

Conversation

@joneidejohnsen
Copy link
Copy Markdown
Contributor

@joneidejohnsen joneidejohnsen commented Apr 3, 2026

Summary

  • cross-checked sanity mcp configure editor support against Neon add-mcp and Vercel skills
  • added MCP editor detection/config support for:
    • Antigravity
    • Cline (VS Code extension)
    • Cline CLI
    • MCPorter
  • kept existing support for:
    • Claude Code
    • Codex CLI
    • Cursor
    • Gemini CLI
    • GitHub Copilot CLI
    • OpenCode
    • VS Code
    • VS Code Insiders
    • Zed
  • updated command description and README command docs to reflect the expanded supported editor set
  • added/updated tests for new editors and token extraction coverage

External comparison

Compared against:

  • Neon add-mcp supported agents list (README.md, src/agents.ts)
  • Vercel skills supported agents list (README.md, src/agents.ts)

Coverage now aligned with add-mcp

Covered in Sanity CLI after this change:

  • Antigravity
  • Cline (extension)
  • Cline CLI
  • Claude Code
  • Codex
  • Cursor
  • Gemini CLI
  • GitHub Copilot CLI
  • MCPorter
  • OpenCode
  • VS Code
  • Zed

Remaining from add-mcp not added in this PR:

  • Claude Desktop (stdio-only flow in add-mcp; not part of current HTTP tokenized Sanity MCP setup)
  • Goose (YAML config format and schema; intentionally deferred in this PR)

skills includes many additional agents, but most are skills-directory ecosystems rather than direct MCP-config targets for sanity mcp configure.

Follow-up fixes from review comments

  • updated detectClineCli to detect based on Cline home root (CLINE_DIR / ~/.cline) so fresh installs are detected before data/settings exists
  • added MCPorter test coverage for:
    • existing mcporter.json branch
    • fresh-install fallback branch (neither mcporter.json nor mcporter.jsonc exists, defaults to mcporter.json)

CI follow-up fixes

  • Fixed Gemini CLI false-positive detection by requiring ~/.gemini/settings.json (instead of only ~/.gemini)
  • Tightened MCP configure tests to avoid broad path matches that caused Windows shard flakiness:
    • made VS Code Windows test robust to additional detected editors
    • made Antigravity and Cline extension mocks path-specific
    • normalized CLINE_DIR path assertion for Windows/Unix
    • updated Gemini-related mocks to detect settings.json specifically
  • Simplified MCPorter config builder to use defaultHttpConfig directly
  • Relaxed Cline CLI path assertion for Windows to account for path-drive normalization differences in CI (\tmp\... vs C:\tmp\...)

Testing

  • pnpm --filter @sanity/cli exec vitest run src/commands/mcp/__tests__/configure.test.ts src/actions/mcp/__tests__/editorConfigs.test.ts --config vitest.config.ts
  • pnpm --filter @sanity/cli check:types
  • pnpm --filter @sanity/cli exec eslint src/actions/mcp/editorConfigs.ts src/actions/mcp/__tests__/editorConfigs.test.ts src/commands/mcp/__tests__/configure.test.ts src/commands/mcp/configure.ts ✅ (warnings only in pre-existing test import style)
  • pnpm check:format

Slack Thread

Open in Web Open in Cursor 

Co-authored-by: Jon Eide Johnsen <joneidejohnsen@gmail.com>
@claude
Copy link
Copy Markdown

claude bot commented Apr 3, 2026

Claude finished @drewlyton's task in 2m 46s —— View job


Code Review

  • Gather context
  • Read changed files
  • Analyze for issues
  • Post review

Two issues found:

1. APPDATA env cleanup leaves stale value on non-Windows CI

configure.test.ts:251

process.env.APPDATA = originalAppData  // originalAppData is `undefined` on Linux/macOS

process.env.X = undefined sets the key to the string "undefined", not unset. Any subsequent test that mocks platform = 'win32' and calls getVSCodeUserDir() will see process.env.APPDATA = "undefined" (truthy), causing it to return path.join("undefined", "Code/User") — potentially triggering unexpected VS Code detection.

Fix: Fix this →

if (originalAppData === undefined) {
  delete process.env.APPDATA
} else {
  process.env.APPDATA = originalAppData
}

2. detectCline only checks stable VS Code path

editorConfigs.ts:70

async function detectCline(): Promise<string | null> {
  const vscodeUserDir = getVSCodeUserDir()  // only 'stable'

Cline installed in VS Code Insiders stores its settings at the Insiders path (Code - Insiders/User/globalStorage/...), which is never checked. If this is intentional (i.e. Cline is targeted at stable VS Code users only), a comment would help clarify. Otherwise, a fallback to getVSCodeUserDir('insiders') when the stable path yields no result would cover Insiders users.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 3, 2026

📦 Bundle Stats — @sanity/cli

Compared against main (9748ee93)

@sanity/cli

Metric Value vs main (9748ee9)
Internal (raw) 2.1 KB -
Internal (gzip) 799 B -
Bundled (raw) 10.95 MB -
Bundled (gzip) 2.06 MB -
Import time 837ms -9ms, -1.1%

bin:sanity

Metric Value vs main (9748ee9)
Internal (raw) 975 B -
Internal (gzip) 460 B -
Bundled (raw) 9.84 MB -
Bundled (gzip) 1.77 MB -
Import time 1.99s -11ms, -0.5%

🗺️ 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 (9748ee93)

Metric Value vs main (9748ee9)
Internal (raw) 92.3 KB -
Internal (gzip) 21.6 KB -
Bundled (raw) 21.53 MB -
Bundled (gzip) 3.41 MB -
Import time 802ms -2ms, -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 (9748ee93)

Metric Value vs main (9748ee9)
Internal (raw) 976 B -
Internal (gzip) 507 B -
Bundled (raw) 50.7 KB -
Bundled (gzip) 12.6 KB -
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.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 3, 2026

Coverage Delta

File Statements
packages/@sanity/cli/src/actions/mcp/editorConfigs.ts 86.4% (+ 10.7%)
packages/@sanity/cli/src/commands/mcp/configure.ts 90.0% (±0%)

Comparing 2 changed files against main @ 9748ee937875ac5832595e0632a478a13d55776e

Overall Coverage

Metric Coverage
Statements 83.2% (+ 0.1%)
Branches 73.0% (+ 0.1%)
Functions 83.4% (+ 0.1%)
Lines 83.6% (+ 0.1%)

…#886)

Introduce EDITOR_DEFAULTS constant with the most common EditorConfig
values (defaultHttpConfig, mcpServers, jsonc, readTokenFromHeaders).
Each EDITOR_CONFIGS entry now spreads the defaults and only declares
detect + any overrides, making deviations immediately visible.

Remove 5 pass-through buildServerConfig wrappers that just returned
defaultHttpConfig(token): buildClaudeCodeServerConfig,
buildCursorServerConfig, buildGeminiCliServerConfig,
buildVSCodeServerConfig, buildVSCodeInsidersServerConfig.

Reduces editorConfigs.ts from 350 to 267 lines with no behavioral
change.
@joneidejohnsen joneidejohnsen marked this pull request as ready for review April 6, 2026 19:43
@joneidejohnsen joneidejohnsen requested a review from a team as a code owner April 6, 2026 19:43
@joneidejohnsen joneidejohnsen requested review from cngonzalez and removed request for a team April 6, 2026 19:43
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.

3 participants