Skip to content

Comments

fix: speed up Claude Code config check by reading JSON directly#682

Merged
dsarno merged 8 commits intoCoplayDev:betafrom
dsarno:fix/claude-code-fast-config-check
Feb 3, 2026
Merged

fix: speed up Claude Code config check by reading JSON directly#682
dsarno merged 8 commits intoCoplayDev:betafrom
dsarno:fix/claude-code-fast-config-check

Conversation

@dsarno
Copy link
Collaborator

@dsarno dsarno commented Feb 3, 2026

Summary

  • Instead of running claude mcp list (15+ seconds due to health checks on every configured server), read the config directly from ~/.claude.json (instant)
  • Walk up directory tree to find config when Unity project is in a subdirectory of the configured Claude Code project
  • Handle duplicate path entries (forward/backslash path variants in config)
  • Add beta/stable version mismatch detection with clearer error messages

Problem

The Claude Code configurator was calling claude mcp list which performs health checks on all MCP servers, taking 15+ seconds. This made the status check extremely slow and sometimes timeout.

Solution

Read ~/.claude.json directly and parse the JSON to find the UnityMCP configuration. This is instant and provides all the same information.

Test plan

  • Open MCP window in Unity - status check should be instant
  • Verify "Configured" status shows correctly when UnityMCP is registered
  • Verify "Not Configured" status shows when UnityMCP is not registered
  • Verify version mismatch detection works

🤖 Generated with Claude Code

Summary by Sourcery

Speed up Claude Code Unity MCP status checks by reading configuration directly from the local JSON config instead of invoking the CLI, while improving transport/version validation.

New Features:

  • Detect Claude Code UnityMCP registration and configuration by parsing the ~/.claude.json config file with project-directory-aware lookup.
  • Identify beta versus stable package source mismatches for the UnityMCP stdio server and report clearer mismatch reasons.

Enhancements:

  • Replace slow CLI-based MCP status checks with direct JSON config inspection to make status evaluation effectively instant.
  • Normalize project paths and handle duplicate/variant path entries when resolving the relevant Claude Code project configuration.
  • Refine mismatch handling logic to auto-reregister when possible and surface clearer error messages for transport and version mismatches.

Summary by CodeRabbit

  • New Features

    • Automatic re-registration when a version/source mismatch is detected.
    • New client mismatch event surfaced to the UI.
    • Visible version-mismatch warning banner in the connection UI.
  • Improvements

    • Beta-aware package/source validation and clearer mismatch messaging.
    • Instant local config detection and immediate status refresh when switching panels or toggling Beta.
    • UI text updates: "Configure"/"Configuring...".

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Feb 3, 2026

Reviewer's Guide

Replaces the slow CLI-based Claude MCP status check with a direct read of ~/.claude.json, adding JSON-based project lookup (with path normalization, directory walking, and duplicate handling) plus clearer transport/version mismatch detection, including beta vs stable differentiation.

Sequence diagram for Claude MCP status check using JSON config

sequenceDiagram
    actor UnityDeveloper
    participant UnityEditor
    participant McpClientConfiguratorBase
    participant FileSystem

    UnityDeveloper->>UnityEditor: Open MCP window
    UnityEditor->>McpClientConfiguratorBase: CheckStatusWithProjectDir(projectDir, useHttpTransport, expectedPackageSource)

    McpClientConfiguratorBase->>McpClientConfiguratorBase: ReadClaudeCodeConfig(projectDir)
    activate McpClientConfiguratorBase
    McpClientConfiguratorBase->>FileSystem: Read ~/.claude.json
    FileSystem-->>McpClientConfiguratorBase: config or error

    alt Config read error
        McpClientConfiguratorBase-->>UnityEditor: status = NotConfigured, error
    else UnityMCP not found in config
        McpClientConfiguratorBase-->>UnityEditor: status = NotConfigured
    else UnityMCP found
        McpClientConfiguratorBase->>McpClientConfiguratorBase: Determine registered transport type
        McpClientConfiguratorBase->>McpClientConfiguratorBase: Compare with useHttpTransport
        McpClientConfiguratorBase->>McpClientConfiguratorBase: ExtractPackageSourceFromConfig(serverConfig)
        McpClientConfiguratorBase->>McpClientConfiguratorBase: IsBetaPackageSource(configured)
        McpClientConfiguratorBase->>McpClientConfiguratorBase: IsBetaPackageSource(expected)
        McpClientConfiguratorBase->>McpClientConfiguratorBase: Detect transport/version mismatch

        alt Mismatch and auto rewrite allowed
            McpClientConfiguratorBase->>McpClientConfiguratorBase: SetStatus(IncorrectPath)
            McpClientConfiguratorBase->>McpClientConfiguratorBase: Configure()
            McpClientConfiguratorBase-->>UnityEditor: status after reconfigure
        else Mismatch but no auto rewrite
            McpClientConfiguratorBase->>McpClientConfiguratorBase: SetStatus(Error or IncorrectPath with message)
            McpClientConfiguratorBase-->>UnityEditor: mismatched status
        else No mismatch
            McpClientConfiguratorBase->>McpClientConfiguratorBase: SetStatus(Configured)
            McpClientConfiguratorBase-->>UnityEditor: status = Configured
        end
    end
    deactivate McpClientConfiguratorBase
