Skip to main content

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.
    • JsonFileMcpConfigurator
      • For JSON-based config files (most clients), in JsonFileMcpConfigurator.cs.
      • Implements CheckStatus, Configure, and GetManualSnippet using ConfigJsonBuilder.
    • CodexMcpConfigurator
      • For Codex-style TOML config files, in CodexMcpConfigurator.cs.
    • ClaudeCliMcpConfigurator
      • For Claude Code registration through its CLI, in ClaudeCliMcpConfigurator.cs.
  • McpClient model (MCPForUnity/Editor/Models/McpClient.cs)

    • Holds the per-client configuration:
      • name
      • windowsConfigPath, macConfigPath, linuxConfigPath
      • Status and several JSON-config flags (used by JsonFileMcpConfigurator):
        • IsVsCodeLayout – VS Code-style layout (servers root, type field, etc.).
        • SupportsHttpTransport – whether the client supports HTTP transport.
        • EnsureEnvObject – ensure an env object exists.
        • StripEnvWhenNotRequired – remove env when not needed.
        • HttpUrlProperty – which property holds the HTTP URL (e.g. "url" vs "serverUrl").
        • DefaultUnityFields – key/value pairs like { "disabled": false } applied when missing.
  • Auto-discovery (McpClientRegistry)

    • McpClientRegistry.All uses TypeCache.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 – JsonFileMcpConfigurator with IsVsCodeLayout = true.
  • VSCode Insiders GitHub Copilot – JsonFileMcpConfigurator with IsVsCodeLayout = true and Insider-specific Code - Insiders/User/mcp.json paths.
  • GitHub Copilot CLI – JsonFileMcpConfigurator with standard HTTP transport.
  • Windsurf – JsonFileMcpConfigurator with Windsurf-specific flags (HttpUrlProperty = "serverUrl", DefaultUnityFields["disabled"] = false, etc.).
  • Kiro, Trae, Antigravity 2.0 (~/.gemini/config/mcp_config.json after 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:

  1. Subclass JsonFileMcpConfigurator.
  2. Provide a McpClient instance in the constructor with:
    • A user-friendly name.
    • OS-specific config paths.
    • Any JSON behavior flags as needed.
  3. Override GetInstallationSteps to describe how users open or edit the config.
  4. 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 using ConfigJsonBuilder.

JSON behavior controlled by McpClient​

JsonFileMcpConfigurator relies on the fields on McpClient:

  • HTTP vs stdio
    • SupportsHttpTransport + EditorPrefs.UseHttpTransport decide whether to configure
      • url / serverUrl (HTTP), or
      • command + args (stdio with uvx).
  • 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 = true switches config structure to a VS Code compatible layout.
  • Env object and default fields
    • EnsureEnvObject / StripEnvWhenNotRequired control an env block.
    • DefaultUnityFields adds 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 CodexConfigHelper to:
    • Parse the existing TOML.
    • Check for a matching Unity MCP server configuration.
    • Write/patch the Codex server block.
  • The CodexConfigurator class:
    • Only needs to supply a McpClient with TOML config paths.
    • Inherits the Codex-specific status and configure behavior from CodexMcpConfigurator.

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 list health check.
  • ClaudeHttpAuth verifies the selected CLI with an isolated --version probe. The minimum automatic-refresh baseline is 2.1.193; unknown or older versions get stdio guidance.
  • Local HTTP registration uses mcp add-json with headersHelper. Capability and configuration validation happen before old registrations are removed. Custom helpers and OAuth settings require manual migration.
  • Configure registers 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 ClaudeCodeConfigurator class:
    • Only needs a McpClient with a name.
    • Inherits CLI-specific installation and reconnect instructions.

Claude Desktop (JSON with restrictions)​

  • Uses JsonFileMcpConfigurator, but only supports stdio transport.
  • ClaudeDesktopConfigurator:
    • Sets SupportsHttpTransport = false in McpClient.
    • Declares SupportedTransports => StdioOnly. ClientConfigurationService reads SupportedTransports and, via ConfigureWithTransportCoercion / CoerceTransportFor, temporarily coerces the transport pref to stdio before calling Configure() — so users with HTTP toggled globally still get a working stdio entry written without a thrown error. The coercion applies to any configurator whose SupportedTransports excludes the user's current transport; Claude Desktop is just the only one declaring stdio-only today.

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 stdio subprocess 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 JsonFileMcpConfigurator if your client reads a JSON config file.
  • Consider CodexMcpConfigurator only if you are integrating a TOML-based client like Codex.
  • Consider ClaudeCliMcpConfigurator only 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 = true for VS Code-style config.
      • HttpUrlProperty = "serverUrl" if your client expects serverUrl.
      • EnsureEnvObject / StripEnvWhenNotRequired based on env handling.
      • DefaultUnityFields = { { "disabled", false }, ... } for client-specific defaults.

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:

  • CheckStatus
  • Configure
  • GetManualSnippet

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:

  1. Open Unity and the Unity MCP (ykh09242) window.
  2. Your client should appear in the list, sorted by display name (McpClient.name).
  3. Use Check Status to verify:
    • Missing config files show as Not Configured.
    • Existing files with matching server settings show as Configured.
  4. Click Configure to auto-write the config file.
  5. 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 to CodexConfigurator).
  • Override GetInstallationSteps to 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 McpClient with a name.
  • Override GetInstallationSteps with the CLI flow.

The base class:

  • Locates the CLI binary using MCPServiceLocator.Paths.
  • Uses ExecPath.TryRun for 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 JsonFileMcpConfigurator subclass in Editor/Clients/Configurators.
    • Provide a McpClient with paths and flags.
    • Override GetInstallationSteps.
  • Special cases like Codex (TOML) and Claude Code (CLI) have dedicated base classes.
  • No manual registration is needed: McpClientRegistry auto-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.