setup_unity_bridge
Installs or updates Unity MCP bridge scripts in a Unity project, enabling direct interaction with Unity assets and scripts, even without an active Unity server.
Instructions
Install/update Unity MCP bridge scripts to a Unity project (works even if Unity server is not running)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| forceUpdate | No | Force update even if scripts are up to date | |
| projectPath | Yes | Path to the Unity project |
Implementation Reference
- src/tools/unity-mcp-tools.ts:211-229 (registration)Tool registration in getTools() method including name, description, and input schema{ name: 'setup_unity_bridge', description: 'Install/update Unity MCP bridge scripts to a Unity project (works even if Unity server is not running)', inputSchema: { type: 'object', properties: { projectPath: { type: 'string', description: 'Path to the Unity project' }, forceUpdate: { type: 'boolean', description: 'Force update even if scripts are up to date', default: false } }, required: ['projectPath'] } },
- src/tools/unity-mcp-tools.ts:453-470 (handler)Handler in executeTool that validates args and delegates to UnityBridgeDeployServicecase 'setup_unity_bridge': { const { projectPath, forceUpdate } = args; if (!projectPath) { throw new Error('projectPath is required'); } try { await this.deployService.deployScripts({ projectPath, forceUpdate }); return { content: [{ type: 'text', text: `Unity MCP bridge scripts installed successfully to:\n${projectPath}/Assets/Editor/MCP/\n\nPlease restart Unity Editor or open Window > Unity MCP Server to start the server.` }] }; } catch (error: any) { throw new Error(`Failed to install scripts: ${error.message}`); } }
- Core deployment logic that validates project, creates directory, and deploys embedded scripts via deployScript methodasync deployScripts(options: DeploymentOptions): Promise<void> { const { projectPath, forceUpdate = false } = options; // Validate Unity project const projectValidation = await this.validateUnityProject(projectPath); if (!projectValidation.isValid) { throw new Error(`Invalid Unity project: ${projectValidation.error}`); } // Create Editor/MCP directory if it doesn't exist const editorMCPPath = path.join(projectPath, 'Assets', 'Editor', 'MCP'); await fs.mkdir(editorMCPPath, { recursive: true }); // Deploy each script for (const script of this.SCRIPTS) { await this.deployScript(projectPath, script, forceUpdate); } this.logger.info('Unity MCP scripts deployed successfully'); }