Loading

Updated class diagram for McpClientConfiguratorBase configuration logic

classDiagram
    class McpClientConfiguratorBase {
        - Models.ConfiguredTransport configuredTransport
        + McpStatus CheckStatusWithProjectDir(string projectDir, bool useHttpTransport, string expectedPackageSource, bool attemptAutoRewrite, bool isRemoteScope, RuntimePlatform platform)
        + void Configure()
        + void SetStatus(McpStatus status)
        + void SetStatus(McpStatus status, string message)
        - static JObject serverConfig
        - static string error
        - static JObject ReadClaudeCodeConfig(string projectDir)
        - static string NormalizePath(string path)
        - static string ExtractPackageSourceFromConfig(JObject serverConfig)
        - static bool IsBetaPackageSource(string packageSource)
        - static string ExtractPackageSourceFromCliOutput(string cliOutput)
    }

    class McpClient {
        + McpStatus status
        + Models.ConfiguredTransport configuredTransport
        + void SetStatus(McpStatus status)
        + void SetStatus(McpStatus status, string message)
    }

    class McpLog {
        + static void Info(string message)
        + static void Warn(string message)
    }

    class Models_ConfiguredTransport {
        <<enumeration>>
        Http
        HttpRemote
        Stdio
        Unknown
    }

    class McpStatus {
        <<enumeration>>
        Configured
        NotConfigured
        IncorrectPath
        Error
    }

    McpClientConfiguratorBase o-- McpClient : client
    McpClientConfiguratorBase ..> McpLog : logging
    McpClientConfiguratorBase ..> Models_ConfiguredTransport : sets
    McpClientConfiguratorBase ..> McpStatus : sets
    McpClient --> Models_ConfiguredTransport
    McpClient --> McpStatus
Loading

File-Level Changes

Change Details Files
Replace claude mcp list / mcp get-based status detection with direct JSON config reading from ~/.claude.json and adapt status handling logic.
  • Remove platform-specific PATH prepend and CLI invocations for claude mcp list and claude mcp get.
  • Introduce ReadClaudeCodeConfig to parse ~/.claude.json, find the relevant project (walking up parent directories), and return the UnityMCP server config or an error.
  • Wire CheckStatusWithProjectDir to call ReadClaudeCodeConfig, treating missing config or missing UnityMCP as NotConfigured and surfacing read/parse errors via status messages.
  • Preserve the existing configured/unconfigured status semantics while skipping slow health checks.
MCPForUnity/Editor/Clients/McpClientConfiguratorBase.cs
Derive configured transport and version directly from JSON config, with improved mismatch detection and messaging (including beta vs stable).
  • Determine registered transport type (http vs stdio) from the type field in the UnityMCP server JSON and set client.configuredTransport accordingly, including HttpRemote inference from scope.
  • Compute transport mismatch between current settings and registered config, and use the mismatch to drive auto-rewrite behavior and status/error messages.
  • Extract the package source for stdio servers from the JSON args array via ExtractPackageSourceFromConfig, replacing CLI output parsing.
  • Add IsBetaPackageSource helper to detect beta package strings (PyPI beta versions and git beta references) and build more specific mismatch reasons for beta/stable differences.
  • Reuse existing auto-rewrite flow (Configure() re-register) but enrich log and user-facing messages with beta/stable mismatch context and maintain fallback error handling when auto-rewrite fails.
