Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

feat(mcp): one-click add of the editor to Claude Code, Cursor and Claude Desktop (desktop b2cb78f3)

yhh80b76cc35a67
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8e427fa80..993fe02cc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -52,6 +52,7 @@ published separately; it ships inside the editor.
- **Shaders that compile without stopping the frame.** `quality.asyncShaderCompile` (off unless a game turns it on): a draw whose shader the browser is still compiling is left out until it is ready, and every shader asked for in the meantime compiles at once, where before each was waited for in turn. On a first visit the Terrain & Water example's shaders took 43 seconds of a frozen page on Chrome and D3D11 (the heavy lit ones 3 to 10 seconds each, the worst frame 10 seconds); with this on the page was blocked for about a second in all and the whole scene was drawn at 20 seconds, not 56. The same scene, once everything has compiled, is the same picture. `renderer_getPendingShaders()` says how many are still compiling, for a loading screen. Off, nothing changes. WebGL2 only (a WebGPU pipeline is not compiled this way). With `quality.prewarmShaders` (and `prewarmTimeoutMs`, default 30 s) a packaged game draws its first scene out of sight behind the loading screen until nothing is compiling, and opens complete; `warmShaders(app)` does the same from code, `shadersCompiled(module)` waits for the queue, and a scene prepared ahead (`readyRenderPrograms`) now claims its programs ready only once they have compiled. The lit shaders also link about 23% faster on a first visit: a light that comes from the tiles no longer carries a second copy of the shadow lookup in the program.
- **A depth prepass for the opaque scene.** A quality level can draw the opaque meshes twice, depth alone first, so a pixel is shaded for the surface that is in front of it and not for every one drawn there on the way: `QualityProfile.depthPrepass` (on for `high` and `medium`, off for `low` and with the quality system off), and `renderer_setDepthPrepass` for a host without one. Cut-out leaves take part, with the coverage their own shader writes. A surface whose material bends its vertices with a hook takes part too, unless it is also a cut-out. On the Terrain & Water example, on an RTX 3060, a frame is 4 to 39 ms shorter, most where trees stand thick.
- **A third mesh for a plant.** A part of a world's plants can name `lod2Mesh` and its kind `lod2Distance`: past that distance the third mesh stands in for the cheaper one, until the kind stops being drawn as itself. The Terrain & Water example's trees have one (a tenth of the triangles, made by `tools/plant-lod2.mjs`) from 80 m, which takes 9 to 15 ms off a frame on an RTX 3060 where trees stand between 60 and 170 m. `tools/terrain-water-cost.mjs` measures what each part of that example costs a frame headless, and `docs/TERRAIN_WATER_GPU_COST.md` has the numbers.
+- **The editor adds itself to the AI tools on the machine.** Settings → External Agents has an "Add to …" switch for each installed Claude Code, Cursor and Claude Desktop: it writes only `mcpServers.estella` into that tool's config (the rest of the file is kept, an unparseable file is refused rather than overwritten), opens the agent endpoint, and its value is read off the file, so removing the entry by hand turns it off. The entry runs the bundled front on the editor's own executable, so no Node.js install or path lookup is needed, and "Let AI agents change the project" decides whether it carries write permission.
- **A generated world on worker threads.** A planet provider can give the engine its generator as `workerSource` (the text of a self-contained module), and the world's placements and the planet's pages (heights, normals, and the paint by the biomes) are then worked out by a pool of workers (`runtime/jobs.ts`), byte for byte what the main thread works out, while the main thread only puts each answer in the world as it arrives. Laying out a planet's world no longer costs the frame: 2 to 8 frames a second while it was laid out became 60.
- **A flat world's generation on worker threads too.** Laying out a `WorldGen` over a `Terrain` (a field or noise ground, with its baked water) is worked out by the same pool of workers, from the ground and the water handed over as data, byte for byte what the main thread works out. Stopping the terrain-water example no longer leaves the editor at 2 frames a second: it is back at 60.
- **A planet's sea and sky.** `Planet.sea` draws a translucent, lit sphere at `seaLevel` in which the ground that dips below it stands, and `skyAtmosphere` takes the planet's radius and centre (`u_planetRadius`, `u_planetX/Y/Z`, as `heightFog` does) to work the sky out in the frame of the ground the camera stands on, so the horizon, the sun and the haze follow it round.
diff --git a/desktop b/desktop
index d2e2b614c..b2cb78f33 160000
--- a/desktop
+++ b/desktop
@@ -1 +1 @@
-Subproject commit d2e2b614c23b95bf232c4f5e0cc9cb7b5528c213
+Subproject commit b2cb78f33cb887c4f671bf92089c34311f7f2a68
diff --git a/docs/astro/src/content/docs/agents/mcp.mdx b/docs/astro/src/content/docs/agents/mcp.mdx
index 7f16b6862..2ebff8158 100644
--- a/docs/astro/src/content/docs/agents/mcp.mdx
+++ b/docs/astro/src/content/docs/agents/mcp.mdx
@@ -20,6 +20,21 @@ Save. You can watch it work in the editor window, and take over at any time.
## Connecting an AI tool
+### One-click add
+
+Under **Settings → Editor → Tools & AI → External Agents** there is an "Add to …" switch
+for each of Claude Code, Cursor and Claude Desktop that is installed on the machine.
+Turning it on writes the editor into that tool's MCP config (only `mcpServers.estella`;
+everything else in the file is kept) and opens "Allow AI agents to connect". Turning it
+off removes just that entry. The switch shows what the file actually holds, so deleting
+the entry by hand turns it off.
+
+The entry runs the bundled script on the editor's own executable, so **no Node.js install
+is needed** and there is no path to look up. "Let AI agents change the project" is off by
+default: an agent can only look until you turn it on, and entries already added follow it.
+
+The manual setup below is for tools the switches do not cover.
+
The MCP server is a small node script that ships inside the editor. It talks MCP
over stdio to your AI tool and drives an editor instance for you (spawning one, or
attaching to one that's already open).
diff --git a/docs/astro/src/content/docs/zh-cn/agents/mcp.mdx b/docs/astro/src/content/docs/zh-cn/agents/mcp.mdx
index 3928c6663..e8629dcb5 100644
--- a/docs/astro/src/content/docs/zh-cn/agents/mcp.mdx
+++ b/docs/astro/src/content/docs/zh-cn/agents/mcp.mdx
@@ -18,6 +18,18 @@ Claude Code、Cursor,或你自己写的代理——都能驱动真实的编辑
## 接入 AI 工具
+### 一键加入
+
+打开**设置 → 编辑器 → 工具与 AI → 外部代理**,对本机已安装的 Claude Code、Cursor、
+Claude Desktop 各有一个"加入 …"开关。打开它,编辑器就把自己写进那个工具的 MCP 配置
+(只动 `mcpServers.estella` 这一条,其余内容原样保留),并同时开启"允许 AI 代理连接"。
+关掉开关只移除这一条。开关反映的是配置文件里的实际内容,所以手动删掉条目后它会自己变回关闭。
+
+写入的条目用编辑器自己的可执行文件运行内置脚本,**不需要另装 Node.js**,也不用找路径。
+"允许 AI 代理修改项目"默认关闭:不开时代理只能查看;开启后已加入的条目会自动更新。
+
+下面是手动配置,用于一键加入覆盖不到的工具。
+
MCP 服务器是随编辑器一起分发的一个小 node 脚本。它对你的 AI 工具讲 stdio MCP,
并为你驱动一个编辑器实例(拉起新的,或挂到已打开的那个上)。