MCP Unity is a bridge between the Unity Editor and AI coding assistants through the Model Context Protocol, allowing agents to query and manipulate Unity scenes and GameObjects. Unity developers use it with assistants such as Cursor, Windsurf, Claude Code, Codex, and Copilot, and the catalogue entries provide instructions for working with it.
Borrowing it
Nothing to install: this file belongs to CoderGamester/mcp-unity. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.
curl -O https://raw.githubusercontent.com/CoderGamester/mcp-unity/main/.windsurfrulesgit clone --depth 1 https://github.com/CoderGamester/mcp-unityWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/rules/codergamester/mcp-unity/windsurfrules)<a href="https://agentmods.dev/rules/codergamester/mcp-unity/windsurfrules"><img src="https://agentmods.dev/badge/rules/codergamester/mcp-unity/windsurfrules/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/rules/codergamester/mcp-unity/windsurfrules"><img src="https://agentmods.dev/badge/rules/codergamester/mcp-unity/windsurfrules.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.02865 | $0.02865 |
| Opus 5.5 | $0.01146 | $0.01146 |
| Sonnet 5.5 | $0.00573 | $0.00573 |
| Haiku 4.5 | $0.00286 | $0.00286 |
Grade B, and why
windsurfrules scanned grade B with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 26d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Unrestricted tool accessmediumExcessive agency
A wildcard tool grant or "run any command" leaves no least-privilege boundary at all.
* **Security/Safety**: Be cautious with tools that modify files or execute arbitrary code. Currently, the scope is within Unity, but general caution is advised. How it starts
The opening of the file, as written. The whole thing — 142 lines — stays where its author put it; the contents beside it link to each section on GitHub.
1. Project Structure
- The project consists of two main parts:
Editor/(Unity C#/Editor Package): A C# Unity Editor package that exposes Unity Editor functionality via a WebSocket bridge.Server/(Node.js/TypeScript): A Node.js server implementing the Model Context Protocol (MCP), using the official TypeScript SDK.
2. Communication & Protocol
- Primary Protocol: Model Context Protocol (MCP).
- The Unity side uses the
websocket-sharplibrary: https://github.com/sta/websocket-sharp/tree/master/websocket-sharp/Server - The Node.js server uses the
@modelcontextprotocol/sdkfor protocol implementation and exposes tools/resources/prompts to LLMs and AI clients.
- The Unity side uses the
- Transport Layer: WebSockets.
- Node.js server (
Server/) acts as a WebSocket client to the WebSocket server running within the Unity Editor (Editor/).
- Node.js server (
- Message Format: JSON. MCP defines the structure for tool/resource calls.
- Node.js tools typically send a request like:
{ method: "csharp_tool_name", params: { ... } }to Unity viamcpUnity.sendRequest(). - Unity C# tools receive this, execute, and return a
JObjectresponse.
- Node.js tools typically send a request like:
- Response Format: JSON. MCP defines the structure for tool/resource responses.
- Unity C# tools return a
JObjectresponse. - Node.js tools receive this and return a
JObjectresponse.
- Unity C# tools return a
- Error Handling: MCP defines a standard error format.
- Unity C# tools return an error object if an exception occurs.
- Node.js tools receive this and return an error object.
Communication Flow:
- Request: AI LLM Assistant -> Node.js MCP Server -> WebSocket Bridge -> Unity Editor Package -> Unity Editor API
- Response: Unity Editor Package -> WebSocket Bridge -> Node.js MCP Server -> AI LLM Assistant
3. Minimum Supported Versions
- Unity: 2022.3 or newer
- Node.js: 18.0.0 or newer
4. Key Components
Unity Editor Package (Editor/)
UnityBridge/:McpUnityServer.cs: Singleton. The central nervous system on the Unity side. Initializes WebSocket server, registers tools/resources, and dispatches incoming requests to appropriate handlers.- LLM Assistant Note: When adding new tools/resources, they must be registered here in
RegisterTools()orRegisterResources(). Pay attention to how existing tools are instantiated (currently directnew Tool()).
- LLM Assistant Note: When adding new tools/resources, they must be registered here in
McpUnitySocketHandler.cs: Handles individual WebSocket client connections, message parsing, and routing requests toMcpUnityServerfor tool/resource execution.McpUnityEditorWindow.cs: // TODO: Complete
Tools/: Contains C# classes inheriting fromMcpToolBase. Each class implements a specific action that can be triggered in Unity.- LLM Assistant Note: New tools should follow the
McpToolBasepattern: defineName(matching Node.js tool name),Description,IsAsync, and overrideExecute()orExecuteAsync(). UseUndo.RecordObjectfor actions that modify the scene or assets.
- LLM Assistant Note: New tools should follow the
Resources/: Contains C# classes inheriting fromMcpResourceBase(assumption, or similar base). These provide read-only access to Unity Editor state.- LLM Assistant Note: New resources should follow the
McpResourceBasepattern: defineName(matching Node.js resource name),Description, and overrideFetch()orFetchAsync()
- LLM Assistant Note: New resources should follow the
Services/: Contains classes providing specific functionalities, often designed for dependency injection.- Example:
TestRunnerService.cs,ConsoleLogsService.cs. - LLM Assistant Note: Prefer dependency injection for new services. If a tool needs a complex piece of logic, consider abstracting it into a service.
- Example:
Utils/: Utility classes for common tasks like logging (McpLogger.cs), settings management (McpUnitySettings.cs), GameObject creation (GameObjectHierarchyCreator.cs)
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 26d ago First seen · 142 lines · 2,865 tokens per session scan B 4467be258dce
windsurfrules is a cursor rule published in the GitHub repository CoderGamester/mcp-unity (2,012 stars, last pushed 26d ago), licensed MIT. It adds 2,865 tokens to every session, about $0.0115 per session on Opus 5.5. A static security scan graded it B with 1 finding (unrestricted tool access). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-10-12.
windsurfrules compared with cursor rules from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| windsurfrulesCoderGamester/mcp-unity | Cursor rule | 2.0k | 26d ago | MIT | B | 2,865 | Windsurf |
| cfx-lua-conventionsTMHSDigital/CFX-Developer-Tools | Cursor rule | 5 | 1mo ago | none | A | 0 | Cursor |
| cfx-javascript-conventionsTMHSDigital/CFX-Developer-Tools | Cursor rule | 5 | 1mo ago | none | A | 0 | Cursor |
| cfx-csharp-conventionsTMHSDigital/CFX-Developer-Tools | Cursor rule | 5 | 1mo ago | none | A | 0 | Cursor |
| ponytailDietrichGebert/ponytail | Cursor rule | 185k | 8d ago | MIT | A | 604 | Cursor |
| angular-20angular/angular | Cursor rule | 101k | yesterday | MIT | A | 0 | Cursor |
| dev-standardapache/superset | Cursor rule | 75k | today | Apache-2.0 | A | 1,147 | Cursor |