MCPForUnity/Editor/Clients/McpClientConfiguratorBase.cs
Add JSON-config utilities for path normalization and project lookup robustness.
  • Introduce NormalizePath to canonicalize project paths for comparison (slash normalization and trailing slash removal).
  • When reading projects from ~/.claude.json, build a dictionary keyed by normalized paths, letting later entries overwrite earlier ones to handle duplicate entries with different slash styles.
  • Implement directory-walk logic in ReadClaudeCodeConfig so that a Unity project in a subdirectory can still match a Claude Code project configured at a parent directory, stopping at the first matching project (or when UnityMCP is absent).
MCPForUnity/Editor/Clients/McpClientConfiguratorBase.cs

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 3, 2026

📝 Walkthrough

Walkthrough

Reads Claude Code config from ~/.claude.json, derives registered transport and package source, adds beta-aware package-source validation and version-mismatch detection, exposes VersionMismatch status and client-config mismatch events, and can auto-reconfigure on the main thread when allowed.

Changes

Cohort / File(s) Summary
Core configurator
MCPForUnity/Editor/Clients/McpClientConfiguratorBase.cs
Adds ReadClaudeCodeConfig, NormalizePath, ExtractPackageSourceFromConfig, GetExpectedPackageSourceForValidation, IsBetaPackageSource; computes configuredTransport (Http/HttpRemote/Stdio/Unknown), performs beta-aware package-source validation, tracks hasVersionMismatch/mismatchReason, and implements main-thread re-registration when possible.
Claude configurator UI text
MCPForUnity/Editor/Clients/Configurators/ClaudeCodeConfigurator.cs
Adjusts installation/action wording from "Register" → "Configure" to reflect the configure-based workflow.
Claude config helpers
MCPForUnity/Editor/Clients/...
Introduces thread-safe helpers to parse ~/.claude.json, extract --from package source, and normalize paths for cross-platform comparisons.
Models & status
MCPForUnity/Editor/Models/McpStatus.cs, MCPForUnity/Editor/Models/McpClient.cs
Adds VersionMismatch enum member; maps display string and surfaces mismatch details in SetStatus.
Client config UI
MCPForUnity/Editor/Windows/Components/ClientConfig/McpClientConfigSection.cs
Adds public event Action<string,string> OnClientConfigMismatch; treats VersionMismatch as a warning and emits mismatch messages to the UI.
Connection UI & layout
MCPForUnity/Editor/Windows/Components/Connection/McpConnectionSection.cs, .../McpConnectionSection.uxml
Adds version-mismatch-warning banner and version-mismatch-text; adds UpdateVersionMismatchWarning(string,string) and ClearVersionMismatchWarning() APIs and show/hide logic.
Editor window wiring
MCPForUnity/Editor/Windows/MCPForUnityEditorWindow.cs
Wires OnClientConfigMismatch to update connection banner; forces immediate client refresh on Beta toggle and when switching to Clients panel.

Sequence Diagram(s)

sequenceDiagram
    participant UI as Editor UI
    participant Config as McpClientConfiguratorBase
    participant File as ~/.claude.json
    participant Main as Main Thread (Configure)

    UI->>Config: Refresh status (forceImmediate)
    Config->>File: ReadClaudeCodeConfig(projectDir)
    File-->>Config: ClaudeCode JSON (stdio args / --from)
    Config->>Config: NormalizePath / ExtractPackageSourceFromConfig
    Config->>Config: Determine configuredTransport, expectedPackageSource
    alt transport or version mismatch detected
        Config-->>UI: Report VersionMismatch + mismatchReason via OnClientConfigMismatch
        opt auto-rewrite allowed
            UI->>Main: Invoke Configure()
            Main->>Config: Configure()
            Config-->>UI: Status -> Configuring... -> Configured/NotConfigured
        end
    else no mismatch
        Config-->>UI: Report Configured/NotConfigured
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Suggested labels

bug

Suggested reviewers

  • msanatan

Poem

