CoplayDev/unity-mcp

Allow add Tools by editor script.

Closed this issue · 2 comments

Can I dynamically add the MCP Tool by writing an editor script, as follows:

#if UNITY_EDITOR

[MCPTool]
public class ExampleTool : MCPTool
{
    protected override string Name => "Tool Name...";
    protected override string Descrption => "Description...";
    protected override void Execute(JObject args) { ... }
}

#endif

This might be more usable for highly process-oriented business projects.

That unfortunately won't work with how it's currently set up. You'll need to update both the Unity plugin and the MCP server itself, which is currently written in Python: https://github.com/CoplayDev/unity-mcp/tree/main/UnityMcpBridge/UnityMcpServer~/src/tools

I think for that to be possible we'd need some way to centralize the tool definition in C#, and have a way to update the tools on the server, and then expose that to users.

Some ways I imagine this can be done:

  • Have a way for the plugin to publish a JSON tool schema, and have the server auto-register those tools.
    • Seems like the most feasible way
  • Move MCP server to C#
  • Have a basic tool in the server called "discover_tools", and all it does it get the dynamically set tools from the Unity plugin. But this loses a lot of the type discovery and seems prone to lower accuracy via hallucinations

Not sure how high I'll rank this feature request in the priorities, though I do see it's utility. CC @dsarno @Scriptwonder

Continued in #293