CoplayDev/unity-mcp · error · InvalidOperationException

{result}

Error message

{result}

What it means

JsonFileMcpConfigurator.Configure() calls McpConfigurationHelper.WriteMcpConfiguration(path, client). If the helper returns any string other than 'Configured successfully', Configure() throws InvalidOperationException with that string as the message. The two known non-success returns are 'uv package manager not found. Please install uv first.' (GetUvxPath returns null) and 'Skipped (locked)' (LOCK_CONFIG_KEY EditorPrefs is true).

Source

Thrown at MCPForUnity/Editor/Clients/McpClientConfiguratorBase.cs:357

            return client.status;
        }

        public override void Configure()
        {
            // Always idempotent-write. The per-client UI button routes through Unregister
            // when the user clicks while the client is already Configured; the bulk
            // "Configure All" path calls this directly and expects an unconditional write.
            string path = GetConfigPath();
            McpConfigurationHelper.EnsureConfigDirectoryExists(path);
            string result = McpConfigurationHelper.WriteMcpConfiguration(path, client);
            if (result == "Configured successfully")
            {
                client.SetStatus(McpStatus.Configured);
                client.configuredTransport = HttpEndpointUtility.GetCurrentServerTransport();
            }
            else
            {
                throw new InvalidOperationException(result);
            }
        }

        public override string GetConfigureActionLabel()
            => client.status == McpStatus.Configured ? "Unregister" : "Configure";

        /// <summary>
        /// Removes the unityMCP entry from the client's JSON config (VS Code-style
        /// `servers` / `mcp.servers` layouts, the standard `mcpServers` layout, or a
        /// client-specific container such as Kilo's `mcp`). Leaves the file in place so we
        /// don't clobber other servers the user has configured.
        /// </summary>
        public override void Unregister()
        {
            string path = GetConfigPath();
            try
            {
                if (!File.Exists(path))

View on GitHub (pinned to c21bf496bc)

Solutions

  1. Install uv (https://docs.astral.sh/uv/getting-started/installation/) — the most common trigger is 'uv package manager not found'.
  2. Disable the config lock: set EditorPref LOCK_CONFIG_KEY to false, or use the MCP for Unity UI toggle.
  3. If a uvx path override is set incorrectly, clear it in Advanced Settings.
  4. Read the exception Message field — it contains the exact helper return string that identifies the root cause.
Defensive patterns

Strategy: try-catch

Validate before calling

string probe = MCPServiceLocator.Paths.GetUvxPath();
if (probe == null)
{ ShowError("uv not found. Install uv first."); return; }
if (EditorPrefs.GetBool(LOCK_CONFIG_KEY, false))
{ ShowError("Config is locked. Disable lock in settings."); return; }

Try / catch

try { configurator.Configure(); }
catch (InvalidOperationException ex)
{ Debug.LogError($"Configuration failed: {ex.Message}"); }

Prevention

When it happens

Trigger: Clicking Configure on a JSON-file-based client (Claude Desktop, Cursor, Windsurf, etc.) when uv is not resolvable, or when the config lock EditorPref is enabled.

Common situations: uv/uvx not installed on a fresh machine. Config lock was enabled for troubleshooting and not turned off. The uvx override is invalid.

Related errors


AI-assisted analysis of CoplayDev/unity-mcp@c21bf496bc (2026-08-13). Data as JSON: /api/errors/e0fd685eddcd822f. Report an issue: GitHub.