Skip to content

Conversation

dsarno
Copy link
Collaborator

@dsarno dsarno commented Aug 13, 2025

Summary

Makes setup far more self‑serve. Adds Claude Code binary picker with NVM auto‑detection, gates Cursor/Windsurf on uv with an inline help flow, and updates VSCode to the new mcp.json top‑level servers schema. Robust parsing prevents bad states and avoids cross‑client status mix‑ups.

Addresses #195 , #204, #205, possibly #189.

What changed

  • Claude Code (claude CLI)
    • Dynamic “Claude Not Found” state with orange inline help link and “Choose Claude Install Location”
    • Auto‑register after picking the binary; persist override between sessions
    • NVM auto‑detection of claude under ~/.nvm/versions/node/*/bin (pick newest)
    • Removed “Auto‑connect to MCP Clients” toggle; simplified to Register/Unregister once found
  • Cursor/Windsurf (uv gating)
    • If uv missing: red “uv Not Found”, orange help link to troubleshooting, single “Choose UV Install Location” button
    • Saving a uv path persists and immediately attempts configure
    • Hide config filename until uv is available
  • VSCode GitHub Copilot
    • Switch to new config path: ~/Library/Application Support/Code/User/mcp.json (mac), %APPDATA%/Code/User/mcp.json (Windows)
    • Write new schema: top‑level servers.unityMCP with "type": "stdio"
    • Read both new (servers) and legacy (mcp.servers) for back‑compat
    • Robust parse/merge: empty files initialize silently; warn only when non‑empty and invalid JSON encountered
  • Status isolation
    • Each client’s status is determined only from its own config; deleting Claude Desktop’s file no longer flips VSCode to “Missing Unity MCP Config”

Why

  • Many users launch Unity from Finder/Hub, so PATH‑based discovery fails (macOS GUI env mismatch).
  • NVM installs of Claude Code are common and not found by default PATH in Unity; adding a picker and NVM scan removes friction.
  • Cursor/Windsurf require uv; gating with a single, guided fix prevents confusing partial states.
  • VSCode moved to mcp.json and a new schema; writing/reading the right shape avoids config breakage.

How to verify

  • Claude Code
    1. Ensure claude is NOT on PATH; open Window > Unity MCP; select Claude Code → see “Claude Not Found” with help and “Choose Claude Install Location”.
    2. Pick ~/.nvm/versions/node/<ver>/bin/claude → status turns green and Register/Unregister button appears; picker hidden.
  • Cursor/Windsurf
    1. Temporarily rename/move uv; open Window > Unity MCP; pick Cursor/Windsurf → see “uv Not Found”, help, and “Choose UV Install Location”.
    2. Pick the uv binary; status/config updates and normal controls reappear.
  • VSCode
    1. Confirm config written to Code/User/mcp.json with:
      {
        "servers": {
          "unityMCP": {
            "command": "uv",
            "args": ["--directory", "<UnityMcpServer/src>", "run", "server.py"],
            "type": "stdio"
          }
        }
      }
    2. If mcp.json is empty, Auto Configure should populate it without warnings.
    3. If legacy mcp.servers exists, read‑back should still show “Configured”.
  • Cross‑client isolation
    1. Delete only the Claude Desktop config file; Claude Desktop shows missing, VSCode remains “Configured”.

Scope

  • Code only:
    • UnityMcpBridge/Editor/Windows/UnityMcpEditorWindow.cs
    • UnityMcpBridge/Editor/Data/McpClients.cs
    • UnityMcpBridge/Editor/Models/MCPConfigServer.cs
  • No breaking API changes; VSCode config schema updated intentionally to match its latest format.

Summary by CodeRabbit

  • New Features

    • Detect Claude CLI in NVM-managed Node installs (macOS/Linux) and show resolved Claude path; add UI to set/clear a custom Claude CLI path.
    • VSCode config now writes unityMCP under top-level servers with type=stdio while keeping legacy support.
    • Pre-checks and installer guidance for missing Claude/UV, with pickers, help links and contextual UI hints.
  • Refactor

    • Removed Auto-connect toggle; first-run/setup flow adjusted accordingly.
  • Chores

    • Bumped package version to 2.0.2.

dsarno added 2 commits August 12, 2025 19:04
…inline help link; NVM auto-detection; path picker override; hide picker after detection; remove auto-connect toggle.
…io; robust parse/merge; Cursor/Windsurf UV gating UI; Claude Code UX polish and NVM detection
Copy link
Contributor

coderabbitai bot commented Aug 13, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Updates change VSCode MCP config schema/path, add a new type field to MCP server config, extend Claude CLI resolution (NVM lookup + EditorPrefs overrides), modify editor UI to perform Claude/UV readiness checks and write resilient JSON, and bump package version to 2.0.2.

Changes

Cohort / File(s) Summary
VSCode Copilot config path update
UnityMcpBridge/Editor/Data/McpClients.cs
Copilot config filename changed from settings.json to mcp.json for Windows and Linux paths.
Claude CLI resolution & overrides
UnityMcpBridge/Editor/Helpers/ExecPath.cs
Added ResolveClaudeFromNvm(home) to locate Claude under ~/.nvm/versions/node/*/bin/claude; integrated NVM check into macOS/Linux ResolveClaude flow before PATH lookup; added SetClaudeCliPath(string) and ClearClaudeCliPath() EditorPrefs overrides; guarded with null checks and try/catch.
MCP server type field
UnityMcpBridge/Editor/Models/MCPConfigServer.cs
Added public string type serialized as "type" (NullValueHandling.Ignore) for VSCode transport type.
Editor window config & UI flow
UnityMcpBridge/Editor/Windows/UnityMcpEditorWindow.cs
Removed Auto-connect toggle and persistence; added Claude/UV pre-checks, install hints, pickers, and Register/Unregister flows; hide quick-info when tools missing; show Claude path when found; prefer top-level servers.unityMCP (fallback to legacy mcp.servers.unityMCP); initialize VSCode unityMCP config with type = "stdio"; made JSON parsing/merge resilient with guarded parse and fallback.
Version bump
UnityMcpBridge/package.json
Package version updated from 2.0.1 to 2.0.2.

