CoplayDev/unity-mcp · error · InvalidOperationException
Failed to unregister: {ex.Message}
Error message
Failed to unregister: {ex.Message} What it means
JsonFileMcpConfigurator.Unregister() parses the client config file, removes the unityMCP key from its container (mcpServers/servers/mcp), and writes it back. Any exception during this read-parse-remove-write cycle is caught and re-thrown as InvalidOperationException with a 'Failed to unregister:' prefix. The original exception is preserved as InnerException.
Source
Thrown at MCPForUnity/Editor/Clients/McpClientConfiguratorBase.cs:413
}
else
{
string containerKey = string.IsNullOrEmpty(client.ServerContainerKey)
? "mcpServers" : client.ServerContainerKey;
if ((root[containerKey] as JObject)?.Remove("unityMCP") == true) removed = true;
}
if (removed)
{
File.WriteAllText(path, root.ToString(Formatting.Indented));
}
client.SetStatus(McpStatus.NotConfigured);
client.configuredTransport = Models.ConfiguredTransport.Unknown;
}
catch (Exception ex)
{
throw new InvalidOperationException($"Failed to unregister: {ex.Message}", ex);
}
}
public override string GetManualSnippet()
{
try
{
string uvx = GetUvxPathOrError();
return ConfigJsonBuilder.BuildManualConfigJson(uvx, client);
}
catch (Exception ex)
{
var errorObj = new { error = ex.Message };
return JsonConvert.SerializeObject(errorObj);
}
}
public override IList<string> GetInstallationSteps() => new List<string> { "Configuration steps not available for this client." };View on GitHub (pinned to c21bf496bc)
Solutions
- Read the InnerException.Message for the underlying cause (IO, parse, or null-ref).
- Close any editor that has the config file open, then retry Unregister.
- Validate the config file JSON with a linter and fix syntax errors.
- Check filesystem permissions on the config directory and file.
- If the file is corrupt beyond repair, back it up, delete it, and re-Configure.
Defensive patterns
Strategy: try-catch
Validate before calling
string path = GetConfigPath();
if (!File.Exists(path)) { /* nothing to unregister */ return; }
string text = File.ReadAllText(path);
JToken.Parse(text); // validate parse before Unregister Try / catch
try { configurator.Unregister(); }
catch (InvalidOperationException ex)
{ Debug.LogError($"Unregister failed: {ex.Message}. Inner: {ex.InnerException?.Message}"); } Prevention
- Close config files in other editors before unregistering.
- Validate JSON before triggering unregister operations.
- Check the InnerException for the root cause of IO or parse failures.
When it happens
Trigger: File IO errors (permissions, disk full, file locked by another process), JSON parse errors on a corrupt config file, or an unexpected null during JObject traversal.
Common situations: The config file is open in another editor that locks it. The user has a malformed config file from a manual edit. Antivirus or sync software (Dropbox, OneDrive) is temporarily locking the file. Disk full or read-only filesystem.
Related errors
- {result}
- OpenClaw config contains non-JSON content and cannot be safe
- uvx not found. Install uv/uvx or set the override in Advance
- Cherry Studio uses UI-based configuration. Please use the Ma
- uvx not found. Install uv/uvx or set the override in Advance
AI-assisted analysis of CoplayDev/unity-mcp@c21bf496bc (2026-08-13).
Data as JSON: /api/errors/78b69bad710b96cf.
Report an issue: GitHub.