setup_unity_bridge
Install or update Unity MCP bridge scripts to enable Claude to interact with Unity projects, even when Unity server is not running.
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 |
|---|---|---|---|
| projectPath | Yes | Path to the Unity project | |
| forceUpdate | No | Force update even if scripts are up to date |
Implementation Reference
- src/tools/unity-mcp-tools.ts:453-470 (handler)Handler for 'setup_unity_bridge' tool in executeTool method. Validates input, calls UnityBridgeDeployService.deployScripts, and returns success/error message.case '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}`); } }
- src/tools/unity-mcp-tools.ts:211-229 (registration)Registration of the tool in getTools() array, defining 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:214-228 (schema)Input schema definition for the tool parameters: projectPath (required string), forceUpdate (optional boolean).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'] }
- Core helper method that validates the Unity project, creates necessary directories, and deploys the MCP bridge scripts (UnityHttpServer.cs and UnityMCPServerWindow.cs) with version checking and meta file generation.async 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'); }