Sequence Diagram(s)

sequenceDiagram
  participant UI as UnityMcpEditorWindow
  participant Exec as ExecPath
  participant FS as FileSystem
  participant VS as VSCode config file

  UI->>Exec: ResolveClaude()
  alt macOS/Linux
    Exec->>Exec: check common locations
    Exec->>Exec: ResolveClaudeFromNvm(~/.nvm/versions/node/*/bin/claude)
    Exec->>Exec: Which("claude") if not found
  else Windows
    Exec->>Exec: PATH/common checks
  end
  Exec-->>UI: Claude path or null

  UI->>UI: Check UV if required
  alt Missing Claude or UV
    UI-->>UI: Show install hint + picker (early return)
  else Ready
    UI->>FS: Read existing VSCode JSON (guarded parse)
    UI->>UI: Build unityMCP config (include type="stdio" for VSCode)
    UI->>VS: Write to config.servers.unityMCP (fallback to mcp.servers.unityMCP)
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~35 minutes

Possibly related PRs

Suggested labels

bug

Poem

I twitch my ears at configs new,
I sniff for Claude in NVM's dew.
I hop to servers, type "stdio",
I pick the path and fix the view.
2.0.2 — a crunchy carrot true 🥕🐇


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a52ce7a and b09a86f.

📒 Files selected for processing (1)
  • UnityMcpBridge/Editor/Windows/UnityMcpEditorWindow.cs (9 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

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

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🔭 Outside diff range comments (1)
UnityMcpBridge/Editor/Windows/UnityMcpEditorWindow.cs (1)

943-948: Fix inconsistency with MCPConfigServer.type initialization.

The type field is set here but the model has both a default value and NullValueHandling.Ignore, creating an inconsistency.

This relates to the issue raised in MCPConfigServer.cs. Once that's resolved, ensure this initialization aligns with the chosen approach.

🧹 Nitpick comments (1)
UnityMcpBridge/Editor/Helpers/ExecPath.cs (1)

124-134: Add logging for SetClaudeCliPath failures.

The method silently fails if the path doesn't exist, which could confuse users who selected an incorrect file.

Apply this diff to provide user feedback:

         internal static void SetClaudeCliPath(string absolutePath)
         {
             try
             {
                 if (!string.IsNullOrEmpty(absolutePath) && File.Exists(absolutePath))
                 {
                     EditorPrefs.SetString(PrefClaude, absolutePath);
                 }
+                else if (!string.IsNullOrEmpty(absolutePath))
+                {
+                    UnityEngine.Debug.LogWarning($"Claude CLI path does not exist: {absolutePath}");
+                }
             }
             catch { }
         }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 86198a0 and eb7b2e9.

📒 Files selected for processing (5)
  • UnityMcpBridge/Editor/Data/McpClients.cs (1 hunks)
  • UnityMcpBridge/Editor/Helpers/ExecPath.cs (3 hunks)
  • UnityMcpBridge/Editor/Models/MCPConfigServer.cs (1 hunks)
  • UnityMcpBridge/Editor/Windows/UnityMcpEditorWindow.cs (9 hunks)
  • UnityMcpBridge/package.json (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
UnityMcpBridge/Editor/Data/McpClients.cs (4)
UnityMcpBridge/Editor/Windows/VSCodeManualSetupWindow.cs (3)
  • UnityMcpBridge (6-295)
  • VSCodeManualSetupWindow (8-294)
  • ShowWindow (10-25)
UnityMcpBridge/Editor/Windows/ManualConfigEditorWindow.cs (2)
  • ManualConfigEditorWindow (9-276)
  • UnityMcpBridge (6-277)
UnityMcpBridge/Editor/Models/McpClient.cs (2)
  • UnityMcpBridge (1-46)
  • McpClient (3-45)
UnityMcpBridge/Editor/Models/McpConfig.cs (1)
  • UnityMcpBridge (4-12)
UnityMcpBridge/Editor/Models/MCPConfigServer.cs (4)
UnityMcpBridge/Editor/Models/McpConfig.cs (2)
  • UnityMcpBridge (4-12)
  • Serializable (6-11)
UnityMcpBridge/Editor/Models/ServerConfig.cs (2)
  • UnityMcpBridge (4-36)
  • Serializable (6-35)
UnityMcpBridge/Editor/Models/MCPConfigServers.cs (2)
  • UnityMcpBridge (4-12)
  • Serializable (6-11)
UnityMcpBridge/Editor/Data/DefaultServerConfig.cs (1)
  • UnityMcpBridge (3-17)
🔇 Additional comments (8)
UnityMcpBridge/package.json (1)

3-3: LGTM! Version bump aligns with the PR's significant changes.

The version increment from 2.0.1 to 2.0.2 appropriately reflects the bug fixes and UX improvements introduced in this PR.

UnityMcpBridge/Editor/Data/McpClients.cs (1)

90-90: Config path change aligns with VSCode's new MCP schema.

The update from settings.json to mcp.json is correct and matches VSCode's updated configuration structure.

Also applies to: 98-98

UnityMcpBridge/Editor/Windows/UnityMcpEditorWindow.cs (6)

693-702: Good pre-validation for Claude CLI availability.

The early check for Claude CLI presence and appropriate status update improves the user experience by providing clear feedback.


704-716: Excellent UV dependency gating implementation.

The pre-check for UV availability with appropriate status updates prevents confusing error states downstream.


732-747: Clear and actionable UI feedback for missing Claude CLI.

The orange hint with a direct link to troubleshooting documentation provides excellent user guidance.


967-987: Robust JSON parsing with proper error recovery.

Excellent implementation that gracefully handles empty files and invalid JSON while providing appropriate warnings.


994-1005: Correct implementation of new VSCode top-level servers schema.

The code properly creates the servers object if missing and updates the unityMCP configuration correctly.


1369-1383: Excellent backward compatibility for VSCode config.

The code correctly checks both the new top-level servers schema and the legacy mcp.servers structure, ensuring smooth migration.

… NVM version parse robustness; help labels [HELP]
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
UnityMcpBridge/Editor/Windows/UnityMcpEditorWindow.cs (1)

1053-1075: Fix hardcoded uv path in manual configuration.

This code uses the resolved UV path correctly, addressing the previous review comment about hardcoded "uv" usage. The error handling when UV is not found is also appropriate.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eb7b2e9 and a52ce7a.

📒 Files selected for processing (3)
  • UnityMcpBridge/Editor/Helpers/ExecPath.cs (3 hunks)
  • UnityMcpBridge/Editor/Models/MCPConfigServer.cs (1 hunks)
  • UnityMcpBridge/Editor/Windows/UnityMcpEditorWindow.cs (9 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • UnityMcpBridge/Editor/Helpers/ExecPath.cs
  • UnityMcpBridge/Editor/Models/MCPConfigServer.cs
🧰 Additional context used
🧬 Code Graph Analysis (1)
UnityMcpBridge/Editor/Windows/UnityMcpEditorWindow.cs (4)
UnityMcpBridge/Editor/Helpers/ExecPath.cs (3)
  • ExecPath (11-267)
  • ResolveClaude (16-85)
  • SetClaudeCliPath (131-141)
UnityMcpBridge/Editor/Windows/VSCodeManualSetupWindow.cs (1)
  • VSCodeManualSetupWindow (8-294)
UnityMcpBridge/Editor/Windows/ManualConfigEditorWindow.cs (1)
  • ManualConfigEditorWindow (9-276)
UnityMcpBridge/Editor/Models/McpClient.cs (1)
  • McpClient (3-45)
🔇 Additional comments (10)
UnityMcpBridge/Editor/Windows/UnityMcpEditorWindow.cs (10)

441-441: LGTM! Design improvement aligns with PR objectives.

The removal of the auto-connect toggle simplifies the UI and follows the PR's design note to use Register/Unregister buttons when clients are found, which is a cleaner user experience.


693-717: Excellent pre-check implementation for Claude Code and UV dependencies.

The early detection of missing dependencies with clear status updates prevents confusing UI states and provides immediate feedback to users about what needs to be installed.


731-747: Great user guidance for missing Claude CLI.

The orange hint with direct link to troubleshooting documentation provides excellent user experience for resolving installation issues.


751-788: Well-implemented UV installation guidance with early return.

The UI correctly shows installation hints and provides a picker for UV location, then returns early to avoid rendering confusing controls when UV is missing. The immediate configuration after path selection is a nice touch.


800-850: Smart conditional UI flow for Claude Code configuration.

The logic properly handles both available and missing Claude CLI states with appropriate button text and actions. The auto-registration after path selection streamlines the user experience.


904-916: Logical hiding of config info when dependencies are missing.

Hiding the config path when Claude CLI or UV is missing reduces user confusion and keeps the UI clean until the prerequisites are met.


967-987: Robust JSON parsing with proper error handling.

The enhanced error handling for malformed JSON files is well-implemented. It gracefully handles empty files and provides appropriate warnings for invalid JSON while ensuring the configuration process continues.


994-1005: Correct implementation of new VSCode schema structure.

The switch to top-level servers.unityMCP structure aligns with the PR objectives for VSCode configuration changes while maintaining clean code organization.


1379-1391: Excellent backward compatibility implementation.

The dual schema support correctly checks the new servers.unityMCP path first, then falls back to the legacy mcp.servers.unityMCP format, ensuring existing configurations continue to work while supporting the new schema.


69-73: Verify Claude CLI dependency for auto-setup.

The auto-setup now only runs when Claude CLI is available, which makes sense for the workflow. However, this might limit auto-setup for users who primarily use other clients like VSCode or Cursor.

Consider whether this change might impact users who don't use Claude Code but want auto-setup for other clients. The original logic might have been more inclusive.

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.

1 participant