MCP Client Configurators
This guide explains how MCP client configurators work in this repo and how to add a new one.
It covers:
- Typical JSON-file clients (Cursor, VSCode GitHub Copilot, VSCode Insiders, GitHub Copilot CLI, Windsurf, Kiro, Trae, Antigravity 2.0, Antigravity IDE, etc.).
- Special clients like Claude CLI, Codex, and OpenClaw that require custom logic.
- How to add a new configurator class so it shows up automatically in the Unity MCP (ykh09242) window.
Quick example: JSON-file configurator
For most clients you just need a small class like this:
using System;
using System.Collections.Generic;
using System.IO;
using MCPForUnity.Editor.Models;
namespace MCPForUnity.Editor.Clients.Configurators
{
public class MyClientConfigurator : JsonFileMcpConfigurator
{
public MyClientConfigurator() : base(new McpClient
{
name = "My Client",
windowsConfigPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".myclient", "mcp.json"),
macConfigPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".myclient", "mcp.json"),
linuxConfigPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".myclient", "mcp.json"),
})
{ }
public override IList<string> GetInstallationSteps() => new List<string>
{
"Open My Client and go to MCP settings",
"Open or create the mcp.json file at the path above",
"Click Configure in MCP for Unity (or paste the manual JSON snippet)",
"Restart My Client"
};
}
}
How the configurator system works
At a high level:
-
IMcpClientConfigurator(MCPForUnity/Editor/Clients/IMcpClientConfigurator.cs)- Contract for all MCP client configurators.
- Handles status detection, auto-configure, manual snippet, and installation steps.
-
Base classes (separate files under
MCPForUnity/Editor/Clients/)McpClientConfiguratorBase- Common properties and helpers in
McpClientConfiguratorBase.cs, with no Codex- or Claude-specific implementation.
- Common properties and helpers in
JsonFileMcpConfigurator- For JSON-based config files (most clients), in
JsonFileMcpConfigurator.cs. - Implements
CheckStatus,Configure, andGetManualSnippetusingConfigJsonBuilder.
- For JSON-based config files (most clients), in
CodexMcpConfigurator- For Codex-style TOML config files, in
CodexMcpConfigurator.cs.
- For Codex-style TOML config files, in
ClaudeCliMcpConfigurator- For Claude Code registration through its CLI, in
ClaudeCliMcpConfigurator.cs.
- For Claude Code registration through its CLI, in
-
McpClientmodel (MCPForUnity/Editor/Models/McpClient.cs)- Holds the per-client configuration:
namewindowsConfigPath,macConfigPath,linuxConfigPath- Status and several JSON-config flags (used by
JsonFileMcpConfigurator):IsVsCodeLayout– VS Code-style layout (serversroot,typefield, etc.).SupportsHttpTransport– whether the client supports HTTP transport.EnsureEnvObject– ensure anenvobject exists.StripEnvWhenNotRequired– removeenvwhen not needed.HttpUrlProperty– which property holds the HTTP URL (e.g."url"vs"serverUrl").DefaultUnityFields– key/value pairs like{ "disabled": false }applied when missing.
- Holds the per-client configuration:
-
Auto-discovery (
McpClientRegistry)McpClientRegistry.AllusesTypeCache.GetTypesDerivedFrom<IMcpClientConfigurator>()to find configurators.- A configurator appears automatically if:
- It is a public, non-abstract class.
- It has a public parameterless constructor.
- No extra registration list is required.
Typical JSON-file clients
Most MCP clients use a JSON config file that defines one or more MCP servers. Examples:
- Cursor –
JsonFileMcpConfigurator(global~/.cursor/mcp.json). - VSCode GitHub Copilot –
JsonFileMcpConfiguratorwithIsVsCodeLayout = true. - VSCode Insiders GitHub Copilot –
JsonFileMcpConfiguratorwithIsVsCodeLayout = trueand Insider-specificCode - Insiders/User/mcp.jsonpaths. - GitHub Copilot CLI –
JsonFileMcpConfiguratorwith standard HTTP transport. - Windsurf –
JsonFileMcpConfiguratorwith Windsurf-specific flags (HttpUrlProperty = "serverUrl",DefaultUnityFields["disabled"] = false, etc.). - Kiro, Trae, Antigravity 2.0 (
~/.gemini/config/mcp_config.jsonafter the 2.x migration), Antigravity IDE (separate~/.gemini/antigravity-ide/mcp_config.json— the IDE build did not migrate) – JSON configs with project-specific paths and flags.
All of these follow the same pattern:
- Subclass
JsonFileMcpConfigurator. - Provide a
McpClientinstance in the constructor with:- A user-friendly
name. - OS-specific config paths.
- Any JSON behavior flags as needed.
- A user-friendly
- Override
GetInstallationStepsto describe how users open or edit the config. - Rely on base implementations for:
CheckStatus– reads and validates the JSON config without rewriting it.Configure– writes/rewrites the config file.GetManualSnippet– builds a JSON snippet usingConfigJsonBuilder.
JSON behavior controlled by McpClient
JsonFileMcpConfigurator relies on the fields on McpClient:
- HTTP vs stdio
SupportsHttpTransport+EditorPrefs.UseHttpTransportdecide whether to configureurl/serverUrl(HTTP), orcommand+args(stdio withuvx).
- URL property name
HttpUrlProperty(default"url") selects which JSON property to use for HTTP urls.- Example: Windsurf and the two Antigravity clients use
"serverUrl".
- VS Code layout
IsVsCodeLayout = trueswitches config structure to a VS Code compatible layout.
- Env object and default fields
EnsureEnvObject/StripEnvWhenNotRequiredcontrol anenvblock.DefaultUnityFieldsadds client-specific fields if they are missing (e.g.disabled: false).
All of this logic is centralized in ConfigJsonBuilder, so most JSON-based clients do not need to override GetManualSnippet.
Preserve manual stdio configuration
An explicit Configure action records ownership of the generated UnityMCP entry. Startup refresh may update that entry only when automatic registration is enabled, the stored fingerprint still matches, and the entry is recognized as generated. Manual edits, custom commands, deliberate source/version pins, and entries created before ownership tracking are preserved. A status check does not claim ownership.
Use Configure when intentionally replacing an existing entry with the selected settings. To diagnose an already running server after an update, inspect the observed stdio build information described in Troubleshooting.
Special clients
Some clients cannot be handled by the generic JSON configurator alone.
Codex (TOML-based)
- Uses
CodexMcpConfigurator. - Reads and writes a TOML config (usually
~/.codex/config.toml). - Uses
CodexConfigHelperto:- Parse the existing TOML.
- Check for a matching Unity MCP server configuration.
- Write/patch the Codex server block.
- The
CodexConfiguratorclass:- Only needs to supply a
McpClientwith TOML config paths. - Inherits the Codex-specific status and configure behavior from
CodexMcpConfigurator.
- Only needs to supply a
The Codex button always performs an idempotent configuration write, including when already configured. OpenCode and OpenClaw also use Configure rather than an unsupported Unregister action. JSON-client toggle buttons offer removal only when their cached configured transport still matches the selected transport. Status checks compare transport, endpoint and managed authentication without logging credentials; a successful write is not a live connection test.
New HTTP snippets do not set features.rmcp_client. Existing feature choices are preserved for older installations; compatibility is not inferred from an unverified version cutoff. See Codex HTTP configuration for the current format and legacy-version guidance.
CodexHttpAuth probes the CLI with an isolated synthetic CODEX_HOME. It does not execute custom helpers. LocalHttpAuth builds the shared token-file reader used by Codex and Claude Code; it contains no client schema or version logic. Helpers are limited to loopback endpoints. Remote credentials remain static and separate.
Claude Code (CLI-based)
- Uses
ClaudeCliMcpConfigurator. - Registration is managed through the Claude CLI; status reads configuration files without running a connection-producing
mcp listhealth check. ClaudeHttpAuthverifies the selected CLI with an isolated--versionprobe. The minimum automatic-refresh baseline is 2.1.193; unknown or older versions get stdio guidance.- Local HTTP registration uses
mcp add-jsonwithheadersHelper. Capability and configuration validation happen before old registrations are removed. Custom helpers and OAuth settings require manual migration. Configureregisters idempotently. The UI dispatches an explicit unregister action separately when the configured transport still matches.- Status checks receive endpoint and remote-header expectations captured on the Editor thread. Local helper validation does not read a current token or execute the helper. Explicit other-project overrides keep their existing independent-project status behavior.
- The
ClaudeCodeConfiguratorclass:- Only needs a
McpClientwith aname. - Inherits CLI-specific installation and reconnect instructions.
- Only needs a
Claude Desktop (JSON with restrictions)
- Uses
JsonFileMcpConfigurator, but only supports stdio transport. ClaudeDesktopConfigurator:- Sets
SupportsHttpTransport = falseinMcpClient. - Declares
SupportedTransports => StdioOnly.ClientConfigurationServicereadsSupportedTransportsand, viaConfigureWithTransportCoercion/CoerceTransportFor, temporarily coerces the transport pref to stdio before callingConfigure()— so users with HTTP toggled globally still get a working stdio entry written without a thrown error. The coercion applies to any configurator whoseSupportedTransportsexcludes the user's current transport; Claude Desktop is just the only one declaring stdio-only today.
- Sets
OpenClaw (plugin-based)
- Uses a custom configurator (
OpenClawConfigurator) because OpenClaw MCP is plugin-driven. - Config file path is
~/.openclaw/openclaw.json. - Unity MCP is configured through
plugins.entries.openclaw-mcp-bridge.config.servers.unityMCP. - When Unity MCP is set to HTTP, the bridge expects the MCP JSON-RPC endpoint URL (
http://127.0.0.1:<port>/mcp), not just the HTTP base URL. - When Unity MCP is set to stdio, the configurator writes a
uvx ... mcp-for-unity --transport stdiosubprocess entry. - The bridge exposes a single proxy tool such as
unityMCP__call, which then forwards to Unity MCP tool names. - OpenClaw support follows the currently selected MCP for Unity transport (via
openclaw-mcp-bridge).
Adding a new MCP client (typical JSON case)
This is the most common scenario: your MCP client uses a JSON file to configure servers.
1. Choose the base class
- Use
JsonFileMcpConfiguratorif your client reads a JSON config file. - Consider
CodexMcpConfiguratoronly if you are integrating a TOML-based client like Codex. - Consider
ClaudeCliMcpConfiguratoronly if your client exposes a CLI command to manage MCP servers.
2. Create the configurator class
Create a new file under:
MCPForUnity/Editor/Clients/Configurators
Name it something like:
MyClientConfigurator.cs
Inside, follow the existing pattern (e.g. CursorConfigurator, WindsurfConfigurator, KiroConfigurator):
- Namespace must be:
MCPForUnity.Editor.Clients.Configurators
- Class:
public class MyClientConfigurator : JsonFileMcpConfigurator
- Constructor:
- Public, parameterless, and call
base(new McpClient { ... }). - Set at least:
name = "My Client"windowsConfigPath = ...macConfigPath = ...linuxConfigPath = ...
- Optionally set flags:
IsVsCodeLayout = truefor VS Code-style config.HttpUrlProperty = "serverUrl"if your client expectsserverUrl.EnsureEnvObject/StripEnvWhenNotRequiredbased on env handling.DefaultUnityFields = { { "disabled", false }, ... }for client-specific defaults.
- Public, parameterless, and call
Because the constructor is parameterless and public, McpClientRegistry will auto-discover this configurator with no extra registration.
3. Add installation steps
Override GetInstallationSteps to tell users how to configure the client:
- Where to find or create the JSON config file.
- Which menu path opens the MCP settings.
- Whether they should rely on the Configure button or copy-paste the manual JSON.
Look at CursorConfigurator, VSCodeConfigurator, VSCodeInsidersConfigurator, KiroConfigurator, TraeConfigurator, AntigravityConfigurator, or AntigravityIdeConfigurator for phrasing.
4. Rely on the base JSON logic
Unless your client has very unusual behavior, you typically do not need to override:
CheckStatusConfigureGetManualSnippet
The base JsonFileMcpConfigurator:
- Detects missing or mismatched config.
- Optionally rewrites config to match Unity MCP.
- Builds a JSON snippet with correct HTTP vs stdio settings, using
ConfigJsonBuilder.
Only override these methods if your client has constraints that cannot be expressed via McpClient flags.
5. Verify in Unity
After adding your configurator class:
- Open Unity and the Unity MCP (ykh09242) window.
- Your client should appear in the list, sorted by display name (
McpClient.name). - Use Check Status to verify:
- Missing config files show as
Not Configured. - Existing files with matching server settings show as
Configured.
- Missing config files show as
- Click Configure to auto-write the config file.
- Restart your MCP client and confirm it connects to Unity.
Adding a custom (non-JSON) client
If your MCP client doesnt store configuration as a JSON file, you likely need a custom base class.
Codex-style TOML client
- Subclass
CodexMcpConfigurator. - Provide TOML paths via
McpClient(similar toCodexConfigurator). - Override
GetInstallationStepsto describe how to open/edit the TOML.
The Codex-specific status and configure logic is already implemented in the base class.
CLI-managed client (Claude-style)
- Subclass
ClaudeCliMcpConfigurator. - Provide a
McpClientwith aname. - Override
GetInstallationStepswith the CLI flow.
The base class:
- Locates the CLI binary using
MCPServiceLocator.Paths. - Uses
ExecPath.TryRunfor CLI registration/removal and an isolated version probe; status reads configuration directly. - Keeps registration and unregistration separate. The UI chooses the action from status and the selected transport.
Use this only if the client exposes an official CLI for managing MCP servers.
Summary
- For most MCP clients, you only need to:
- Create a
JsonFileMcpConfiguratorsubclass inEditor/Clients/Configurators. - Provide a
McpClientwith paths and flags. - Override
GetInstallationSteps.
- Create a
- Special cases like Codex (TOML) and Claude Code (CLI) have dedicated base classes.
- No manual registration is needed:
McpClientRegistryauto-discovers all configurators with a public parameterless constructor.
Following these patterns keeps all MCP client integrations consistent and lets users configure everything from the Unity MCP (ykh09242) window with minimal friction.
Generated stdio executable health
JSON and Codex status checks validate the launcher file for recognized generated
uvx entries as well as the selected server source. A missing executable or a
launch command that disagrees with the current executable override needs repair:
choose the current uv installation, then click Configure to regenerate the
entry. Status checks report the issue without rewriting the launch command.
This filesystem check does not execute a launcher or prove that its Python environment can start successfully. Custom commands, wrappers, arguments and environment settings keep their manual ownership; status does not probe or replace those launchers. Existing ownership receipts still govern any automatic source updates, and explicit configuration remains the way to repair a changed launcher.