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.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
refactor: extract MCP server to standalone repo as submodule
esengine1627bb6d8305
diff --git a/.gitmodules b/.gitmodulesindex 89228e200..e016fda66 100644--- a/.gitmodules+++ b/.gitmodules@@ -28,3 +28,6 @@path = third_party/spine-runtimes-4.2url = https://github.com/EsotericSoftware/spine-runtimes.gitbranch = 4.2+[submodule "tools/mcp-server"]+ path = tools/mcp-server+ url = https://github.com/esengine/estella-mcp-server.gitdiff --git a/docs/astro/astro.config.mjs b/docs/astro/astro.config.mjsindex 15d50475f..b11c40e97 100644--- a/docs/astro/astro.config.mjs+++ b/docs/astro/astro.config.mjs@@ -134,6 +134,7 @@ export default defineConfig({{ label: 'Game View', translations: { 'zh-CN': 'Game View' }, slug: 'guides/game-view' },{ label: 'Project Settings', translations: { 'zh-CN': '项目设置' }, slug: 'guides/project-settings' },{ label: 'Editor Extensions', translations: { 'zh-CN': '编辑器扩展' }, slug: 'guides/editor-extensions' },+ { label: 'MCP Server', translations: { 'zh-CN': 'MCP Server' }, slug: 'guides/mcp' },{ label: 'Profiler', translations: { 'zh-CN': '性能分析' }, slug: 'guides/profiler' },{ label: 'Debugging', translations: { 'zh-CN': '调试' }, slug: 'guides/debugging' },],diff --git a/docs/astro/src/content/docs/guides/mcp.mdx b/docs/astro/src/content/docs/guides/mcp.mdxnew file mode 100644index 000000000..b1659a4e9--- /dev/null+++ b/docs/astro/src/content/docs/guides/mcp.mdx@@ -0,0 +1,176 @@+---+title: MCP Server+description: AI-assisted editing via Model Context Protocol+---++import { Aside, Tabs, TabItem } from '@astrojs/starlight/components';++The Estella editor includes a built-in **MCP (Model Context Protocol)** bridge that allows AI assistants like Claude to read and modify your scene in real-time. The MCP server acts as a thin wrapper that translates MCP tool calls into HTTP requests to the running editor.++<Aside type="note">+ The MCP bridge starts automatically when the editor launches — no configuration needed on the editor side.+</Aside>++## Prerequisites++- Estella editor v0.10.0 or later+- Node.js 18++- An MCP-compatible AI client (e.g., Claude Desktop, Claude Code, Cursor)++## Installation++Configure your AI client to use the MCP server. No separate install step is needed — `npx` fetches it directly from GitHub.++<Tabs>+ <TabItem label="Claude Code">++Add to your project's `.mcp.json`:++```json+{+ "mcpServers": {+ "estella-editor": {+ "command": "npx",+ "args": ["-y", "github:esengine/estella-mcp-server"]+ }+ }+}+```++ </TabItem>+ <TabItem label="Claude Desktop">++Add to `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):++```json+{+ "mcpServers": {+ "estella-editor": {+ "command": "npx",+ "args": ["-y", "github:esengine/estella-mcp-server"]+ }+ }+}+```++ </TabItem>+ <TabItem label="Cursor">++Add to `.cursor/mcp.json` in your project root:++```json+{+ "mcpServers": {+ "estella-editor": {+ "command": "npx",+ "args": ["-y", "github:esengine/estella-mcp-server"]+ }+ }+}+```++ </TabItem>+</Tabs>++### 3. Start the editor++Open your project in the Estella editor. The MCP bridge automatically registers itself at `~/.esengine/bridge-<port>.json`, which the MCP server discovers on startup.++## How It Works++```+AI Client ←→ MCP Server (stdio) ←→ HTTP Bridge ←→ Estella Editor+```++1. The editor starts an HTTP bridge server on a random available port+2. It writes a discovery file to `~/.esengine/bridge-<port>.json`+3. The MCP server reads the discovery file to find the running editor+4. AI tool calls are translated to HTTP GET/POST requests++## Available Tools++### Scene Inspection++| Tool | Description |+|------|-------------|+| `get_hierarchy` | List all entities in the scene tree |+| `get_entity` | Get entity data (all components and properties) |+| `get_component` | Get a specific component's properties |+| `get_children` | List child entities |+| `list_assets` | List project assets by type |+| `read_asset` | Read an asset file's content |++### Entity Operations++| Tool | Description |+|------|-------------|+| `create_entity` | Create a new entity (optionally under a parent) |+| `delete_entity` | Delete an entity |+| `rename_entity` | Rename an entity |+| `reparent_entity` | Move an entity to a new parent |+| `add_component` | Add a component to an entity |+| `remove_component` | Remove a component from an entity |++### Property Editing++| Tool | Description |+|------|-------------|+| `set_property` | Set a component property value (with undo support) |+| `get_selection` | Get the currently selected entity |+| `select_entity` | Select an entity in the editor |++### Timeline++| Tool | Description |+|------|-------------|+| `get_timeline` | Read timeline data for an entity |+| `update_timeline` | Modify timeline tracks, keyframes, or properties |+| `write_asset` | Write modified asset data back to disk |++### Play Mode++| Tool | Description |+|------|-------------|+| `play` | Enter play mode |+| `stop` | Exit play mode |+| `pause` | Pause/resume play mode |+| `set_play_speed` | Adjust playback speed |++### Visual++| Tool | Description |+|------|-------------|+| `screenshot` | Capture a screenshot of the current viewport |+| `screenshot_diff` | Compare two screenshots pixel-by-pixel |++## Example Prompts++Once configured, you can ask your AI assistant things like:++- "Show me all the entities in the scene"+- "Change the player's position to (100, 200)"+- "Add a Sprite component to the Background entity"+- "Set the idle animation speed to 0.5x"+- "Take a screenshot and tell me what's on screen"++## Troubleshooting++### MCP server says "No running ESEngine editor found"++- Make sure the Estella editor is running with a project open+- Check that `~/.esengine/` contains a `bridge-*.json` file+- If the file exists but the editor was closed, delete stale bridge files++### Connection refused errors++The bridge server binds to `127.0.0.1`. If using a proxy, ensure localhost traffic is not proxied:++```bash+curl --noproxy '*' http://127.0.0.1:<port>/health+```++### Tools return errors++- Ensure the editor has a scene loaded+- Entity IDs are numeric — use `get_hierarchy` first to find valid IDs+- Component names are case-sensitive (e.g., `Transform`, `Sprite`, `SpineAnimation`)diff --git a/docs/astro/src/content/docs/zh/guides/mcp.mdx b/docs/astro/src/content/docs/zh/guides/mcp.mdxnew file mode 100644index 000000000..e293215e1--- /dev/null+++ b/docs/astro/src/content/docs/zh/guides/mcp.mdx@@ -0,0 +1,176 @@+---+title: MCP Server+description: 通过 Model Context Protocol 实现 AI 辅助编辑+---++import { Aside, Tabs, TabItem } from '@astrojs/starlight/components';++Estella 编辑器内置 **MCP(Model Context Protocol)** 桥接器,允许 Claude 等 AI 助手实时读取和修改你的场景。MCP 服务器将 MCP 工具调用转换为对运行中编辑器的 HTTP 请求。++<Aside type="note">+ MCP 桥接器在编辑器启动时自动运行,编辑器侧无需任何配置。+</Aside>++## 前提条件++- Estella 编辑器 v0.10.0 或更高版本+- Node.js 18++- MCP 兼容的 AI 客户端(如 Claude Desktop、Claude Code、Cursor)++## 安装++配置你的 AI 客户端使用 MCP 服务器。无需额外安装步骤——`npx` 直接从 GitHub 获取。++<Tabs>+ <TabItem label="Claude Code">++在项目根目录的 `.mcp.json` 中添加:++```json+{+ "mcpServers": {+ "estella-editor": {+ "command": "npx",+ "args": ["-y", "github:esengine/estella-mcp-server"]+ }+ }+}+```++ </TabItem>+ <TabItem label="Claude Desktop">++添加到 `~/Library/Application Support/Claude/claude_desktop_config.json`(macOS)或 `%APPDATA%\Claude\claude_desktop_config.json`(Windows):++```json+{+ "mcpServers": {+ "estella-editor": {+ "command": "npx",+ "args": ["-y", "github:esengine/estella-mcp-server"]+ }+ }+}+```++ </TabItem>+ <TabItem label="Cursor">++在项目根目录的 `.cursor/mcp.json` 中添加:++```json+{+ "mcpServers": {+ "estella-editor": {+ "command": "npx",+ "args": ["-y", "github:esengine/estella-mcp-server"]+ }+ }+}+```++ </TabItem>+</Tabs>++### 3. 启动编辑器++在 Estella 编辑器中打开项目。MCP 桥接器会自动在 `~/.esengine/bridge-<port>.json` 注册,MCP 服务器启动时通过此文件发现编辑器。++## 工作原理++```+AI 客户端 ←→ MCP Server (stdio) ←→ HTTP Bridge ←→ Estella 编辑器+```++1. 编辑器在随机可用端口启动 HTTP 桥接服务器+2. 写入发现文件到 `~/.esengine/bridge-<port>.json`+3. MCP 服务器读取发现文件找到运行中的编辑器+4. AI 工具调用被转换为 HTTP GET/POST 请求++## 可用工具++### 场景检查++| 工具 | 说明 |+|------|------|+| `get_hierarchy` | 列出场景树中的所有实体 |+| `get_entity` | 获取实体数据(所有组件和属性) |+| `get_component` | 获取指定组件的属性 |+| `get_children` | 列出子实体 |+| `list_assets` | 按类型列出项目资源 |+| `read_asset` | 读取资源文件内容 |++### 实体操作++| 工具 | 说明 |+|------|------|+| `create_entity` | 创建新实体(可指定父实体) |+| `delete_entity` | 删除实体 |+| `rename_entity` | 重命名实体 |+| `reparent_entity` | 将实体移动到新的父级 |+| `add_component` | 为实体添加组件 |+| `remove_component` | 移除实体的组件 |++### 属性编辑++| 工具 | 说明 |+|------|------|+| `set_property` | 设置组件属性值(支持撤销) |+| `get_selection` | 获取当前选中的实体 |+| `select_entity` | 在编辑器中选中实体 |++### 时间轴++| 工具 | 说明 |+|------|------|+| `get_timeline` | 读取实体的时间轴数据 |+| `update_timeline` | 修改时间轴轨道、关键帧或属性 |+| `write_asset` | 将修改后的资源数据写回磁盘 |++### Play 模式++| 工具 | 说明 |+|------|------|+| `play` | 进入 Play 模式 |+| `stop` | 退出 Play 模式 |+| `pause` | 暂停/恢复 |+| `set_play_speed` | 调整播放速度 |++### 视觉++| 工具 | 说明 |+|------|------|+| `screenshot` | 截取当前视口的截图 |+| `screenshot_diff` | 逐像素比较两张截图 |++## 示例提示++配置完成后,你可以这样向 AI 助手提问:++- "显示场景中的所有实体"+- "把玩家的位置改成 (100, 200)"+- "给 Background 实体添加一个 Sprite 组件"+- "把 idle 动画速度设为 0.5 倍"+- "截个图告诉我屏幕上有什么"++## 故障排除++### MCP 服务器提示 "No running ESEngine editor found"++- 确保 Estella 编辑器正在运行且已打开项目+- 检查 `~/.esengine/` 目录下是否有 `bridge-*.json` 文件+- 如果文件存在但编辑器已关闭,删除过期的 bridge 文件++### 连接被拒绝++桥接服务器绑定在 `127.0.0.1`。如果使用了代理,确保 localhost 流量不经过代理:++```bash+curl --noproxy '*' http://127.0.0.1:<port>/health+```++### 工具返回错误++- 确保编辑器已加载场景+- 实体 ID 是数字——先用 `get_hierarchy` 查找有效的 ID+- 组件名称区分大小写(如 `Transform`、`Sprite`、`SpineAnimation`)diff --git a/tools/mcp-server b/tools/mcp-servernew file mode 160000index 000000000..48254fef8--- /dev/null+++ b/tools/mcp-server@@ -0,0 +1 @@+Subproject commit 48254fef82f830429f69a89b6bcf5196ef52d1d1diff --git a/tools/mcp-server/package.json b/tools/mcp-server/package.jsondeleted file mode 100644index acb133adf..000000000--- a/tools/mcp-server/package.json+++ /dev/null@@ -1,37 +0,0 @@-{- "name": "@esengine/mcp-server",- "version": "0.1.0",- "type": "module",- "description": "MCP server for AI-assisted editing in the Estella game engine editor",- "repository": {- "type": "git",- "url": "https://github.com/esengine/estella.git",- "directory": "tools/mcp-server"- },- "publishConfig": {- "registry": "https://npm.pkg.github.com"- },- "main": "dist/index.js",- "bin": {- "estella-mcp-server": "dist/index.js"- },- "files": [- "dist"- ],- "scripts": {- "build": "tsc",- "dev": "tsc --watch",- "prepublishOnly": "tsc"- },- "dependencies": {- "@modelcontextprotocol/sdk": "^1.12.1",- "pixelmatch": "^6.0.0",- "pngjs": "^7.0.0",- "zod": "^3.24.4"- },- "devDependencies": {- "@types/node": "^22.15.3",- "@types/pngjs": "^6.0.5",- "typescript": "^5.8.3"- }-}diff --git a/tools/mcp-server/src/bridge.ts b/tools/mcp-server/src/bridge.tsdeleted file mode 100644index 3512cc8e6..000000000--- a/tools/mcp-server/src/bridge.ts+++ /dev/null@@ -1,91 +0,0 @@-import { readdir, readFile } from 'node:fs/promises';-import { join } from 'node:path';-import { homedir } from 'node:os';--interface BridgeInfo {- port: number;- pid: number;- projectPath: string;-}--export class BridgeClient {- private baseUrl_: string | null = null;-- async discover(projectPath?: string): Promise<boolean> {- const dir = join(homedir(), '.esengine');- let files: string[];- try {- files = await readdir(dir);- } catch {- return false;- }-- const bridges: BridgeInfo[] = [];- for (const file of files) {- if (!file.startsWith('bridge-') || !file.endsWith('.json')) continue;- try {- const content = await readFile(join(dir, file), 'utf-8');- const info = JSON.parse(content) as BridgeInfo;- if (isProcessAlive(info.pid)) {- bridges.push(info);- }- } catch {- continue;- }- }-- if (bridges.length === 0) return false;-- if (projectPath) {- const match = bridges.find(b => b.projectPath === projectPath);- if (match) {- this.baseUrl_ = `http://127.0.0.1:${match.port}`;- return true;- }- }-- this.baseUrl_ = `http://127.0.0.1:${bridges[0].port}`;- return true;- }-- get connected(): boolean {- return this.baseUrl_ !== null;- }-- async get(path: string): Promise<unknown> {- if (!this.baseUrl_) throw new Error('Editor is not running');- const res = await fetch(`${this.baseUrl_}${path}`);- if (!res.ok) {- const body = await res.text();- throw new Error(`Bridge error (${res.status}): ${body}`);- }- return res.json();- }-- async post(path: string, body: unknown): Promise<unknown> {- if (!this.baseUrl_) throw new Error('Editor is not running');- const res = await fetch(`${this.baseUrl_}${path}`, {- method: 'POST',- headers: { 'Content-Type': 'application/json' },- body: JSON.stringify(body),- });- if (!res.ok) {- const text = await res.text();- throw new Error(`Bridge error (${res.status}): ${text}`);- }- return res.json();- }-- async health(): Promise<unknown> {- return this.get('/health');- }-}--function isProcessAlive(pid: number): boolean {- try {- process.kill(pid, 0);- return true;- } catch {- return false;- }-}diff --git a/tools/mcp-server/src/index.ts b/tools/mcp-server/src/index.tsdeleted file mode 100644index 222565e9d..000000000--- a/tools/mcp-server/src/index.ts+++ /dev/null@@ -1,38 +0,0 @@-#!/usr/bin/env node--import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';-import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';-import { BridgeClient } from './bridge.js';-import { registerSceneTools } from './tools/scene.js';-import { registerStateTools } from './tools/state.js';-import { registerActionTools } from './tools/actions.js';-import { registerVisualTools } from './tools/visual.js';-import { registerResources } from './resources.js';--const bridge = new BridgeClient();--const server = new McpServer({- name: 'esengine-editor',- version: '0.1.0',-});--registerSceneTools(server, bridge);-registerStateTools(server, bridge);-registerActionTools(server, bridge);-registerVisualTools(server, bridge);-registerResources(server, bridge);--async function main(): Promise<void> {- const discovered = await bridge.discover();- if (!discovered) {- console.error('[MCP] No running ESEngine editor found. Start the editor first.');- }-- const transport = new StdioServerTransport();- await server.connect(transport);-}--main().catch((e) => {- console.error('[MCP] Fatal error:', e);- process.exit(1);-});diff --git a/tools/mcp-server/src/resources.ts b/tools/mcp-server/src/resources.tsdeleted file mode 100644index 58fcbadbb..000000000--- a/tools/mcp-server/src/resources.ts+++ /dev/null@@ -1,113 +0,0 @@-import type { BridgeClient } from './bridge.js';-import { SDK_API_REFERENCE } from './sdk-reference.js';--export function registerResources(- server: { resource: Function; prompt: Function },- bridge: BridgeClient,-): void {- server.resource(- 'editor://sdk-api',- 'editor://sdk-api',- 'ESEngine SDK API reference: defineComponent, defineSystem, Query, Schedule, built-in components, script template',- async () => ({- contents: [{- uri: 'editor://sdk-api',- text: SDK_API_REFERENCE,- mimeType: 'text/markdown',- }],- }),- );-- server.resource(- 'editor://components',- 'editor://components',- 'All registered component types grouped by category',- async () => {- const result = await bridge.get('/components/list');- return {- contents: [{- uri: 'editor://components',- text: JSON.stringify(result, null, 2),- mimeType: 'application/json',- }],- };- },- );-- server.resource(- 'editor://assets',- 'editor://assets',- 'All project assets with UUIDs, paths, and types',- async () => {- const result = await bridge.get('/assets/list');- return {- contents: [{- uri: 'editor://assets',- text: JSON.stringify(result, null, 2),- mimeType: 'application/json',- }],- };- },- );-- server.prompt(- 'create-game-object',- 'Guide: create a game entity with components and script',- [],- async () => ({- messages: [{- role: 'user' as const,- content: {- type: 'text' as const,- text: 'I want to create a new game object. Please:\n' +- '1. Read editor://sdk-api resource to understand the API\n' +- '2. Use list_components to see available component types\n' +- '3. Use create_entity with the appropriate components\n' +- '4. If custom behavior is needed, use create_script to write a script\n' +- '5. Use reload_scripts after creating scripts\n' +- '6. Use set_property to configure component values\n' +- '7. Use save_scene to persist changes',- },- }],- }),- );-- server.prompt(- 'inspect-ui',- 'Inspect UI: capture screenshot, get selection, entity data, and console logs',- [],- async () => ({- messages: [{- role: 'user' as const,- content: {- type: 'text' as const,- text: 'Please inspect the current UI state. Use these tools in order:\n' +- '1. capture_editor - take a screenshot\n' +- '2. get_selection - see what is selected\n' +- '3. get_entity_data - get selected entity details\n' +- '4. get_console_logs - check for errors\n\n' +- 'Then provide analysis and suggestions.',- },- }],- }),- );-- server.prompt(- 'review-layout',- 'Review layout: capture screenshot, get panel layout, and render stats',- [],- async () => ({- messages: [{- role: 'user' as const,- content: {- type: 'text' as const,- text: 'Please review the editor layout. Use these tools:\n' +- '1. capture_editor - take a screenshot\n' +- '2. get_panel_layout - get panel positions\n' +- '3. get_render_stats - check performance\n\n' +- 'Then analyze the layout and suggest improvements.',- },- }],- }),- );-}diff --git a/tools/mcp-server/src/sdk-reference.ts b/tools/mcp-server/src/sdk-reference.tsdeleted file mode 100644index 6b7df21bb..000000000--- a/tools/mcp-server/src/sdk-reference.ts+++ /dev/null@@ -1,472 +0,0 @@-export const SDK_API_REFERENCE = `-# ESEngine SDK API Reference--## Imports-\`\`\`typescript-import {- // Component- defineComponent, defineTag, getComponent,- // System- defineSystem, addSystem, addStartupSystem, addSystemToSchedule, Schedule,- // Query- Query, Removed,- // Resources- Res, ResMut, defineResource,- // Commands- Commands,- // Events- defineEvent, EventReader, EventWriter,- // World access- GetWorld,- // Built-in components- Transform, Sprite, Camera, Name, Parent, Children, Velocity,- SpriteAnimator, SpineAnimation, Tilemap, TilemapLayer,- AudioSource, AudioListener, ParticleEmitter, ShapeRenderer,- PostProcessVolume, TimelinePlayer,- // Types- type Entity, type World, type ComponentDef,-} from 'esengine';--import {- // Physics- RigidBody, BoxCollider, CircleCollider, CapsuleCollider,- PolygonCollider, ChainCollider, SegmentCollider,- RevoluteJoint, DistanceJoint, PrismaticJoint, WeldJoint, WheelJoint,- Physics,-} from 'esengine/physics';--import {- // UI- UIRect, Canvas, Image, Text, BitmapText, Button, Toggle, ToggleGroup,- Slider, ProgressBar, ScrollView, Dropdown, TextInput, ListView,- Interactable, Focusable, UIMask, FlexContainer, FlexItem,- LayoutGroup, SafeArea, Draggable, DragState, UIRenderer,-} from 'esengine';-\`\`\`--## defineComponent-Define a custom component with default values. The editor auto-registers it.-\`\`\`typescript-export const Health = defineComponent('Health', {- current: 100,- max: 100,- invincible: false,-});--// With nested objects-export const Movement = defineComponent('Movement', {- speed: 5,- direction: { x: 0, y: 0 },- grounded: false,-});-\`\`\`--## defineTag-Define a tag component (no data, just marks entities).-\`\`\`typescript-export const Enemy = defineTag('Enemy');-export const Player = defineTag('Player');-\`\`\`--## defineSystem-Define a system with typed parameters. Parameters are injected automatically.-\`\`\`typescript-// Query entities with Transform and Velocity-const movementSystem = defineSystem(- [Query(Transform, Velocity)],- (query) => {- for (const [transform, velocity] of query) {- transform.position.x += velocity.linear.x;- transform.position.y += velocity.linear.y;- }- },-);--// Access resources-const scoreSystem = defineSystem(- [Query(Player), Res(ScoreResource)],- (players, score) => {- // score is read-only- },-);--// Mutable resource access-const timerSystem = defineSystem(- [ResMut(GameTimer)],- (timer) => {- timer.elapsed += timer.deltaTime;- },-);--// Spawn/despawn entities-const spawnerSystem = defineSystem(- [Commands(), Query(Spawner)],- (commands, spawners) => {- for (const [spawner] of spawners) {- if (spawner.shouldSpawn) {- const e = commands.spawn();- commands.insert(e, Transform, { position: { x: 0, y: 0, z: 0 }, rotation: { x: 0, y: 0, z: 0, w: 1 }, scale: { x: 1, y: 1, z: 1 } });- commands.insert(e, Sprite, { size: { x: 32, y: 32 } });- }- }- },-);--// Events-const damageSystem = defineSystem(- [EventReader(DamageEvent), Query(Health)],- (events, healths) => {- for (const event of events) {- // handle damage- }- },-);--// Direct world access-const worldSystem = defineSystem(- [GetWorld()],- (world) => {- const entity = world.spawn();- world.insert(entity, Transform, { ... });- if (world.valid(entity)) {- const t = world.tryGet(entity, Transform);- }- world.despawn(entity);- },-);--// Removed query (entities that just had a component removed)-const cleanupSystem = defineSystem(- [Removed(Health)],- (removed) => {- for (const entity of removed) {- console.log('Entity lost Health:', entity);- }- },-);-\`\`\`--## Schedule (execution order)-\`\`\`-Startup — runs once at app start-First — runs every frame, before everything-FixedPreUpdate — fixed timestep, before physics-FixedUpdate — fixed timestep, physics step-FixedPostUpdate— fixed timestep, after physics-PreUpdate — before main update-Update — main game logic (default)-PostUpdate — after main update (cleanup, camera follow)-Last — end of frame-\`\`\`--### Registering systems-\`\`\`typescript-addSystem(movementSystem); // Update schedule (default)-addStartupSystem(initSystem); // Startup (runs once)-addSystemToSchedule(Schedule.PostUpdate, cameraSystem); // Specific schedule-addSystemToSchedule(Schedule.FixedUpdate, physicsStep); // Fixed timestep-\`\`\`--## defineResource-\`\`\`typescript-export const GameState = defineResource('GameState', {- score: 0,- level: 1,- paused: false,-});-\`\`\`--## defineEvent-\`\`\`typescript-export const DamageEvent = defineEvent<{ target: Entity; amount: number }>('DamageEvent');--// Write events-const attackSystem = defineSystem(- [EventWriter(DamageEvent)],- (writer) => {- writer.send({ target: someEntity, amount: 10 });- },-);-\`\`\`--## Query Filters-\`\`\`typescript-// With: entities that have both Transform AND Sprite-Query(Transform, Sprite)--// Optional component (may be undefined)-Query(Transform).optionally(Velocity)--// Without: exclude entities that have Enemy tag-Query(Transform).without(Enemy)--// Iteration-for (const [transform, sprite] of query) { ... }--// Get specific entity's components-const result = query.get(entity); // returns tuple or undefined-\`\`\`--## Built-in Component Defaults--### Transform-\`\`\`typescript-{- position: { x: 0, y: 0, z: 0 },- rotation: { x: 0, y: 0, z: 0, w: 1 }, // quaternion- scale: { x: 1, y: 1, z: 1 },-}-\`\`\`--### Sprite-\`\`\`typescript-{- texture: "", // asset UUID or relative path (empty = no texture)- size: { x: 100, y: 100 },- pivot: { x: 0.5, y: 0.5 },- color: { r: 1, g: 1, b: 1, a: 1 },- flipX: false,- flipY: false,- layer: 0,- enabled: true,-}-\`\`\`--### Camera-\`\`\`typescript-{- size: 5, // orthographic half-height- near: -1000,- far: 1000,- clearColor: { r: 0.2, g: 0.2, b: 0.2, a: 1 },- enabled: true,-}-\`\`\`--### RigidBody-\`\`\`typescript-{- bodyType: 0, // 0=Dynamic, 1=Kinematic, 2=Static- gravityScale: 1,- linearDamping: 0,- angularDamping: 0,- fixedRotation: false,- bullet: false,- enabled: true,-}-\`\`\`--### UIRect-\`\`\`typescript-{- anchorMin: { x: 0.5, y: 0.5 },- anchorMax: { x: 0.5, y: 0.5 },- offsetMin: { x: -50, y: -50 },- offsetMax: { x: 50, y: 50 },- pivot: { x: 0.5, y: 0.5 },-}-\`\`\`--## Script File Template-A typical user script file:-\`\`\`typescript-import {- defineComponent, defineSystem, defineTag,- Query, Commands, Res, addSystem, addSystemToSchedule, Schedule,- Transform, Sprite,- type Entity, type World,-} from 'esengine';--// 1. Define components-export const PlayerData = defineComponent('PlayerData', {- speed: 200,- jumpForce: 400,- health: 100,-});--export const IsPlayer = defineTag('IsPlayer');--// 2. Define systems-const playerMovement = defineSystem(- [Query(Transform, PlayerData)],- (query) => {- for (const [transform, player] of query) {- // movement logic- }- },- { name: 'PlayerMovement' },-);--// 3. Register systems-addSystem(playerMovement);-\`\`\`--## Property Value Types-When using \`set_property\`, values must match these formats:-\`\`\`-number → 42 or 3.14-string → "hello"-boolean → true / false-vec2 → { x: number, y: number }-vec3 → { x: number, y: number, z: number }-vec4 → { x: number, y: number, z: number, w: number }-color → { r: 0-1, g: 0-1, b: 0-1, a: 0-1 }-padding → { left: number, top: number, right: number, bottom: number }-vec2-array→ [{ x, y }, { x, y }, ...]-\`\`\`--## Asset Referencing-In the editor and scene files, asset fields (texture, clip, font, material, etc.) store **UUID strings** (preferred) or **relative paths**.-- **UUIDs** (stable, preferred): \`"a1b2c3d4-e5f6-7890-abcd-ef1234567890"\`-- **Relative paths** (fallback): \`"assets/textures/player.png"\`-- Use \`list_assets\` to find assets and get their UUIDs-- When setting asset fields via \`set_property\`, pass the UUID or relative path as a string-- To clear an asset field, set it to \`""\` (empty string)-- At runtime (C++/WASM), these are resolved to numeric handles internally — you don't need to deal with handles--## UI Components--### Canvas-Root container for UI elements. All UI entities must be children of a Canvas entity.-\`\`\`typescript-{ renderMode: 0, designResolution: { x: 1080, y: 1920 }, matchMode: 0 }-\`\`\`--### UIRect-Anchored rectangle layout (required on all UI elements under Canvas).-\`\`\`typescript-{- anchorMin: { x: 0.5, y: 0.5 }, // 0-1, relative to parent- anchorMax: { x: 0.5, y: 0.5 },- offsetMin: { x: -50, y: -50 }, // pixels from anchor- offsetMax: { x: 50, y: 50 },- pivot: { x: 0.5, y: 0.5 },-}-\`\`\`--### Image-\`\`\`typescript-{ source: "", color: { r: 1, g: 1, b: 1, a: 1 }, type: 0, enabled: true }-// source: asset UUID or relative path (empty = no image)-// type: 0=Simple, 1=Sliced, 2=Tiled, 3=Filled-\`\`\`--### Text-\`\`\`typescript-{- content: "Hello",- fontSize: 24,- color: { r: 1, g: 1, b: 1, a: 1 },- align: 0, // 0=Left, 1=Center, 2=Right- verticalAlign: 0, // 0=Top, 1=Middle, 2=Bottom- lineSpacing: 0,- overflow: 0, // 0=Overflow, 1=Truncate, 2=Wrap-}-\`\`\`--### Button-Requires: Interactable + Image on same entity. Use a child Text entity for the label.-\`\`\`typescript-{ normalColor: { r: 1, g: 1, b: 1, a: 1 }, pressedColor: ..., disabledColor: ... }-\`\`\`--### Toggle-\`\`\`typescript-{ isOn: false, toggleGroup: null }-\`\`\`--### Slider-\`\`\`typescript-{ value: 0, minValue: 0, maxValue: 1, wholeNumbers: false, direction: 0 }-\`\`\`--### ScrollView-\`\`\`typescript-{ horizontal: true, vertical: true, movementType: 0, elasticity: 0.1, inertia: true }-\`\`\`--### Interactable-Required for any interactive UI element (Button, Toggle, Slider, etc.).-\`\`\`typescript-{ interactable: true }-\`\`\`--## Query Advanced Patterns-\`\`\`typescript-// Optional component (may be undefined in tuple)-const q = Query(Transform).optionally(Velocity);-for (const [transform, velocity] of q) {- if (velocity) { /* has velocity */ }-}--// Without filter (exclude entities)-Query(Transform, Sprite).without(Disabled)--// Combining-Query(Transform).with(Sprite).without(Enemy).optionally(Health)--// Removed query (entities that just lost a component this frame)-const cleanup = defineSystem(- [Removed(Health)],- (removed) => { for (const entity of removed) { ... } },-);-\`\`\`--## Draw API (Immediate Mode Drawing)-\`\`\`typescript-import { Draw } from 'esengine';--const debugDrawSystem = defineSystem(- [Query(Transform)],- (query) => {- for (const [transform] of query) {- Draw.circle(transform.position, 10, { r: 0, g: 1, b: 0, a: 0.5 });- Draw.rect(transform.position, { x: 20, y: 20 }, { r: 1, g: 0, b: 0, a: 0.3 });- Draw.line({ x: 0, y: 0 }, transform.position, { r: 1, g: 1, b: 1, a: 1 });- }- },-);-addSystemToSchedule(Schedule.PostUpdate, debugDrawSystem);-\`\`\`--## Audio-\`\`\`typescript-import { Audio } from 'esengine';--Audio.play('assets/audio/click.wav');-Audio.playMusic('assets/audio/bgm.mp3', { loop: true, volume: 0.5 });-Audio.stopAll();-Audio.setMasterVolume(0.8);-\`\`\`--## Common Entity Patterns--### Sprite Entity-\`\`\`-create_entity: { name, components: [- { type: "Transform", data: { position: { x, y, z: 0 } } },- { type: "Sprite", data: { texture: "<uuid-or-path>", size: { x, y } } }-]}-// Use list_assets to find the asset UUID, then pass it as the texture value-\`\`\`--### UI Button-\`\`\`-1. Create Canvas entity (if not exists): Canvas + UIRect + Transform-2. Create Button entity as child:- - Transform + UIRect + Image + Interactable + Button-3. Create Label as child of Button:- - Transform + UIRect + Text (content: "Click Me")-\`\`\`--### Physics Entity-\`\`\`-create_entity: { name, components: [- { type: "Transform" },- { type: "Sprite" },- { type: "RigidBody", data: { bodyType: 0 } }, // 0=Dynamic- { type: "BoxCollider", data: { size: { x: 1, y: 1 } } }-]}-\`\`\`-\`\`\`-`;diff --git a/tools/mcp-server/src/tools/actions.ts b/tools/mcp-server/src/tools/actions.tsdeleted file mode 100644index 673317a2d..000000000--- a/tools/mcp-server/src/tools/actions.ts+++ /dev/null@@ -1,117 +0,0 @@-import { z } from 'zod';-import type { BridgeClient } from '../bridge.js';--export function registerActionTools(- server: { tool: Function },- bridge: BridgeClient,-): void {- server.tool(- 'select_entity',- 'Select an entity in the editor by ID or name',- {- entity: z.union([z.number(), z.string()]).describe('Entity ID (number) or name (string)'),- },- async (args: { entity: number | string }) => {- const result = await bridge.post('/action/select', { entity: args.entity });- return { content: [{ type: 'text' as const, text: JSON.stringify(result) }] };- },- );-- server.tool(- 'set_property',- `Set a component property on an entity (supports undo).-Common component fields:-- Transform: position {x,y,z}, rotation {x,y,z,w}, scale {x,y,z}-- Sprite: texture (UUID), color {r,g,b,a}, size {x,y}, enabled, flipX, flipY-- TimelinePlayer: timeline (asset UUID), playing (bool), speed (number), wrapMode ("once"|"loop"|"pingPong")-- SpriteAnimator: clip (esanim asset UUID or registered name), playing (bool)-- Camera: orthoSize (number)-Use get_component_schema for full field list of any component.`,- {- entity: z.union([z.number(), z.string()]).describe('Entity ID or name'),- component: z.string().describe('Component type (e.g., "Transform", "Sprite")'),- field: z.string().describe('Property name'),- value: z.unknown().describe('New value'),- },- async (args: { entity: number | string; component: string; field: string; value: unknown }) => {- const result = await bridge.post('/action/set-property', args);- return { content: [{ type: 'text' as const, text: JSON.stringify(result) }] };- },- );-- server.tool(- 'execute_menu',- 'Execute an editor menu action by dot-separated ID (e.g., "file.save", "edit.undo")',- {- id: z.string().describe('Menu item ID (dot-separated, e.g., "file.save")'),- },- async (args: { id: string }) => {- const result = await bridge.post('/action/menu', { id: args.id });- return { content: [{ type: 'text' as const, text: JSON.stringify(result) }] };- },- );-- server.tool(- 'toggle_play_mode',- 'Toggle between Play and Edit mode in the editor',- {},- async () => {- const result = await bridge.post('/action/play-mode', {});- return { content: [{ type: 'text' as const, text: JSON.stringify(result) }] };- },- );-- server.tool(- 'save_scene',- 'Save the current scene',- {},- async () => {- const result = await bridge.post('/action/save-scene', {});- return { content: [{ type: 'text' as const, text: JSON.stringify(result) }] };- },- );-- server.tool(- 'reload_scripts',- 'Reload and recompile user scripts',- {},- async () => {- const result = await bridge.post('/action/reload-scripts', {});- return { content: [{ type: 'text' as const, text: JSON.stringify(result) }] };- },- );-- server.tool(- 'undo',- 'Undo the last editor action',- {},- async () => {- const result = await bridge.post('/action/undo', {});- return { content: [{ type: 'text' as const, text: JSON.stringify(result) }] };- },- );-- server.tool(- 'redo',- 'Redo the last undone editor action',- {},- async () => {- const result = await bridge.post('/action/redo', {});- return { content: [{ type: 'text' as const, text: JSON.stringify(result) }] };- },- );-- server.tool(- 'create_script',- 'Create a new TypeScript script file in the project. Read editor://sdk-api resource first to understand the API.',- {- name: z.string().describe('Script name (e.g., "PlayerController")'),- content: z.string().optional().describe('Script content (default: component template)'),- dir: z.string().optional().describe('Directory relative to project root (default: "src")'),- },- async (args: { name: string; content?: string; dir?: string }) => {- const result = await bridge.post('/scripts/create', args);- return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }] };- },- );-}diff --git a/tools/mcp-server/src/tools/scene.ts b/tools/mcp-server/src/tools/scene.tsdeleted file mode 100644index 9c3c79e6c..000000000--- a/tools/mcp-server/src/tools/scene.ts+++ /dev/null@@ -1,212 +0,0 @@-import { z } from 'zod';-import type { BridgeClient } from '../bridge.js';--export function registerSceneTools(- server: { tool: Function },- bridge: BridgeClient,-): void {- server.tool(- 'get_scene_tree',- 'Get the entity hierarchy of the current scene',- { depth: z.number().optional().describe('Max tree depth') },- async (args: { depth?: number }) => {- const query = args.depth != null ? `?depth=${args.depth}` : '';- const result = await bridge.get(`/scene/tree${query}`);- return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }] };- },- );-- server.tool(- 'get_entity_data',- 'Get all component data for an entity by ID or name',- {- entity: z.union([z.number(), z.string()]).describe('Entity ID (number) or name (string)'),- },- async (args: { entity: number | string }) => {- const param = typeof args.entity === 'number' ? `id=${args.entity}` : `name=${encodeURIComponent(args.entity)}`;- const result = await bridge.get(`/scene/entity?${param}`);- return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }] };- },- );-- server.tool(- 'get_selection',- 'Get currently selected entities and asset in the editor',- {},- async () => {- const result = await bridge.get('/scene/selection');- return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }] };- },- );-- server.tool(- 'find_entities',- 'Find entities by name (fuzzy match) or component type (exact match)',- { query: z.string().describe('Search query: entity name or component type') },- async (args: { query: string }) => {- const result = await bridge.get(`/scene/find?query=${encodeURIComponent(args.query)}`);- return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }] };- },- );-- server.tool(- 'create_entity',- 'Create a new entity in the scene, optionally with components',- {- name: z.string().optional().describe('Entity name (default: "Entity")'),- parent: z.union([z.number(), z.string()]).optional().describe('Parent entity ID or name'),- components: z.array(z.object({- type: z.string().describe('Component type (e.g., "Transform", "Sprite")'),- data: z.record(z.unknown()).optional().describe('Component data overrides'),- })).optional().describe('Components to add (defaults are auto-filled)'),- },- async (args: { name?: string; parent?: number | string; components?: Array<{ type: string; data?: Record<string, unknown> }> }) => {- const result = await bridge.post('/scene/create-entity', args);- return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }] };- },- );-- server.tool(- 'delete_entity',- 'Delete an entity from the scene',- {- entity: z.union([z.number(), z.string()]).describe('Entity ID or name'),- },- async (args: { entity: number | string }) => {- const body = typeof args.entity === 'number' ? { id: args.entity } : { name: args.entity };- const result = await bridge.post('/scene/delete-entity', body);- return { content: [{ type: 'text' as const, text: JSON.stringify(result) }] };- },- );-- server.tool(- 'rename_entity',- 'Rename an entity',- {- entity: z.union([z.number(), z.string()]).describe('Entity ID or current name'),- newName: z.string().describe('New name for the entity'),- },- async (args: { entity: number | string; newName: string }) => {- const body = typeof args.entity === 'number'- ? { id: args.entity, newName: args.newName }- : { name: args.entity, newName: args.newName };- const result = await bridge.post('/scene/rename-entity', body);- return { content: [{ type: 'text' as const, text: JSON.stringify(result) }] };- },- );-- server.tool(- 'reparent_entity',- 'Move an entity under a new parent (or to root if newParent is null)',- {- entity: z.union([z.number(), z.string()]).describe('Entity ID or name'),- newParent: z.union([z.number(), z.string()]).nullable().describe('New parent entity ID/name, or null for root'),- },- async (args: { entity: number | string; newParent: number | string | null }) => {- const body: Record<string, unknown> = { newParent: args.newParent };- if (typeof args.entity === 'number') body.id = args.entity;- else body.name = args.entity;- const result = await bridge.post('/scene/reparent-entity', body);- return { content: [{ type: 'text' as const, text: JSON.stringify(result) }] };- },- );-- server.tool(- 'add_component',- `Add a component to an entity (defaults are auto-filled). Use list_components to see available types.-Key components for animation:-- TimelinePlayer: { timeline: "<.estimeline UUID>", playing: false, speed: 1, wrapMode: "once" }-- SpriteAnimator: { clip: "<.esanim UUID>", playing: false }-To play esanim via timeline: entity needs both TimelinePlayer and SpriteAnimator, and the timeline must have a spriteAnim track referencing the esanim asset.`,- {- entity: z.union([z.number(), z.string()]).describe('Entity ID or name'),- component: z.string().describe('Component type (e.g., "Transform", "Sprite", "RigidBody")'),- data: z.record(z.unknown()).optional().describe('Component data overrides'),- },- async (args: { entity: number | string; component: string; data?: Record<string, unknown> }) => {- const body: Record<string, unknown> = { component: args.component };- if (typeof args.entity === 'number') body.id = args.entity;- else body.name = args.entity;- if (args.data) body.data = args.data;- const result = await bridge.post('/scene/add-component', body);- return { content: [{ type: 'text' as const, text: JSON.stringify(result) }] };- },- );-- server.tool(- 'remove_component',- 'Remove a component from an entity',- {- entity: z.union([z.number(), z.string()]).describe('Entity ID or name'),- component: z.string().describe('Component type to remove'),- },- async (args: { entity: number | string; component: string }) => {- const body: Record<string, unknown> = { component: args.component };- if (typeof args.entity === 'number') body.id = args.entity;- else body.name = args.entity;- const result = await bridge.post('/scene/remove-component', body);- return { content: [{ type: 'text' as const, text: JSON.stringify(result) }] };- },- );-- server.tool(- 'duplicate_entity',- 'Duplicate an entity with all its components',- {- entity: z.union([z.number(), z.string()]).describe('Entity ID or name to duplicate'),- },- async (args: { entity: number | string }) => {- const body = typeof args.entity === 'number' ? { id: args.entity } : { name: args.entity };- const result = await bridge.post('/scene/duplicate-entity', body);- return { content: [{ type: 'text' as const, text: JSON.stringify(result) }] };- },- );-- server.tool(- 'instantiate_prefab',- 'Instantiate a prefab into the scene',- {- path: z.string().describe('Prefab asset path (relative or UUID)'),- parent: z.union([z.number(), z.string()]).optional().describe('Parent entity ID or name'),- },- async (args: { path: string; parent?: number | string }) => {- const result = await bridge.post('/scene/instantiate-prefab', args);- return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }] };- },- );-- server.tool(- 'new_scene',- 'Create a new empty scene (discards current scene)',- {},- async () => {- const result = await bridge.post('/scene/new', {});- return { content: [{ type: 'text' as const, text: JSON.stringify(result) }] };- },- );-- server.tool(- 'open_scene',- 'Open a scene file by path',- {- path: z.string().describe('Scene file path (e.g., "assets/scenes/main.esscene")'),- },- async (args: { path: string }) => {- const result = await bridge.post('/scene/open', { path: args.path });- return { content: [{ type: 'text' as const, text: JSON.stringify(result) }] };- },- );-- server.tool(- 'toggle_entity_visibility',- 'Toggle an entity\'s visibility in the editor',- {- entity: z.union([z.number(), z.string()]).describe('Entity ID or name'),- },- async (args: { entity: number | string }) => {- const body = typeof args.entity === 'number' ? { id: args.entity } : { name: args.entity };- const result = await bridge.post('/scene/toggle-visibility', body);- return { content: [{ type: 'text' as const, text: JSON.stringify(result) }] };- },- );-}diff --git a/tools/mcp-server/src/tools/state.ts b/tools/mcp-server/src/tools/state.tsdeleted file mode 100644index efb99646d..000000000--- a/tools/mcp-server/src/tools/state.ts+++ /dev/null@@ -1,297 +0,0 @@-import { z } from 'zod';-import type { BridgeClient } from '../bridge.js';--export function registerStateTools(- server: { tool: Function },- bridge: BridgeClient,-): void {- server.tool(- 'get_console_logs',- 'Get recent console logs from the editor',- {- count: z.number().optional().describe('Number of log entries (default 50)'),- level: z.string().optional().describe('Filter by level: stdout|stderr|error|success|command'),- },- async (args: { count?: number; level?: string }) => {- const params = new URLSearchParams();- if (args.count != null) params.set('count', String(args.count));- if (args.level) params.set('level', args.level);- const query = params.toString();- const result = await bridge.get(`/state/logs${query ? '?' + query : ''}`);- return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }] };- },- );-- server.tool(- 'get_panel_layout',- 'Get the list of editor panels and their positions',- {},- async () => {- const result = await bridge.get('/state/layout');- return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }] };- },- );-- server.tool(- 'get_project_settings',- 'Get project settings (all non-default values, or specific keys)',- {- keys: z.array(z.string()).optional().describe('Specific setting keys to retrieve'),- },- async (args: { keys?: string[] }) => {- const query = args.keys ? `?keys=${args.keys.join(',')}` : '';- const result = await bridge.get(`/state/settings${query}`);- return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }] };- },- );-- server.tool(- 'get_build_status',- 'Get recent build history entries',- {},- async () => {- const result = await bridge.get('/state/build');- return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }] };- },- );-- server.tool(- 'get_render_stats',- 'Get current frame timing and system performance data',- {},- async () => {- const result = await bridge.get('/state/render-stats');- return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }] };- },- );-- server.tool(- 'list_assets',- 'List all assets in the project, optionally filtered by type',- {- type: z.string().optional().describe('Filter by asset type (e.g., "texture", "scene", "script", "audio")'),- },- async (args: { type?: string }) => {- const query = args.type ? `?type=${encodeURIComponent(args.type)}` : '';- const result = await bridge.get(`/assets/list${query}`);- return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }] };- },- );-- server.tool(- 'get_asset_info',- 'Get detailed information about a specific asset by UUID or path',- {- uuid: z.string().optional().describe('Asset UUID'),- path: z.string().optional().describe('Asset relative path'),- },- async (args: { uuid?: string; path?: string }) => {- const params = args.uuid ? `uuid=${args.uuid}` : `path=${encodeURIComponent(args.path!)}`;- const result = await bridge.get(`/assets/info?${params}`);- return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }] };- },- );-- server.tool(- 'get_timeline_data',- `Get timeline asset data. Returns { duration, wrapMode, tracks[] }.-Use list_assets with type="timeline" to find timeline UUIDs, or get_entity_data to read TimelinePlayer.timeline field.`,- {- uuid: z.string().optional().describe('Timeline asset UUID'),- path: z.string().optional().describe('Timeline asset relative path'),- },- async (args: { uuid?: string; path?: string }) => {- const params = args.uuid ? `uuid=${args.uuid}` : `path=${encodeURIComponent(args.path!)}`;- const result = await bridge.get(`/timeline/data?${params}`);- return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }] };- },- );-- server.tool(- 'update_timeline_data',- `Update a .estimeline asset file. Provide uuid/path plus any top-level fields to patch (tracks, duration, wrapMode).--IMPORTANT: "tracks" replaces the full array — always read first with get_timeline_data, modify, then write back.--## How timeline works-- An entity needs a TimelinePlayer component with "timeline" field set to the .estimeline asset UUID.-- The entity also needs the target components (Transform, Sprite, SpriteAnimator, etc.) that the tracks animate.-- To control esanim: add a spriteAnim track referencing the .esanim asset UUID. The entity must also have a SpriteAnimator component.-- Use set_property to change TimelinePlayer fields (wrapMode, playing, speed) on the entity.--## Track type schemas--### property — animate component fields with keyframes-{ type: "property", name: string, component: "Transform"|"Sprite"|"UIRect"|..., childPath: "" (or "ChildName/GrandChild"),- channels: [{ property: "position.x"|"scale.y"|"color.r"|...,- keyframes: [{ time: number, value: number, inTangent: 0, outTangent: 0, interpolation: "linear"|"easeIn"|"easeOut"|"easeInOut"|"step"|"hermite" }] }] }--### spine — play spine animations on SpineAnimation component-{ type: "spine", name: string, childPath: "",- clips: [{ start: number, duration: number, animation: "idle"|..., speed: 1, loop: true }], blendIn: 0 }--### spriteAnim — trigger a SpriteAnimator clip (esanim). Entity must have SpriteAnimator component.-{ type: "spriteAnim", name: string, childPath: "",- clip: "<esanim-asset-UUID-or-path>", startTime: 0 }--### audio — play audio clips-{ type: "audio", name: string, childPath: "",- events: [{ time: number, clip: "<audio-asset-UUID>", volume: 1 }] }--### activation — show/hide entity in time ranges-{ type: "activation", name: string, childPath: "",- ranges: [{ start: number, end: number }] }--### marker — named time markers (no runtime effect, for editor use)-{ type: "marker", name: string, childPath: "",- markers: [{ time: number, name: string }] }--### customEvent — custom events with payload-{ type: "customEvent", name: string, childPath: "",- events: [{ time: number, name: string, payload: {} }] }--## Example: add a spriteAnim track to play idle.esanim at t=0-1. get_timeline_data({ uuid: "..." }) → read existing tracks-2. Append: { type: "spriteAnim", name: "Idle", childPath: "", clip: "<idle.esanim-uuid>", startTime: 0 }-3. update_timeline_data({ uuid: "...", tracks: [...existing, newTrack] })-4. Ensure the entity has SpriteAnimator component: add_component({ entity: id, component: "SpriteAnimator", data: { clip: "<idle.esanim-uuid>" } })-5. Set loop playback: set_property({ entity: id, component: "TimelinePlayer", field: "wrapMode", value: "loop" })`,- {- uuid: z.string().optional().describe('Timeline asset UUID'),- path: z.string().optional().describe('Timeline asset relative path'),- tracks: z.array(z.record(z.unknown())).optional().describe('Full tracks array to replace (read first, modify, write back)'),- duration: z.number().optional().describe('Timeline duration in seconds'),- wrapMode: z.string().optional().describe('Wrap mode: once, loop, pingPong'),- },- async (args: { uuid?: string; path?: string; tracks?: Record<string, unknown>[]; duration?: number; wrapMode?: string }) => {- const result = await bridge.post('/timeline/update', args);- return { content: [{ type: 'text' as const, text: JSON.stringify(result) }] };- },- );-- server.tool(- 'get_asset_meta',- 'Get full asset meta: UUID, importer settings, labels, address, group, platform overrides',- {- uuid: z.string().optional().describe('Asset UUID'),- path: z.string().optional().describe('Asset relative path'),- },- async (args: { uuid?: string; path?: string }) => {- const params = args.uuid ? `uuid=${args.uuid}` : `path=${encodeURIComponent(args.path!)}`;- const result = await bridge.get(`/assets/meta?${params}`);- return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }] };- },- );-- server.tool(- 'update_asset_meta',- 'Update asset meta: labels, address, group, importer settings, platform overrides',- {- uuid: z.string().describe('Asset UUID'),- labels: z.array(z.string()).optional().describe('Asset labels'),- address: z.string().nullable().optional().describe('Addressable name (unique) or null to clear'),- group: z.string().optional().describe('Asset group name'),- importer: z.record(z.unknown()).optional().describe('Importer settings (type-specific)'),- platformOverrides: z.record(z.record(z.unknown())).optional().describe('Platform-specific importer overrides'),- },- async (args: { uuid: string; labels?: string[]; address?: string | null; group?: string; importer?: Record<string, unknown>; platformOverrides?: Record<string, Record<string, unknown>> }) => {- const result = await bridge.post('/assets/meta/update', args);- return { content: [{ type: 'text' as const, text: JSON.stringify(result) }] };- },- );-- server.tool(- 'ensure_asset_meta',- 'Generate .meta file for an asset if it does not exist, returns the UUID',- {- path: z.string().describe('Asset relative path (e.g., "assets/textures/player.png")'),- },- async (args: { path: string }) => {- const result = await bridge.post('/assets/meta/ensure', args);- return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }] };- },- );-- server.tool(- 'create_asset',- 'Create a new asset file with default content and auto-generate .meta',- {- type: z.enum(['material', 'scene', 'shader', 'anim-clip', 'timeline', 'bitmap-font']).describe('Asset type'),- name: z.string().describe('Asset file name (extension auto-added if missing)'),- dir: z.string().optional().describe('Directory relative to project root (default: "assets")'),- },- async (args: { type: string; name: string; dir?: string }) => {- const result = await bridge.post('/assets/create', args);- return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }] };- },- );-- server.tool(- 'delete_asset',- 'Delete an asset file and its .meta file',- {- uuid: z.string().optional().describe('Asset UUID'),- path: z.string().optional().describe('Asset relative path'),- },- async (args: { uuid?: string; path?: string }) => {- const result = await bridge.post('/assets/delete', args);- return { content: [{ type: 'text' as const, text: JSON.stringify(result) }] };- },- );-- server.tool(- 'rename_asset',- 'Rename an asset file and update its .meta file',- {- uuid: z.string().optional().describe('Asset UUID'),- path: z.string().optional().describe('Asset relative path'),- newName: z.string().describe('New file name (e.g., "player_idle.png")'),- },- async (args: { uuid?: string; path?: string; newName: string }) => {- const result = await bridge.post('/assets/rename', args);- return { content: [{ type: 'text' as const, text: JSON.stringify(result) }] };- },- );-- server.tool(- 'list_components',- 'List all available component types grouped by category (builtin, ui, physics, script, tag)',- {},- async () => {- const result = await bridge.get('/components/list');- return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }] };- },- );-- server.tool(- 'get_component_schema',- 'Get detailed schema for a component: fields, types, defaults, ranges, and constraints',- {- name: z.string().describe('Component type name (e.g., "Transform", "Sprite", "RigidBody")'),- },- async (args: { name: string }) => {- const result = await bridge.get(`/components/schema?name=${encodeURIComponent(args.name)}`);- return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }] };- },- );-- server.tool(- 'list_menus',- 'List all editor menu items with IDs, labels, shortcuts, and enabled state',- {},- async () => {- const result = await bridge.get('/menus/list');- return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }] };- },- );-- server.tool(- 'get_scene_metadata',- 'Get current scene info: name, file path, dirty state, design resolution, undo/redo status',- {},- async () => {- const result = await bridge.get('/scene/metadata');- return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }] };- },- );-}diff --git a/tools/mcp-server/src/tools/visual.ts b/tools/mcp-server/src/tools/visual.tsdeleted file mode 100644index 69ed70f5c..000000000--- a/tools/mcp-server/src/tools/visual.ts+++ /dev/null@@ -1,103 +0,0 @@-import { z } from 'zod';-import { readFile, writeFile, mkdtemp } from 'node:fs/promises';-import { join } from 'node:path';-import { tmpdir } from 'node:os';-import type { BridgeClient } from '../bridge.js';--export function registerVisualTools(- server: { tool: Function },- bridge: BridgeClient,-): void {- server.tool(- 'capture_editor',- 'Capture a screenshot of the editor (whole window or specific panel)',- {- panel: z.string().optional().describe('Panel to capture: scene|game|inspector|hierarchy|content|output (omit for WebGL view)'),- maxWidth: z.number().optional().describe('Max width in pixels for resizing'),- },- async (args: { panel?: string; maxWidth?: number }) => {- const params = new URLSearchParams();- if (args.panel) params.set('panel', args.panel);- if (args.maxWidth != null) params.set('maxWidth', String(args.maxWidth));- const query = params.toString();- const result = await bridge.get(`/capture${query ? '?' + query : ''}`) as { data?: { dataUrl?: string } };-- const dataUrl = (result as any)?.data?.dataUrl ?? (result as any)?.dataUrl;- if (!dataUrl || typeof dataUrl !== 'string') {- return { content: [{ type: 'text' as const, text: 'Failed to capture screenshot' }] };- }-- const base64 = dataUrl.replace(/^data:image\/png;base64,/, '');- const tmpDir = await mkdtemp(join(tmpdir(), 'esengine-capture-'));- const filePath = join(tmpDir, 'capture.png');- await writeFile(filePath, Buffer.from(base64, 'base64'));-- return {- content: [- { type: 'image' as const, data: base64, mimeType: 'image/png' },- { type: 'text' as const, text: `Screenshot saved to: ${filePath}` },- ],- };- },- );-- server.tool(- 'capture_diff',- 'Compare two screenshots and show pixel differences',- {- screenshot_a: z.string().describe('File path to first screenshot'),- screenshot_b: z.string().describe('File path to second screenshot'),- },- async (args: { screenshot_a: string; screenshot_b: string }) => {- try {- const { default: pixelmatch } = await import('pixelmatch');- const { PNG } = await import('pngjs');-- const imgA = PNG.sync.read(await readFile(args.screenshot_a));- const imgB = PNG.sync.read(await readFile(args.screenshot_b));-- const width = Math.min(imgA.width, imgB.width);- const height = Math.min(imgA.height, imgB.height);- const diff = new PNG({ width, height });-- const numDiffPixels = pixelmatch(- imgA.data, imgB.data, diff.data,- width, height,- { threshold: 0.1 },- );-- const totalPixels = width * height;- const diffPercent = ((numDiffPixels / totalPixels) * 100).toFixed(2);-- const diffBuffer = PNG.sync.write(diff);- const base64 = diffBuffer.toString('base64');-- const tmpDir = await mkdtemp(join(tmpdir(), 'esengine-diff-'));- const filePath = join(tmpDir, 'diff.png');- await writeFile(filePath, diffBuffer);-- return {- content: [- { type: 'image' as const, data: base64, mimeType: 'image/png' },- { type: 'text' as const, text: `Diff: ${diffPercent}% (${numDiffPixels}/${totalPixels} pixels). Saved to: ${filePath}` },- ],- };- } catch (e) {- const msg = e instanceof Error ? e.message : String(e);- return { content: [{ type: 'text' as const, text: `Diff failed: ${msg}` }] };- }- },- );-- server.tool(- 'get_element_bounds',- 'Get the position and size of a DOM element by CSS selector',- {- selector: z.string().describe('CSS selector for the element'),- },- async (args: { selector: string }) => {- const result = await bridge.get(`/state/element-bounds?selector=${encodeURIComponent(args.selector)}`);- return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }] };- },- );-}diff --git a/tools/mcp-server/src/types.d.ts b/tools/mcp-server/src/types.d.tsdeleted file mode 100644index e1e0dbf05..000000000--- a/tools/mcp-server/src/types.d.ts+++ /dev/null@@ -1,11 +0,0 @@-declare module 'pixelmatch' {- function pixelmatch(- img1: Buffer | Uint8Array,- img2: Buffer | Uint8Array,- output: Buffer | Uint8Array | null,- width: number,- height: number,- options?: { threshold?: number },- ): number;- export default pixelmatch;-}diff --git a/tools/mcp-server/tsconfig.json b/tools/mcp-server/tsconfig.jsondeleted file mode 100644index bc748576d..000000000--- a/tools/mcp-server/tsconfig.json+++ /dev/null@@ -1,14 +0,0 @@-{- "compilerOptions": {- "target": "ES2022",- "module": "Node16",- "moduleResolution": "Node16",- "outDir": "dist",- "rootDir": "src",- "strict": true,- "esModuleInterop": true,- "skipLibCheck": true,- "declaration": true- },- "include": ["src"]-}