🐰 I hopped through JSON, not a CLI in view,
I sniffed the transport and checked versions too.
If sources differ, I tap a gentle re-run,
I show a little banner until the runs are done.
Tiny rabbit, keeping configs true. 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 44.83% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and clearly summarizes the main change: replacing slow CLI calls with direct JSON file reading to speed up Claude Code config checks.
Description check ✅ Passed The description includes Summary, Problem, Solution, and Test Plan sections aligned with the template's intent, though the formal template structure (Type of Change checkbox, Changes Made list) is not strictly followed.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Consider treating a missing ~/.claude.json as a normal "not configured" case (e.g., returning (null, null)) rather than an error string, so the UI/state continues to distinguish between "no Claude Code installed" and actual config read/parsing failures.
  • ReadClaudeCodeConfig is now called on every status check and always re-reads/parses the JSON file; you might want to add simple caching (e.g., by path + last-write time) to avoid repeated disk IO and JSON parsing when the config hasn’t changed.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider treating a missing ~/.claude.json as a normal "not configured" case (e.g., returning (null, null)) rather than an error string, so the UI/state continues to distinguish between "no Claude Code installed" and actual config read/parsing failures.
- ReadClaudeCodeConfig is now called on every status check and always re-reads/parses the JSON file; you might want to add simple caching (e.g., by path + last-write time) to avoid repeated disk IO and JSON parsing when the config hasn’t changed.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Instead of running `claude mcp list` (15+ seconds due to health checks),
read the config directly from ~/.claude.json (instant).

Changes:
- Add ReadClaudeCodeConfig() to parse Claude's JSON config file
- Walk up directory tree to find config at parent directories
- Handle duplicate path entries (forward/backslash variants)
- Add beta/stable version mismatch detection with clear messages
- Add IsBetaPackageSource() to detect PyPI beta versions and prerelease ranges
- Change button label from "Register" to "Configure" for consistency

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@dsarno dsarno force-pushed the fix/claude-code-fast-config-check branch from ddcc053 to 3ecee71 Compare February 3, 2026 21:46
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: 2

🤖 Fix all issues with AI agents
In `@MCPForUnity/Editor/Clients/McpClientConfiguratorBase.cs`:
- Around line 1082-1116: The ExtractPackageSourceFromConfig method misses args
formatted as "--from=VALUE"; update the parsing in
ExtractPackageSourceFromConfig to also detect arguments that start with
"--from=" by checking argStr.StartsWith("--from=") and returning the substring
after the '=' (trim surrounding quotes/whitespace), while keeping the existing
behavior for a separate "--from" token followed by the next arg; operate on the
same args JArray and ensure null/empty checks remain.
- Around line 470-571: The code only checks HTTP vs stdio but misses HTTP URL
mismatches; update the logic around registeredType/registeredWithHttp to extract
the registered HTTP URL from serverConfig (e.g., look for a "url" or similar
field), derive client.configuredTransport as HttpRemote vs Http based on the
registered URL (not currentUseHttp), and add a URL comparison: compute
expectedUrl (from the same place you derive
expectedPackageSource/expectedPackageSource), set hasTransportMismatch or a new
hasUrlMismatch when the registered URL differs (case-insensitive/normalized),
and treat that as a configuration mismatch that triggers the same auto-rewrite
path (using Configure(), client.SetStatus, McpStatus) or shows the appropriate
error message via McpLog.Warn; keep existing stdio/version checks
(ExtractPackageSourceFromConfig, IsBetaPackageSource) intact.

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

🤖 Fix all issues with AI agents
In `@MCPForUnity/Editor/Clients/McpClientConfiguratorBase.cs`:
- Around line 528-571: Replace the hardcoded main-thread check
(Thread.CurrentThread.ManagedThreadId == 1) with a captured main thread id
field: add a static or instance field (e.g., s_mainThreadId or _mainThreadId) to
McpClientConfiguratorBase and initialize it on startup (static constructor or
class constructor) by capturing
System.Threading.Thread.CurrentThread.ManagedThreadId (same pattern as
TransportCommandDispatcher.cs / StdioBridgeHost.cs), then change the local
isMainThread assignment to compare Thread.CurrentThread.ManagedThreadId ==
s_mainThreadId; update any references in the current method (the block using
attemptAutoRewrite, isMainThread, Configure(), client.SetStatus) to use that
field.

