Unity3d Editor MCP Server for LLMs
Enable LLMs to interact with the Unity3d Editor via an MCP server to access console and test logs, editor functions, hierarchy state, and execute editor tools.
npx -y @CoderGamester/mcp-unityOverview
This MCP (Model Context Protocol) server runs inside the Unity3D Editor and exposes editor state and functions to LLM-based agents. It allows external language models to observe console and test logs, query the scene/hierarchy, and request execution of editor tools or automated editor commands using a standard protocol. The server is intended for development workflows where LLMs need structured access to project context to provide debugging help, automated edits, or content generation.
Using an editor-hosted MCP server keeps the communication local to the development machine (or a secured network) and lets model-driven agents interact with a live Unity Editor instance instead of just static files. This enables capabilities like summarizing runtime errors, applying repair patches suggested by models, running and analyzing tests, or manipulating scene hierarchies programmatically and safely.
Features
- Exposes Unity Editor state and events via the MCP protocol
- Read access to console logs, test results, and playmode events
- Queryable scene/hierarchy and GameObject/component metadata
- Execute registered editor tools, menu actions, and scripted commands
- Simple local HTTP endpoint, configurable port and auth
- Designed for integration with LLM agents and tool-runners that support MCP
Installation / Configuration
- Clone the repository:
Open the project in the Unity Editor (recommended Unity 2019.4+). Import the package or copy the “Assets/MCP” folder into your Unity project’s Assets folder.
Start the MCP server from the Editor menu or a dedicated window (the package provides an Editor window to control the server). Alternatively, enable auto-start in the Inspector for the MCP component.
Example configuration file (mcp-config.json):
Start the server (if provided as a CLI or HTTP call):
Example: request the latest console logs
Note: exact menu names and start endpoints depend on the shipped package version in the repository. The above commands show typical usage patterns.
Available Resources
The MCP server exposes a set of resources useful to LLM-based tooling. Typical endpoints/resources include:
| Resource | Purpose |
|---|---|
| Console logs | Retrieve recent editor and runtime logs, with timestamps and stack traces |
| Test results | Access unit/integration test run summaries, failures, and stack traces |
| Hierarchy snapshot | Serialize scene root GameObjects, names, components, and transform data |
| Scene diff | Produce compact change sets or suggestions for scene modifications |
| Editor tools | Trigger registered editor actions, menu commands, or custom scripted tools |
| Asset database | Query assets by type, GUID, and path; preview metadata |
| Playmode control | Start/stop playmode, capture playmode events and frames |
Available resources are registered by the package and by any custom editor scripts that opt into the MCP bridge. Each resource typically accepts query parameters (limit, filters, serialization depth) and returns JSON structured for LM consumption.
Use Cases
- Debugging assistant: An LLM fetches the latest error logs and failing test traces, summarizes root causes, and suggests concrete editor commands to fix missing references or incorrect prefabs. The model can then request the editor to apply the suggested changes.
- Automated test summarization: After running CI or local test suites, the MCP server provides structured test outcomes to an LLM which classifies failures and drafts a checklist for triage.
- Scene editing by intent: A designer describes a change (“place three enemy prefabs along the platform and rotate them to face the player”); the LLM translates the intent into a sequence of MCP tool calls that instantiate prefabs and set transforms.
- Content generation and validation: Generate placeholder content (textures, prefabs) and have the LLM validate naming conventions, folder placement, and asset metadata via the asset database API.
Security & Best Practices
- Run the server only in a trusted environment; restrict binding to localhost or a secured network.
- Use token authentication (as shown in configuration) and enable firewall rules for the MCP port.
- Limit capabilities for untrusted models: prefer read-only access for third-party tools, and gate destructive editor actions behind explicit approval flows.
- Log and audit MCP requests so changes are traceable and reversible via source control.
Troubleshooting
- If the server does not start, check Unity console for initialization errors and port conflicts.
- Increase logBufferSize in config to capture more console history if requests return incomplete logs.
- If models produce invalid editor requests, enforce a review step before executing high-impact changes.
For the repository and latest implementation details, visit: https://github.com/CoderGamester/mcp-unity