|
1 |
| -# MCP Unity エディター (ゲームエンジン) |
| 1 | +# MCP Unity Editor(ゲームエンジン) |
2 | 2 |
|
3 | 3 | [](https://modelcontextprotocol.io/introduction)
|
4 | 4 | [](https://unity.com/releases/editor/archive)
|
5 | 5 | [](https://nodejs.org/en/download/)
|
| 6 | +[](https://github.com/CoderGamester/mcp-unity/stargazers) |
| 7 | +[](https://github.com/CoderGamester/mcp-unity/commits/main) |
| 8 | +[](https://opensource.org/licenses/MIT) |
6 | 9 |
|
7 |
| -[](https://smithery.ai/server/@CoderGamester/mcp-unity) |
8 |
| -[](https://github.com/CoderGamester/mcp-unity/stargazers) |
9 |
| -[](https://github.com/CoderGamester/mcp-unity/commits/main) |
10 |
| -[](https://opensource.org/licenses/MIT) |
11 |
| - |
12 |
| -| [English](README.md) | [🇨🇳简体中文](README_zh-CN.md) | [🇯🇵日本語](README-ja.md) | |
| 10 | +| [英語](README.md) | [🇨🇳簡体中文](README_zh-CN.md) | [🇯🇵日本語](README-ja.md) | |
13 | 11 | |----------------------|---------------------------------|----------------------|
|
14 | 12 |
|
15 | 13 | ```
|
|
45 | 43 |
|
46 | 44 | MCP Unityは、Unityエディター向けのModel Context Protocolの実装であり、AIアシスタントがUnityプロジェクトと対話できるようにします。このパッケージは、UnityとMCPプロトコルを実装するNode.jsサーバー間のブリッジを提供し、Claude、Windsurf、CursorなどのAIエージェントがUnityエディター内で操作を実行できるようにします。
|
47 | 45 |
|
48 |
| -## 機能 |
49 |
| - |
50 | 46 | <a href="https://glama.ai/mcp/servers/@CoderGamester/mcp-unity">
|
51 | 47 | <img width="400" height="200" src="https://glama.ai/mcp/servers/@CoderGamester/mcp-unity/badge" alt="Unity MCPサーバー" />
|
52 | 48 | </a>
|
53 | 49 |
|
| 50 | +## 機能 |
| 51 | + |
54 | 52 | ### IDE統合 - パッケージキャッシュアクセス
|
55 | 53 |
|
56 | 54 | MCP Unityは、Unityの`Library/PackedCache`フォルダーをワークスペースに追加することで、VSCode系IDE(Visual Studio Code、Cursor、Windsurf)との自動統合を提供します。この機能により:
|
@@ -278,38 +276,120 @@ MCP Unityサーバーをデバッグするには、以下の方法を使用で
|
278 | 276 | npm run debug
|
279 | 277 | ```
|
280 | 278 |
|
281 |
| -## トラブルシューティング |
| 279 | +## Frequently Asked Questions |
| 280 | + |
| 281 | +### What is MCP Unity? |
| 282 | +MCP Unity is a powerful bridge that connects your Unity Editor environment to AI assistants and external tools using the Model Context Protocol (MCP). |
| 283 | + |
| 284 | +**MCP (Model Context Protocol)** is an open standard designed to allow AI models (like large language models) to interact with software applications and their data in a structured way. Think of it as a universal language that AI can use to "talk" to different programs. |
| 285 | + |
| 286 | +In essence, MCP Unity: |
| 287 | +- Exposes Unity Editor functionalities (like creating objects, modifying components, running tests, etc.) as "tools" and "resources" that an AI can understand and use. |
| 288 | +- Runs a WebSocket server inside Unity and a Node.js server (acting as a WebSocket client to Unity) that implements the MCP. This allows AI assistants to send commands to Unity and receive information back. |
| 289 | +- Enables you to use natural language prompts with your AI assistant to perform complex tasks within your Unity project, significantly speeding up development workflows. |
| 290 | + |
| 291 | +### Why use MCP Unity? |
| 292 | +MCP Unity offers several compelling advantages for developers, artists, and project managers: |
| 293 | + |
| 294 | +- **Accelerated Development:** Automate repetitive tasks, generate boilerplate code, and manage assets using AI prompts. This frees up your time to focus on creative and complex problem-solving. |
| 295 | +- **Enhanced Productivity:** Interact with Unity Editor features without needing to manually click through menus or write scripts for simple operations. Your AI assistant becomes a direct extension of your capabilities within Unity. |
| 296 | +- **Improved Accessibility:** Allows users who are less familiar with the deep intricacies of the Unity Editor or C# scripting to still make meaningful contributions and modifications to a project through AI guidance. |
| 297 | +- **Seamless Integration:** Designed to work with various AI assistants and IDEs that support MCP, providing a consistent way to leverage AI across your development toolkit. |
| 298 | +- **Extensibility:** The protocol and the toolset can be expanded. You can define new tools and resources to expose more of your project-specific or Unity's functionality to AI. |
| 299 | +- **Collaborative Potential:** Facilitates a new way of collaborating where AI can assist in tasks traditionally done by team members, or help in onboarding new developers by guiding them through project structures and operations. |
| 300 | + |
| 301 | +### How does MCP Unity compare with the upcoming Unity 6 AI features? |
| 302 | +Unity 6 is set to introduce new built-in AI tools, including Unity Muse (for generative AI capabilities like texture and animation generation) and Unity Sentis (for running neural networks in Unity runtime). As Unity 6 is not yet fully released, this comparison is based on publicly available information and anticipated functionalities: |
| 303 | + |
| 304 | +- **Focus:** |
| 305 | + - **MCP Unity:** Primarily focuses on **Editor automation and interaction**. It allows external AI (like LLM-based coding assistants) to *control and query the Unity Editor itself* to manipulate scenes, assets, and project settings. It's about augmenting the *developer's workflow* within the Editor. |
| 306 | + - **Unity 6 AI (Muse & Sentis):** |
| 307 | + - **Muse:** Aims at **in-Editor content creation** (generating textures, sprites, animations, behaviors) and AI-powered assistance for common tasks, directly integrated into the Unity Editor interface. |
| 308 | + - **Sentis:** Focuses on **runtime AI model inference**. It allows you to deploy and run pre-trained neural networks *within your game or application* for features like NPC behavior, image recognition, etc. |
| 309 | + |
| 310 | +- **Mechanism:** |
| 311 | + - **MCP Unity:** Uses an external AI assistant communicating via the Model Context Protocol to control the Editor. It's about *external AI driving the Editor*. |
| 312 | + - **Unity 6 AI:** These are *native, integrated AI features*. Muse will be part of the Editor's UI/UX, and Sentis is a runtime library. |
| 313 | + |
| 314 | +- **Use Cases:** |
| 315 | + - **MCP Unity:** "Create a new 3D object, name it 'Player', add a Rigidbody, and set its mass to 10." "Find all materials in the project that use the 'Standard' shader." "Run all Play Mode tests." |
| 316 | + - **Unity Muse:** "Generate a sci-fi texture for this material." "Create a walking animation for this character." "Help me write a script for player movement." |
| 317 | + - **Unity Sentis:** Powering intelligent NPCs in your built game, implementing real-time style transfer, enabling voice commands for players. |
| 318 | + |
| 319 | +- **Complementary, Not Mutually Exclusive:** |
| 320 | + MCP Unity and Unity's native AI tools can be seen as complementary. You might use MCP Unity with your AI coding assistant to set up a scene or batch-modify assets, and then use Unity Muse to generate a specific texture for one of those assets. Sentis would then be used for AI logic in the final game. MCP Unity provides a flexible, protocol-based way to interact with the Editor, which can be powerful for developers who want to integrate with a broader range of external AI services or build custom automation workflows. |
| 321 | + |
| 322 | +### What MCP hosts and IDEs currently support MCP Unity? |
| 323 | +MCP Unity is designed to work with any AI assistant or development environment that can act as an MCP client. The ecosystem is growing, but current known integrations or compatible platforms include: |
| 324 | + |
| 325 | +- **AI Coding Assistants:** |
| 326 | + - **Windsurf:** A powerful agentic AI coding assistant that can leverage MCP tools. |
| 327 | + - **Cursor:** An AI-first code editor that can integrate with MCP servers. |
| 328 | + - Other LLM-based assistants that can be configured to use the MCP protocol. |
| 329 | +- **IDEs:** |
| 330 | + - **Visual Studio Code (VSCode) and variants (like Cursor):** Configuration is typically done by specifying the MCP server details in the IDE's settings, allowing the AI features within these IDEs to connect to MCP Unity. |
| 331 | +- **MCP Inspector:** |
| 332 | + - The `@modelcontextprotocol/inspector` is a tool that can be used to debug and interact with any MCP server, including MCP Unity. |
| 333 | + |
| 334 | +The flexibility of MCP means that as more tools adopt the protocol, they should theoretically be able to interface with MCP Unity. Always check the documentation of your specific AI assistant or IDE for MCP support and configuration instructions. |
| 335 | + |
| 336 | +### How can MCP Unity help with "Generative Engine Optimization" (GEO) for my project? |
| 337 | +"Generative Engine Optimization" (GEO) is an emerging concept, similar to SEO for websites, but for discoverability and usability by generative AI models and AI-powered search engines (like Google's SGE). Here's how MCP Unity helps: |
| 338 | + |
| 339 | +- **Structured Data Exposure:** MCP tools and resources expose Unity project data (scene hierarchy, assets, components) in a structured, machine-readable format. This makes it easier for AI to "understand" your project. |
| 340 | +- **Actionable Endpoints:** By providing clear "actions" (tools) the AI can take, MCP Unity allows generative AI to not just read about your project, but to *interact* with and *modify* it. This is key for AI agents that perform tasks. |
| 341 | +- **Clear Tool Definitions:** The names, descriptions, and parameters of MCP tools (e.g., `update_gameobject`, `add_asset_to_scene`) act like keywords and schemas for AI. Well-defined tools make your project more "AI-friendly." |
| 342 | +- **Facilitating AI-Driven Content & Code Generation:** While MCP Unity itself doesn't generate game content directly, it enables AI assistants to *orchestrate* the use of Unity's features. For example, an AI could use MCP Unity tools to set up a scene and then prompt you (or potentially another AI service in the future) to generate assets for that scene. |
| 343 | +- **Standardized Interaction:** Using an open standard like MCP increases the chances that future AI systems and search tools will be able to interface with your project's capabilities exposed via MCP Unity. |
| 344 | + |
| 345 | +Essentially, by making your Unity Editor environment programmatically accessible and understandable to AI through MCP, you are optimizing it for interaction with generative AI engines and AI-driven development workflows. |
| 346 | + |
| 347 | +### Can I extend MCP Unity with custom tools for my project? |
| 348 | +Yes, absolutely! One of the significant benefits of the MCP Unity architecture is its extensibility. |
| 349 | +- **In Unity (C#):** You can create new C# classes that inherit from `McpToolBase` (or a similar base for resources) to expose custom Unity Editor functionality. These tools would then be registered in `McpUnityServer.cs`. For example, you could write a tool to automate a specific asset import pipeline unique to your project. |
| 350 | +- **In Node.js Server (TypeScript):** You would then define the corresponding TypeScript tool handler in the `Server/src/tools/` directory, including its Zod schema for inputs/outputs, and register it in `Server/src/index.ts`. This Node.js part will forward the request to your new C# tool in Unity. |
| 351 | + |
| 352 | +This allows you to tailor the AI's capabilities to the specific needs and workflows of your game or application. |
| 353 | + |
| 354 | +### Troubleshooting Common Issues |
282 | 355 |
|
283 | 356 | <details>
|
284 |
| -<summary><span style="font-size: 1.1em; font-weight: bold;">接続の問題</span></summary> |
| 357 | +<summary><span style="font-size: 1.1em; font-weight: bold;">Connection Issues</span></summary> |
285 | 358 |
|
286 |
| -- WebSocketサーバーが実行中であることを確認してください(UnityのServer Windowを確認) |
287 |
| -- ファイアウォールの制限が接続を妨げていないか確認してください |
288 |
| -- ポート番号が正しいことを確認してください(デフォルトは8080) |
289 |
| -- UnityエディターのMCP Serverウィンドウでポート番号を変更できます(ツール > MCP Unity > Server Window) |
| 359 | +- Ensure the WebSocket server is running (check the Server Window in Unity) |
| 360 | +- Send a console log message from MCP client to force a reconnection between MCP client and Unity server |
| 361 | +- Change the port number in the Unity Editor MCP Server window. (Tools > MCP Unity > Server Window) |
290 | 362 | </details>
|
291 | 363 |
|
292 | 364 | <details>
|
293 |
| -<summary><span style="font-size: 1.1em; font-weight: bold;">サーバーが起動しない</span></summary> |
| 365 | +<summary><span style="font-size: 1.1em; font-weight: bold;">Server Not Starting</span></summary> |
294 | 366 |
|
295 |
| -- Unityコンソールにエラーメッセージがないか確認してください |
296 |
| -- Node.jsが正しくインストールされ、PATHで利用可能であることを確認してください |
297 |
| -- Serverディレクトリ内の依存関係がすべてインストールされていることを確認してください |
| 367 | +- Check the Unity Console for error messages |
| 368 | +- Ensure Node.js is properly installed and accessible in your PATH |
| 369 | +- Verify that all dependencies are installed in the Server directory |
298 | 370 | </details>
|
299 | 371 |
|
300 | 372 | <details>
|
301 |
| -<summary><span style="font-size: 1.1em; font-weight: bold;">Play Modeテスト実行時の接続失敗</span></summary> |
| 373 | +<summary><span style="font-size: 1.1em; font-weight: bold;">Connection failed when running Play Mode tests</span></summary> |
302 | 374 |
|
303 |
| -`run_tests` ツールは以下の応答を返します: |
| 375 | +The `run_tests` tool returns the following response: |
304 | 376 | ```
|
305 | 377 | Error:
|
306 | 378 | Connection failed: Unknown error
|
307 | 379 | ```
|
308 | 380 |
|
309 |
| -このエラーは、Play Modeへ切り替える際にドメインリロードが発生し、ブリッジ接続が失われるために発生します。 |
310 |
| -回避策は、**Edit > Project Settings > Editor > "Enter Play Mode Settings"** で **Reload Domain** をオフにすることです。 |
| 381 | +This error occurs because the bridge connection is lost when the domain reloads upon switching to Play Mode. |
| 382 | +The workaround is to turn off **Reload Domain** in **Edit > Project Settings > Editor > "Enter Play Mode Settings"**. |
311 | 383 | </details>
|
312 | 384 |
|
| 385 | +### Where can I find more information or contribute? |
| 386 | +- **Official MCP Unity Repository:** [https://github.com/CoderGamester/mcp-unity](https://github.com/CoderGamester/mcp-unity) (Check for Issues, Discussions, and the Roadmap) |
| 387 | +- **Model Context Protocol Documentation:** [https://modelcontextprotocol.io](https://modelcontextprotocol.io) |
| 388 | +- **Unity Forums and Communities:** For general Unity questions or discussions on integrating AI. |
| 389 | + |
| 390 | +### Is MCP Unity free to use? |
| 391 | +Yes, MCP Unity is an open-source project distributed under the MIT License. You are free to use, modify, and distribute it according to the license terms. |
| 392 | + |
313 | 393 | ## サポート・フィードバック
|
314 | 394 |
|
315 | 395 | ご質問やサポートが必要な場合は、このリポジトリの[issue](https://github.com/CoderGamester/mcp-unity/issues)をご利用ください。
|
|
0 commit comments