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.

fix: auto-start bridge server on McpBridge init

esengine6598c13ba93c
diff --git a/editor/src/Editor.ts b/editor/src/Editor.ts
index 098853d11..7762f0901 100644
--- a/editor/src/Editor.ts
+++ b/editor/src/Editor.ts
@@ -249,7 +249,7 @@ export class Editor {
iocContainer.provide(LAYOUT_SERVICE, sk, this.navigationService_);
iocContainer.provide(PLUGIN_MANAGER, sk, this.pluginManager_);
- this.mcpBridge_ = new McpBridge(this.outputService_, this.scriptService_, null);
+ this.mcpBridge_ = new McpBridge(this.outputService_, this.scriptService_, null, this.projectPath_);
}
private async initializeAllScripts_(): Promise<void> {
diff --git a/editor/src/bridge/McpBridge.ts b/editor/src/bridge/McpBridge.ts
index d6d3b2768..5a54fcf9a 100644
--- a/editor/src/bridge/McpBridge.ts
+++ b/editor/src/bridge/McpBridge.ts
@@ -35,9 +35,11 @@ export class McpBridge {
private outputService_: OutputService,
private scriptService_: ScriptService,
private buildHistory_: BuildHistory | null,
+ private projectPath_: string | null = null,
) {
this.setupLogCapture_();
this.setupEventListener_();
+ this.startBridgeServer_();
}
dispose(): void {
@@ -57,6 +59,18 @@ export class McpBridge {
);
}
+ private startBridgeServer_(): void {
+ import('@tauri-apps/api/core').then(({ invoke }) => {
+ invoke('start_bridge_server', {
+ projectPath: this.projectPath_,
+ }).then((port) => {
+ console.log(`[McpBridge] Bridge server started on port ${port}`);
+ }).catch((e) => {
+ console.warn('[McpBridge] Failed to start bridge server:', e);
+ });
+ }).catch(() => {});
+ }
+
private setupEventListener_(): void {
listen<McpRequest>('mcp-request', (event) => {
this.handleRequest_(event.payload);