Comment on lines 528 to 571
// If there's any mismatch and auto-rewrite is enabled, re-register
if (hasTransportMismatch || hasVersionMismatch)
{
// Configure() requires main thread (accesses EditorPrefs, Application.dataPath)
// Only attempt auto-rewrite if we're on the main thread
bool isMainThread = System.Threading.Thread.CurrentThread.ManagedThreadId == 1;
if (attemptAutoRewrite && isMainThread)
{
string reason = hasTransportMismatch
? $"Transport mismatch (registered: {(registeredWithHttp ? "HTTP" : "stdio")}, expected: {(currentUseHttp ? "HTTP" : "stdio")})"
: mismatchReason ?? $"Package version mismatch";
McpLog.Info($"{reason}. Re-registering...");
try
{
// Force re-register by ensuring status is not Configured (which would toggle to Unregister)
client.SetStatus(McpStatus.IncorrectPath);
Configure();
return client.status;
}
catch (Exception ex)
{
McpLog.Warn($"Auto-reregister failed: {ex.Message}");
client.SetStatus(McpStatus.IncorrectPath, $"Configuration mismatch. Click Configure to re-register.");
return client.status;
}
}
else
{
if (hasTransportMismatch)
{
string errorMsg = $"Transport mismatch: Claude Code is registered with {(registeredWithHttp ? "HTTP" : "stdio")} but current setting is {(currentUseHttp ? "HTTP" : "stdio")}. Click Configure to re-register.";
client.SetStatus(McpStatus.Error, errorMsg);
McpLog.Warn(errorMsg);
}
else
{
client.SetStatus(McpStatus.IncorrectPath, mismatchReason);
}
return client.status;
}
}

client.SetStatus(McpStatus.NotConfigured);
client.configuredTransport = Models.ConfiguredTransport.Unknown;
client.SetStatus(McpStatus.Configured);
return client.status;
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# Check the context around the line in question
cat -n MCPForUnity/Editor/Clients/McpClientConfiguratorBase.cs | sed -n '520,580p'

Repository: CoplayDev/unity-mcp

Length of output: 3674


🏁 Script executed:

# Search for ManagedThreadId usage in the codebase
rg "ManagedThreadId" --type cs

Repository: CoplayDev/unity-mcp

Length of output: 1005


🏁 Script executed:

# Search for other thread detection patterns in the codebase
rg "Thread\." --type cs -A 2 -B 2 | head -100

Repository: CoplayDev/unity-mcp

Length of output: 7810


🏁 Script executed:

# Look for Unity.EditorApplication or Editor thread related checks
rg "EditorApplication|MainThread|ThreadPool" --type cs | head -30

Repository: CoplayDev/unity-mcp

Length of output: 3430


🏁 Script executed:

# Check what's in the using statements and imports of this file
head -30 MCPForUnity/Editor/Clients/McpClientConfiguratorBase.cs

Repository: CoplayDev/unity-mcp

Length of output: 977


Use a captured main-thread ID instead of hardcoded ManagedThreadId == 1.
The main thread ID is not guaranteed to be 1 across platforms. Other parts of this codebase (e.g., TransportCommandDispatcher.cs, StdioBridgeHost.cs) already demonstrate the correct pattern: capture the thread ID at initialization and compare against it. Apply the same approach here.

🤖 Prompt for AI Agents
In `@MCPForUnity/Editor/Clients/McpClientConfiguratorBase.cs` around lines 528 -
571, Replace the hardcoded main-thread check
(Thread.CurrentThread.ManagedThreadId == 1) with a captured main thread id
field: add a static or instance field (e.g., s_mainThreadId or _mainThreadId) to
McpClientConfiguratorBase and initialize it on startup (static constructor or
class constructor) by capturing
System.Threading.Thread.CurrentThread.ManagedThreadId (same pattern as
TransportCommandDispatcher.cs / StdioBridgeHost.cs), then change the local
isMainThread assignment to compare Thread.CurrentThread.ManagedThreadId ==
s_mainThreadId; update any references in the current method (the block using
attemptAutoRewrite, isMainThread, Configure(), client.SetStatus) to use that
field.

dsarno and others added 4 commits February 3, 2026 14:06
Instead of running `claude mcp list` (15+ seconds due to health checks),
read the config directly from ~/.claude.json (instant).

Changes:
- Add ReadClaudeCodeConfig() to parse Claude's JSON config file
- Walk up directory tree to find config at parent directories
- Handle duplicate path entries (forward/backslash variants)
- Add beta/stable version mismatch detection with clear messages
- Add IsBetaPackageSource() to detect PyPI beta versions and prerelease ranges
- Change button label from "Register" to "Configure" for consistency
- Refresh client status when switching to Connect tab or toggling beta mode

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add McpStatus.VersionMismatch enum value for version mismatch cases
- Show "Version Mismatch" with yellow warning indicator instead of "Error"
- Use VersionMismatch for beta/stable package source mismatches
- Keep Error status for transport mismatches and general errors

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add version-mismatch-warning banner to McpConnectionSection.uxml
- Add UpdateVersionMismatchWarning method to show/hide the banner
- Fire OnClientConfigMismatch event when VersionMismatch status detected
- Wire up event in main window to update the warning banner
- Store mismatch details in configStatus for both Error and VersionMismatch

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Before: "Beta/stable mismatch: registered with beta 'mcpforunityserver>=0.0.0a0' but plugin is stable 'mcpforunityserver==9.4.0'."

