12 KiB
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, Windsurf, Kiro, Trae, Antigravity, etc.).
- Special clients like Claude CLI and Codex that require custom logic.
- How to add a new configurator class so it shows up automatically in the MCP for Unity 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 (
MCPForUnity/Editor/Clients/McpClientConfiguratorBase.cs)McpClientConfiguratorBase- Common properties and helpers.
JsonFileMcpConfigurator- For JSON-based config files (most clients).
- Implements
CheckStatus,Configure, andGetManualSnippetusingConfigJsonBuilder.
CodexMcpConfigurator- For Codex-style TOML config files.
ClaudeCliMcpConfigurator- For CLI-driven clients like Claude Code (register/unregister via CLI, not JSON files).
-
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. - Windsurf –
JsonFileMcpConfiguratorwith Windsurf-specific flags (HttpUrlProperty = "serverUrl",DefaultUnityFields["disabled"] = false, etc.). - Kiro, Trae, Antigravity (Gemini) – 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; can auto-rewrite to match Unity MCP.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 Antigravity 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.
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
Claude Code (CLI-based)
- Uses
ClaudeCliMcpConfigurator. - Configuration is stored internally by the Claude CLI, not in a JSON file.
CheckStatusandConfigureare implemented in the base class usingclaude mcp ...commands:CheckStatuscallsclaude mcp listto detect ifUnityMCPis registered.Configuretoggles register/unregister viaclaude mcp add/remove UnityMCP.
- The
ClaudeCodeConfiguratorclass:- Only needs a
McpClientwith aname. - Overrides
GetInstallationStepswith CLI-specific instructions.
- Only needs a
Claude Desktop (JSON with restrictions)
- Uses
JsonFileMcpConfigurator, but only supports stdio transport. ClaudeDesktopConfigurator:- Sets
SupportsHttpTransport = falseinMcpClient. - Overrides
Configure/GetManualSnippetto:- Guard against HTTP mode.
- Provide clear error text if HTTP is enabled.
- Sets
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, or AntigravityConfigurator 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 MCP for Unity 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.TryRunto callmcp list,mcp add, andmcp remove. - Implements
Configureas a toggle between register and unregister.
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 MCP for Unity window with minimal friction.