Skip to content

t1k:unity:base:mcp-tool-creator

FieldValue
Modulebase
Version2.2.2
Effortmedium
Tools

Keywords: bridge, MCP, tool creator, unity

/t1k:unity:base:mcp-tool-creator
[tool-name] [description]

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.

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 clients

Auto-discovery: C# uses [McpForUnityTool] attribute; Python uses @mcp_for_unity_tool decorator. Both auto-register — no manual wiring needed.

  1. Create Manage<Domain>.cs with [McpForUnityTool] attribute and HandleCommand(JObject params)
  2. Route actions via switch expression: action switch { "do_x" => DoX(p), _ => ErrorResponse }
  3. Create manage_<domain>.py with @mcp_for_unity_tool decorator and typed Annotated params
  4. Send params via send_with_unity_instance → return {"success": bool, "message": str, "data": ...}
  5. 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.

p.GetRequired("action") // Result<string> — check .IsSuccess
p.Get("key", "default") // string with fallback
p.GetBool("key", false) // bool
p.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.

  • Naming: ManageFoo (C#) → manage_foo (Python) → manage_foo (MCP tool name)
  • Action-based routing: All tools use action as 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
  • C# handler must be in Editor folder: [McpForUnityTool] classes must live under Editor/ — placing them in Runtime/ causes build errors since they reference UnityEditor APIs
  • Python registration path must match: The Python file name manage_<domain>.py must 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
FileContents
references/tool-templates.mdFull C# + Python templates, ToolParams API, conventions, verification