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: add build_project and list_build_configs MCP tools

esengine3b794f679222
diff --git a/desktop/src-tauri/src/bridge_server.rs b/desktop/src-tauri/src/bridge_server.rs
index 3b35aa911..8461e997e 100644
--- a/desktop/src-tauri/src/bridge_server.rs
+++ b/desktop/src-tauri/src/bridge_server.rs
@@ -63,13 +63,10 @@ impl BridgeServer {
worker_loop(server, shutdown, app, project);
}));
- if let Some(ref path) = project_path {
- let file = write_bridge_file(port, path);
- eprintln!("[BridgeServer] Bridge file written: {:?}", file);
- self.bridge_file = Some(file);
- } else {
- eprintln!("[BridgeServer] No project path provided, skipping bridge file");
- }
+ let bridge_path = project_path.as_deref().unwrap_or("__launcher__");
+ let file = write_bridge_file(port, bridge_path);
+ eprintln!("[BridgeServer] Bridge file written: {:?}", file);
+ self.bridge_file = Some(file);
Ok(port)
}
@@ -215,6 +212,9 @@ fn parse_request(
("GET", "/state/build") => {
Ok(("getBuildStatus".into(), json!({})))
}
+ ("GET", "/state/build-configs") => {
+ Ok(("listBuildConfigs".into(), json!({})))
+ }
("GET", "/state/render-stats") => {
Ok(("getRenderStats".into(), json!({})))
}
@@ -324,6 +324,10 @@ fn parse_request(
("POST", "/action/redo") => {
Ok(("redo".into(), json!({})))
}
+ ("POST", "/action/build") => {
+ let body = read_json_body(reader)?;
+ Ok(("buildProject".into(), body))
+ }
("GET", "/timeline/data") => {
let uuid = query_params.get("uuid").cloned();
let path = query_params.get("path").cloned();
@@ -368,6 +372,24 @@ fn parse_request(
let body = read_json_body(reader)?;
Ok(("instantiateTemplate".into(), body))
}
+ // Launcher / project management routes
+ ("GET", "/editor/status") => {
+ Ok(("getEditorStatus".into(), json!({})))
+ }
+ ("GET", "/projects/recent") => {
+ Ok(("listRecentProjects".into(), json!({})))
+ }
+ ("GET", "/projects/examples") => {
+ Ok(("listExamples".into(), json!({})))
+ }
+ ("POST", "/projects/open") => {
+ let body = read_json_body(reader)?;
+ Ok(("openProject".into(), body))
+ }
+ ("POST", "/projects/create-from-example") => {
+ let body = read_json_body(reader)?;
+ Ok(("createFromExample".into(), body))
+ }
_ => Err(format!("Unknown route: {} {}", method, path)),
}
}
diff --git a/editor/src/bridge/McpBridge.ts b/editor/src/bridge/McpBridge.ts
index f4d51d668..f0f62d1d8 100644
--- a/editor/src/bridge/McpBridge.ts
+++ b/editor/src/bridge/McpBridge.ts
@@ -2,6 +2,8 @@ import { listen, emit, type UnlistenFn } from '@tauri-apps/api/event';
import type { OutputService, OutputType } from '../services/OutputService';
import type { ScriptService } from '../services/ScriptService';
import type { BuildHistory } from '../builder/BuildHistory';
+import { BuildService } from '../builder/BuildService';
+import { getBuildConfigService } from '../builder/BuildConfigService';
import { getEditorStore } from '../store/EditorStore';
import { getSharedRenderContext } from '../renderer/SharedRenderContext';
import { getEditorContainer } from '../container';
@@ -149,6 +151,8 @@ export class McpBridge {
case 'deleteAsset': return this.deleteAsset_(params);
case 'renameAsset': return this.renameAsset_(params);
case 'instantiateTemplate': return this.instantiateTemplate_(params);
+ case 'buildProject': return this.buildProject_(params);
+ case 'listBuildConfigs': return this.listBuildConfigs_();
default: throw new Error(`Unknown method: ${method}`);
}
}
@@ -259,6 +263,48 @@ export class McpBridge {
return { entries: this.buildHistory_.getRecentBuilds(20) };
}
+ private async buildProject_(params: Record<string, unknown>): Promise<unknown> {
+ if (!this.projectPath_) throw new Error('No project open');
+
+ const configService = getBuildConfigService();
+ await configService.load();
+
+ const configId = params.configId as string | undefined;
+ const platform = params.platform as string | undefined;
+ const cleanBuild = params.cleanBuild as boolean | undefined;
+
+ let config = configId
+ ? configService.getConfig(configId)
+ : configService.getActiveConfig();
+
+ if (!config && platform) {
+ const platformConfigs = configService.getConfigsByPlatform(platform as 'playable' | 'wechat');
+ config = platformConfigs[0];
+ }
+
+ if (!config) {
+ throw new Error('No build config found. Specify configId or platform.');
+ }
+
+ const buildService = new BuildService(this.projectPath_);
+ const result = await buildService.build(config, { cleanBuild: cleanBuild ?? false });
+ return result;
+ }
+
+ private listBuildConfigs_(): unknown {
+ const configService = getBuildConfigService();
+ const configs = configService.getConfigs();
+ return {
+ configs: configs.map(c => ({
+ id: c.id,
+ name: c.name,
+ platform: c.platform,
+ scenes: c.scenes,
+ })),
+ activeConfigId: configService.getActiveConfig()?.id ?? null,
+ };
+ }
+
private getRenderStats_(): unknown {
const ctx = getSharedRenderContext();
const app = (ctx as any).app_;
diff --git a/tools/mcp-server b/tools/mcp-server
index 4a354ac14..9c32e7283 160000
--- a/tools/mcp-server
+++ b/tools/mcp-server
@@ -1 +1 @@
-Subproject commit 4a354ac1408c6504ce698d7ef216c6e15c4689d3
+Subproject commit 9c32e728340344812ce49d2c395f0f1899dde15c