t1k:unity:base:mcp-tool-creator
| Field | Value |
|---|---|
| Module | base |
| Version | 2.2.2 |
| Effort | medium |
| Tools | — |
Keywords: bridge, MCP, tool creator, unity
How to invoke
Section titled “How to invoke”/t1k:unity:base:mcp-tool-creator[tool-name] [description]Unity MCP Tool Creator
Section titled “Unity MCP Tool Creator”Create/update MCP tools for the Unity MCP package (e.g., Packages/com.coplaydev.unity-mcp).
Handles: MCP tool creation (C# + Python), tool updates, action-based routing, parameter handling. Does NOT handle: MCP server infrastructure, transport layer, middleware, resource creation.
Architecture
Section titled “Architecture”Each MCP tool requires 2 files:
Packages/[your-mcp-package]/ MCPForUnity/Editor/Tools/Manage<Domain>.cs # C# — handles commands in Unity Editor Server/src/services/tools/manage_<domain>.py # Python — MCP tool definition for LLM clientsAuto-discovery: C# uses [McpForUnityTool] attribute; Python uses @mcp_for_unity_tool decorator. Both auto-register — no manual wiring needed.
Step-by-Step Workflow
Section titled “Step-by-Step Workflow”- Create
Manage<Domain>.cswith[McpForUnityTool]attribute andHandleCommand(JObject params) - Route actions via switch expression:
action switch { "do_x" => DoX(p), _ => ErrorResponse } - Create
manage_<domain>.pywith@mcp_for_unity_tooldecorator and typedAnnotatedparams - Send params via
send_with_unity_instance→ return{"success": bool, "message": str, "data": ...} - Verify: check Unity console for compile errors, test each action, confirm Python server logs registration
→ See references/tool-templates.md for complete C# and Python file templates.
Key API — C# Parameter Helpers
Section titled “Key API — C# Parameter Helpers”p.GetRequired("action") // Result<string> — check .IsSuccessp.Get("key", "default") // string with fallbackp.GetBool("key", false) // boolp.GetInt("key") // int?Response types: SuccessResponse("msg", data), ErrorResponse("msg"), PendingResponse("msg", poll)
→ See references/tool-templates.md for full ToolParams API, response types, attribute options, conventions.
Conventions
Section titled “Conventions”- Naming:
ManageFoo(C#) →manage_foo(Python) →manage_foo(MCP tool name) - Action-based routing: All tools use
actionas first discriminator - Editor-only: All C# code under
Editor/— never reference from Runtime - Studio tools: Create new files, don’t modify upstream — minimizes merge conflicts
Gotchas
Section titled “Gotchas”- C# handler must be in Editor folder:
[McpForUnityTool]classes must live underEditor/— placing them inRuntime/causes build errors since they referenceUnityEditorAPIs - Python registration path must match: The Python file name
manage_<domain>.pymust match the tool name used in@mcp_for_unity_tool. Mismatches cause the tool to not register - Tool name collisions: If two packages register the same tool name, only one loads. Prefix studio tools with a unique namespace (e.g.,
studio_manage_x) to avoid conflicts with upstream MCP tools
Reference Files
Section titled “Reference Files”| File | Contents |
|---|---|
references/tool-templates.md | Full C# + Python templates, ToolParams API, conventions, verification |