After: "Configured for beta server, but 'Use Beta Server' is disabled in Advanced settings."

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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

🤖 Fix all issues with AI agents
In `@MCPForUnity/Editor/Clients/McpClientConfiguratorBase.cs`:
- Around line 451-456: The current branch sets McpStatus.NotConfigured and
clears configuredTransport but drops configResult.error/mismatchReason because
SetStatus only records errorDetails for McpStatus.Error; update the flow so
those details are preserved and surfaced: either extend the client to hold a
dedicated statusDetails field (e.g., add/assign client.statusDetails =
configResult.error or mismatchReason) before calling
SetStatus(McpStatus.NotConfigured, ...), or explicitly propagate them through
the existing mismatch event/logger (invoke the mismatch event with
configResult.error/mismatchReason or call a logging helper). Make the change in
the block that uses SetStatus and the similar block at the other occurrence so
non-Error statuses retain actionable details for users.

dsarno and others added 2 commits February 3, 2026 14:17
- Treat missing ~/.claude.json as "not configured" instead of error
  (distinguishes "no Claude Code installed" from actual read failures)
- Handle --from=VALUE format in ExtractPackageSourceFromConfig
  (in addition to existing --from VALUE format)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…ients

- Move GetExpectedPackageSourceForValidation() and IsBetaPackageSource()
  to base class so all configurators can use them
- Update JsonFileMcpConfigurator.CheckStatus() to use beta-aware comparison
- Show VersionMismatch status with clear messaging for Claude Desktop,
  Cursor, Windsurf, VS Code, and other JSON-based clients
- Auto-rewrite still attempts to fix mismatches automatically

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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

🤖 Fix all issues with AI agents
In `@MCPForUnity/Editor/Clients/McpClientConfiguratorBase.cs`:
- Around line 596-612: CheckStatusWithProjectDir currently only detects
transport type changes via client.configuredTransport and hasTransportMismatch;
when registeredWithHttp is true also read the registered URL from
serverConfig["url"] and compare it to HttpEndpointUtility.GetMcpRpcUrl(), and if
they differ mark the client as mismatched (same semantics used for stdio
mismatch detection) so the configured state reflects an endpoint URL change;
update the logic around registeredWithHttp/currentUseHttp to include this URL
equality check (use the same pattern as
OpenCodeConfigurator/CodexMcpConfigurator) and surface the mismatch where
hasTransportMismatch is evaluated.
🧹 Nitpick comments (2)
MCPForUnity/Editor/Clients/McpClientConfiguratorBase.cs (2)

96-108: Consider reusing EditorConfigurationCache.GetUseBetaServerWithDynamicDefault() to avoid logic duplication.

This duplicates the beta mode detection logic from EditorConfigurationCache. If the beta detection logic changes in one place, it could drift from the other. Consider extracting a shared helper or calling the cache method directly (if main-thread access is guaranteed).


428-434: CodexMcpConfigurator lacks beta-aware validation.

JsonFileMcpConfigurator and ClaudeCliMcpConfigurator now use GetExpectedPackageSourceForValidation() for beta-aware comparison, but CodexMcpConfigurator still uses AssetPathUtility.GetMcpServerPackageSource() directly. This inconsistency means Codex clients won't detect beta/stable mismatches.

♻️ Suggested fix
                     else if (args != null && args.Length > 0)
                     {
-                        string expected = AssetPathUtility.GetMcpServerPackageSource();
+                        string expected = GetExpectedPackageSourceForValidation();
                         string configured = McpConfigurationHelper.ExtractUvxUrl(args);
                         matches = !string.IsNullOrEmpty(configured) &&
                                   McpConfigurationHelper.PathsEqual(configured, expected);
                     }

Note: You may also want to add version mismatch detection and messaging similar to JsonFileMcpConfigurator.

