MCPクライアント設定の仕組み
MCP for Unityは、clientごとのconfig形式をconfigurator classへ分離しています。一般的なJSON clientと、Codex / Claude Code / OpenClawのような個別対応が必要なclientを同じregistryから扱います。
主要interfaceとbase class
IMcpClientConfigurator— status確認、自動設定、manual snippet、導入手順を定義するcontractMcpClientConfiguratorBase— 共通propertyとhelperJsonFileMcpConfigurator— JSON configを使う大半のclient向けCodexMcpConfigurator— TOML config向けClaudeCliMcpConfigurator— CLIでMCP serverを登録するclient向けMcpClient— client名、OS別config path、transport / JSON layoutなどの設定値McpClientRegistry— configuratorを自動検出するregistry
一般的なJSON clientを追加する
MCPForUnity/Editor/Clients/Configuratorsへpublic classを追加します。
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",
"Configure MCP for Unity",
"Restart My Client"
};
}
}
自動検出には次が必要です。
public- non-abstract class
- public parameterless constructor
追加のregistration listは不要です。
McpClientで指定できる主な差分
windowsConfigPath/macConfigPath/linuxConfigPathSupportsHttpTransport— HTTP対応可否IsVsCodeLayout—serversrootなどVS Code形式HttpUrlProperty—urlまたはserverUrlなどEnsureEnvObject/StripEnvWhenNotRequired—envobjectの扱いDefaultUnityFields—disabled: falseなどclient固有の既定field
JSON生成の差分はConfigJsonBuilderへ集約されているため、通常はCheckStatus、Configure、GetManualSnippetをoverrideする必要はありません。
特殊client
Codex
CodexMcpConfiguratorを使用します。通常は~/.codex/config.tomlのようなTOMLをCodexConfigHelperで読み書きします。
Claude Code
ClaudeCliMcpConfiguratorを使用します。JSON fileではなくclaude mcp list/add/removeで登録状態を管理します。
Claude Desktop
JSON形式ですがstdioのみです。SupportsHttpTransport = falseとtransport contractにより、全体設定がHTTPでもClaude Desktop向けにはstdioへcoerceして書き込みます。
OpenClaw
OpenClawConfiguratorが~/.openclaw/openclaw.json内のopenclaw-mcp-bridge設定を扱います。HTTPでは/mcp endpoint、stdioではuvx ... --transport stdioを設定します。
Unityで検証する
- Unityを開き MCP for Unity windowを表示する
- 新しいclientが表示されることを確認する
- Check Status で未設定 / 設定済みを確認する
- Configure でconfigを書き込む
- MCP clientを再起動し、Unityへ接続できることを確認する
原則
新しいclientがJSON形式なら、独自logicを増やす前にJsonFileMcpConfiguratorとMcpClientの既存fieldで表 現できないか確認します。client固有の特殊処理は、標準形式で表せない場合だけ追加します。