From 3ea327e79985d7f1213fdb1cae4500d919c705a9 Mon Sep 17 00:00:00 2001 From: Shutong Wu <51266340+Scriptwonder@users.noreply.github.com> Date: Sun, 24 May 2026 10:56:41 +0800 Subject: [PATCH 1/2] fix(clients): write Antigravity config to ~/.gemini/config/ (post-2.x migration) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Antigravity 2.x moved its MCP config from ~/.gemini/antigravity/mcp_config.json to a dedicated ~/.gemini/config/mcp_config.json. The migration drops a `.migrated` marker in the new location and renames the prior folder to `antigravity-backup`; the old path keeps Antigravity's runtime state (conversations/, scratch/, brain/, etc.) but is no longer read for MCP. Confirmed empirically on a real machine: ~/.gemini/config/mcp_config.json shows `mcpServers: {}` (Antigravity reads from here) while our writes have been landing in the legacy ~/.gemini/antigravity/mcp_config.json that Antigravity now ignores. Community report matches this exactly: "in .gemini there are two folders, antigravity and config; antigravity is not where mcp.json is supposed to be, there is another config folder." Also override IsInstalled. The inherited ParentDirectoryExists check points at ~/.gemini/config/, which is only created on Antigravity's first launch — on a fresh machine that has the app installed but never opened, detection false-negatives and ConfigureAllDetectedClients skips Antigravity entirely. Check ~/.antigravity/ (installer-created), the new config dir, the legacy config dir, or /Applications/Antigravity.app on macOS; any one of those is conclusive. --- .../Configurators/AntigravityConfigurator.cs | 33 +++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/MCPForUnity/Editor/Clients/Configurators/AntigravityConfigurator.cs b/MCPForUnity/Editor/Clients/Configurators/AntigravityConfigurator.cs index 9a83620f6..5378e162d 100644 --- a/MCPForUnity/Editor/Clients/Configurators/AntigravityConfigurator.cs +++ b/MCPForUnity/Editor/Clients/Configurators/AntigravityConfigurator.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Runtime.InteropServices; using MCPForUnity.Editor.Constants; using MCPForUnity.Editor.Models; using UnityEditor; @@ -9,18 +10,44 @@ namespace MCPForUnity.Editor.Clients.Configurators { public class AntigravityConfigurator : JsonFileMcpConfigurator { + // Antigravity 2.x migrated its MCP config from ~/.gemini/antigravity/mcp_config.json + // (where Antigravity also stores its own runtime state — conversations, scratch, etc.) + // to a dedicated ~/.gemini/config/mcp_config.json. The migration drops a `.migrated` + // marker in the new location and renames the previous folder to `antigravity-backup`. + // The old path is no longer read by Antigravity at all, so writing there silently + // fails to register UnityMCP on every modern install. public AntigravityConfigurator() : base(new McpClient { name = "Antigravity", - windowsConfigPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".gemini", "antigravity", "mcp_config.json"), - macConfigPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".gemini", "antigravity", "mcp_config.json"), - linuxConfigPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".gemini", "antigravity", "mcp_config.json"), + windowsConfigPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".gemini", "config", "mcp_config.json"), + macConfigPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".gemini", "config", "mcp_config.json"), + linuxConfigPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".gemini", "config", "mcp_config.json"), HttpUrlProperty = "serverUrl", DefaultUnityFields = { { "disabled", false } }, StripEnvWhenNotRequired = true }) { } + // Detect Antigravity itself, not just its config dir. ~/.gemini/config/ is created on + // first launch of Antigravity 2.x, so the inherited ParentDirectoryExists check + // false-negatives on a fresh install where the user hasn't opened Antigravity yet. + // ~/.antigravity/ is created by the installer (VS-Code-style support dir) and the + // macOS app bundle is dropped by the installer; either is conclusive evidence that + // Antigravity is installed, regardless of whether it has been launched. + public override bool IsInstalled + { + get + { + string home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); + if (Directory.Exists(Path.Combine(home, ".antigravity"))) return true; + if (Directory.Exists(Path.Combine(home, ".gemini", "config"))) return true; + if (Directory.Exists(Path.Combine(home, ".gemini", "antigravity"))) return true; + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + return Directory.Exists("/Applications/Antigravity.app"); + return false; + } + } + public override IList GetInstallationSteps() => new List { "Open Antigravity", From 4036c3d30ae7a2d07a69caf453df4c2663b55f4c Mon Sep 17 00:00:00 2001 From: Shutong Wu <51266340+Scriptwonder@users.noreply.github.com> Date: Sun, 24 May 2026 11:11:27 +0800 Subject: [PATCH 2/2] fix(clients): split Antigravity into "Antigravity 2.0" + "Antigravity IDE" The two Antigravity apps coexist on the same machine and use different MCP config paths, so they need to be separate configurators in the client list. - AntigravityConfigurator: renamed display label to "Antigravity 2.0" (path now ~/.gemini/config/mcp_config.json, already changed in the parent commit) and updated the installation-steps copy to match. - AntigravityIdeConfigurator (new): same JsonFile shape with serverUrl HTTP property, points at ~/.gemini/antigravity-ide/mcp_config.json where the IDE build keeps both its runtime state and its mcp_config. IsInstalled checks for that dedicated dir. Manual configuration guidance updated in README, README-zh, and MCP_CLIENT_CONFIGURATORS.md to reflect both clients side by side and spell out which path each one writes to. --- .../Configurators/AntigravityConfigurator.cs | 4 +- .../AntigravityIdeConfigurator.cs | 52 +++++++++++++++++++ .../AntigravityIdeConfigurator.cs.meta | 11 ++++ README.md | 4 +- docs/guides/MCP_CLIENT_CONFIGURATORS.md | 8 +-- docs/i18n/README-zh.md | 2 +- 6 files changed, 72 insertions(+), 9 deletions(-) create mode 100644 MCPForUnity/Editor/Clients/Configurators/AntigravityIdeConfigurator.cs create mode 100644 MCPForUnity/Editor/Clients/Configurators/AntigravityIdeConfigurator.cs.meta diff --git a/MCPForUnity/Editor/Clients/Configurators/AntigravityConfigurator.cs b/MCPForUnity/Editor/Clients/Configurators/AntigravityConfigurator.cs index 5378e162d..83556bd10 100644 --- a/MCPForUnity/Editor/Clients/Configurators/AntigravityConfigurator.cs +++ b/MCPForUnity/Editor/Clients/Configurators/AntigravityConfigurator.cs @@ -18,7 +18,7 @@ public class AntigravityConfigurator : JsonFileMcpConfigurator // fails to register UnityMCP on every modern install. public AntigravityConfigurator() : base(new McpClient { - name = "Antigravity", + name = "Antigravity 2.0", windowsConfigPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".gemini", "config", "mcp_config.json"), macConfigPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".gemini", "config", "mcp_config.json"), linuxConfigPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".gemini", "config", "mcp_config.json"), @@ -50,7 +50,7 @@ public override bool IsInstalled public override IList GetInstallationSteps() => new List { - "Open Antigravity", + "Open Antigravity 2.0", "Click the more_horiz menu in the Agent pane > MCP Servers", "Select 'Install' for Unity MCP or use the Configure button above", "Restart Antigravity if necessary" diff --git a/MCPForUnity/Editor/Clients/Configurators/AntigravityIdeConfigurator.cs b/MCPForUnity/Editor/Clients/Configurators/AntigravityIdeConfigurator.cs new file mode 100644 index 000000000..da7e790ba --- /dev/null +++ b/MCPForUnity/Editor/Clients/Configurators/AntigravityIdeConfigurator.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.IO; +using MCPForUnity.Editor.Constants; +using MCPForUnity.Editor.Models; +using UnityEditor; + +namespace MCPForUnity.Editor.Clients.Configurators +{ + /// + /// Antigravity IDE — the separate IDE build that ships its own ~/.gemini/antigravity-ide/ + /// runtime dir and reads its MCP config from that same folder. It did NOT migrate to + /// ~/.gemini/config/ the way Antigravity 2.0 did, so it still uses the legacy in-folder + /// mcp_config.json layout. The two apps coexist on the same machine, so we expose them + /// as separate clients rather than trying to autodetect which one to write to. + /// + public class AntigravityIdeConfigurator : JsonFileMcpConfigurator + { + public AntigravityIdeConfigurator() : base(new McpClient + { + name = "Antigravity IDE", + windowsConfigPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".gemini", "antigravity-ide", "mcp_config.json"), + macConfigPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".gemini", "antigravity-ide", "mcp_config.json"), + linuxConfigPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".gemini", "antigravity-ide", "mcp_config.json"), + HttpUrlProperty = "serverUrl", + DefaultUnityFields = { { "disabled", false } }, + StripEnvWhenNotRequired = true + }) + { } + + // ~/.gemini/antigravity-ide/ is created by the IDE on first launch and holds both + // its runtime state (annotations/, brain/, conversations/, ...) and its mcp_config.json + // — presence of the dir is the canonical "Antigravity IDE has been installed and + // launched at least once" signal. + public override bool IsInstalled + { + get + { + string home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); + return Directory.Exists(Path.Combine(home, ".gemini", "antigravity-ide")); + } + } + + public override IList GetInstallationSteps() => new List + { + "Open Antigravity IDE", + "Click the more_horiz menu in the Agent pane > MCP Servers", + "Select 'Install' for Unity MCP or use the Configure button above", + "Restart Antigravity IDE if necessary" + }; + } +} diff --git a/MCPForUnity/Editor/Clients/Configurators/AntigravityIdeConfigurator.cs.meta b/MCPForUnity/Editor/Clients/Configurators/AntigravityIdeConfigurator.cs.meta new file mode 100644 index 000000000..c7da79b63 --- /dev/null +++ b/MCPForUnity/Editor/Clients/Configurators/AntigravityIdeConfigurator.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c74a24c69bb0481682d5e35731cba6b1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/README.md b/README.md index 2a27a18fa..5b2b72afb 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ openupm add com.coplaydev.unity-mcp - In the **Clients** tab, click **Configure All Detected Clients** to set up every client found on your machine in one shot, or pick a single client from the dropdown and click **Configure**. - Look for 🟢 "Connected ✓". -**Per-client gotchas:** Some clients (Cursor, Antigravity, OpenClaw) still require enabling an MCP toggle or plugin in their own settings. OpenClaw also needs the `openclaw-mcp-bridge` plugin enabled and follows the currently selected MCP for Unity transport (`HTTP` or `stdio`). Claude Desktop only supports stdio — MCP for Unity will silently configure it that way even if you've selected HTTP elsewhere. Claude Code, VS Code, Windsurf, Cline, and the various CLI clients auto-connect after configuration. +**Per-client gotchas:** Some clients (Cursor, Antigravity 2.0, Antigravity IDE, OpenClaw) still require enabling an MCP toggle or plugin in their own settings. The two Antigravity clients are listed separately because Antigravity 2.0 migrated its MCP config into `~/.gemini/config/` while Antigravity IDE still uses `~/.gemini/antigravity-ide/`; if you run both, configure each one. OpenClaw also needs the `openclaw-mcp-bridge` plugin enabled and follows the currently selected MCP for Unity transport (`HTTP` or `stdio`). Claude Desktop only supports stdio — MCP for Unity will silently configure it that way even if you've selected HTTP elsewhere. Claude Code, VS Code, Windsurf, Cline, and the various CLI clients auto-connect after configuration. **Updates handle themselves.** When you update the package, MCP for Unity rewrites the configs of every detected client on the next Editor open — no need to repeat the Configure step. @@ -118,7 +118,7 @@ openupm add com.coplaydev.unity-mcp If auto-setup doesn't work, add this to your MCP client's config file: -**HTTP (default — works with Cursor, Windsurf, Antigravity, VS Code, Cline; Claude Desktop is stdio-only, see below):** +**HTTP (default — works with Cursor, Windsurf, Antigravity 2.0, Antigravity IDE, VS Code, Cline; Claude Desktop is stdio-only, see below):** ```json { "mcpServers": { diff --git a/docs/guides/MCP_CLIENT_CONFIGURATORS.md b/docs/guides/MCP_CLIENT_CONFIGURATORS.md index 73e5a60f3..8cbdf101d 100644 --- a/docs/guides/MCP_CLIENT_CONFIGURATORS.md +++ b/docs/guides/MCP_CLIENT_CONFIGURATORS.md @@ -4,7 +4,7 @@ This guide explains how MCP client configurators work in this repo and how to ad It covers: -- **Typical JSON-file clients** (Cursor, VSCode GitHub Copilot, VSCode Insiders, GitHub Copilot CLI, Windsurf, Kiro, Trae, Antigravity, etc.). +- **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 MCP for Unity window. @@ -93,7 +93,7 @@ Most MCP clients use a JSON config file that defines one or more MCP servers. Ex - **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 (Gemini)** – JSON configs with project-specific paths and flags. +- **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: @@ -118,7 +118,7 @@ All of these follow the same pattern: - `command` + `args` (stdio with `uvx`). - **URL property name** - `HttpUrlProperty` (default `"url"`) selects which JSON property to use for HTTP urls. - - Example: Windsurf and Antigravity use `"serverUrl"`. + - 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** @@ -228,7 +228,7 @@ Override `GetInstallationSteps` to tell users how to configure the client: - 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. +Look at `CursorConfigurator`, `VSCodeConfigurator`, `VSCodeInsidersConfigurator`, `KiroConfigurator`, `TraeConfigurator`, `AntigravityConfigurator`, or `AntigravityIdeConfigurator` for phrasing. ### 4. Rely on the base JSON logic diff --git a/docs/i18n/README-zh.md b/docs/i18n/README-zh.md index 4caba6eb6..420d4fb98 100644 --- a/docs/i18n/README-zh.md +++ b/docs/i18n/README-zh.md @@ -81,7 +81,7 @@ openupm add com.coplaydev.unity-mcp 2. 点击 **Start Server**(会在 `localhost:8080` 启动 HTTP 服务器) 3. 从下拉菜单选择你的 MCP Client,然后点击 **Configure** 4. 查找 🟢 "Connected ✓" -5. **连接你的客户端:** 一些客户端(Cursor、Antigravity、OpenClaw)需要在设置里启用 MCP 开关或插件。OpenClaw 还需要启用 `openclaw-mcp-bridge` 插件,并会跟随 MCP for Unity 当前选择的传输方式(HTTP 或 stdio);另一些(Claude Desktop、Claude Code)在配置后会自动连接。 +5. **连接你的客户端:** 一些客户端(Cursor、Antigravity 2.0、Antigravity IDE、OpenClaw)需要在设置里启用 MCP 开关或插件。Antigravity 2.0 与 Antigravity IDE 是分开列出的:Antigravity 2.0 已迁移到 `~/.gemini/config/`,而 Antigravity IDE 仍使用 `~/.gemini/antigravity-ide/`;如果两者都在使用,请分别配置。OpenClaw 还需要启用 `openclaw-mcp-bridge` 插件,并会跟随 MCP for Unity 当前选择的传输方式(HTTP 或 stdio);另一些(Claude Desktop、Claude Code)在配置后会自动连接。 **就这些!** 试试这样的提示词:*"Create a red, blue and yellow cube"* 或 *"Build a simple player controller"*