CodexMcpConfigurator was still using the non-beta-aware package source
comparison. Now uses GetExpectedPackageSourceForValidation() and shows
VersionMismatch status with clear messaging like other configurators.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@dsarno dsarno merged commit 6f3b869 into CoplayDev:beta Feb 3, 2026
1 of 2 checks passed
urun4m0r1 pushed a commit to urun4m0r1/unity-mcp that referenced this pull request Feb 6, 2026
…ntion

Cherry-pick PR CoplayDev#682: Read ~/.claude.json directly instead of running
`claude mcp list` (15+ seconds). Makes config check instant.

Fix TcpListener leak on Windows:
- Remove ExclusiveAddressUse=false to prevent duplicate listeners
  binding to the same port after Domain Reload
- Increase port binding retry from 3x75ms to 10x200ms to allow
  old socket cleanup during Domain Reload

Fixes CoplayDev#664
Related: CoplayDev#643

Co-Authored-By: Claude <noreply@anthropic.com>
urun4m0r1 pushed a commit to urun4m0r1/unity-mcp that referenced this pull request Feb 6, 2026
…ntion

Cherry-pick PR CoplayDev#682: Read ~/.claude.json directly instead of running
`claude mcp list` (15+ seconds). Makes config check instant.

Fix TcpListener leak on Windows:
- Remove ExclusiveAddressUse=false to prevent duplicate listeners
  binding to the same port after Domain Reload
- Increase port binding retry from 3x75ms to 10x200ms to allow
  old socket cleanup during Domain Reload

Fixes CoplayDev#664
Related: CoplayDev#643

Co-Authored-By: Claude <noreply@anthropic.com>
urun4m0r1 pushed a commit to urun4m0r1/unity-mcp that referenced this pull request Feb 6, 2026
- Remove ExclusiveAddressUse=false to prevent duplicate listeners
  binding to the same port after Domain Reload
- Increase port binding retry from 3x75ms to 10x200ms to allow
  old socket cleanup during Domain Reload

Based on beta branch (post-PR CoplayDev#682) which includes:
- CheckStatus speed-up (read ~/.claude.json directly)
- Thread-safety fixes (PR CoplayDev#667)
- Beta mode validation (PR CoplayDev#671)

Fixes CoplayDev#664
Related: CoplayDev#643

Co-Authored-By: Claude <noreply@anthropic.com>
urun4m0r1 pushed a commit to urun4m0r1/unity-mcp that referenced this pull request Feb 6, 2026
- Remove ExclusiveAddressUse=false to prevent duplicate listeners
  binding to the same port after Domain Reload
- Increase port binding retry from 3x75ms to 10x200ms to allow
  old socket cleanup during Domain Reload

Based on beta branch (post-PR CoplayDev#682) which includes:
- CheckStatus speed-up (read ~/.claude.json directly)
- Thread-safety fixes (PR CoplayDev#667)
- Beta mode validation (PR CoplayDev#671)

Fixes CoplayDev#664
Related: CoplayDev#643

Co-Authored-By: Claude <noreply@anthropic.com>
urun4m0r1 pushed a commit to urun4m0r1/unity-mcp that referenced this pull request Feb 7, 2026
- Remove ExclusiveAddressUse=false to prevent duplicate listeners
  binding to the same port after Domain Reload
- Increase port binding retry from 3x75ms to 10x200ms to allow
  old socket cleanup during Domain Reload

Based on beta branch (post-PR CoplayDev#682) which includes:
- CheckStatus speed-up (read ~/.claude.json directly)
- Thread-safety fixes (PR CoplayDev#667)
- Beta mode validation (PR CoplayDev#671)

Fixes CoplayDev#664
Related: CoplayDev#643

Co-Authored-By: Claude <noreply@anthropic.com>
urun4m0r1 pushed a commit to urun4m0r1/unity-mcp that referenced this pull request Feb 7, 2026
- Remove ExclusiveAddressUse=false to prevent duplicate listeners
  binding to the same port after Domain Reload
- Increase port binding retry from 3x75ms to 10x200ms to allow
  old socket cleanup during Domain Reload

Based on beta branch (post-PR CoplayDev#682) which includes:
- CheckStatus speed-up (read ~/.claude.json directly)
- Thread-safety fixes (PR CoplayDev#667)
- Beta mode validation (PR CoplayDev#671)

Fixes CoplayDev#664
Related: CoplayDev#643

Co-Authored-By: Claude <noreply@anthropic.com>
@dsarno dsarno deleted the fix/claude-code-fast-config-check branch February 13, 2026 04:28
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