Use coding agents with Unity Editor.
Chat with an agent inside Unity, or expose Unity tools to DotCraft, Claude Code, Codex, Cursor, and other agents.
| Workflow | Use this when | Entry point |
|---|---|---|
| In-Unity Agent Chat | You want to chat with DotCraft or another ACP agent inside Unity | Tools → DotCraft → AI Assistant |
| MCP Tool Gateway | You want external MCP clients such as Claude Code, Codex, or Cursor to call Unity tools | Tools → DotCraft → MCP Gateway Setup |
| C# Automation | You want an agent to perform batch operations in Unity | unity_execute_csharp |
| Custom Tools | You want to expose project-specific Unity tools | [AgentTool] |
In-editor ACP chat and MCP Tool Gateway are separate paths.
- In-editor chat starts an ACP agent process and talks to it inside Unity.
- MCP Tool Gateway starts a local Unity tool endpoint for external agents.
Open Window → Package Manager and add this Git URL:
https://github.com/DotHarness/dotcraft-unity.git
Minimum Unity version: 2021.3, recommended version: Unity 6.
- Install dotcraft-unity from Package Manager.
- Open Tools → DotCraft → AI Assistant.
- Select DotCraft or Custom ACP Agent in Project Settings → DotCraft.
- Click Connect.
- Open the Unity project.
- Enable Local Tool Gateway in Project Settings → DotCraft.
- Run Tools → DotCraft → MCP Gateway Setup.
- Choose your client: DotCraft, Claude Code, Codex, or Cursor.
- Start your coding agent from the project root.
- Create a static Editor method marked with
[AgentTool]. - Let Unity compile.
- Enable the tool in Project Settings → DotCraft → Unity Tools.
- Use it from DotCraft or any MCP client connected to the gateway.
dotcraft-unity exposes a local MCP Tool Gateway for external coding agents. While Unity Editor is running, MCP clients can connect to:
http://127.0.0.1:39777/dotcraft/mcp
Currently supports DotCraft, Claude Code, Codex, and Cursor.
The MCP endpoint uses sessionful Streamable HTTP for protocol version
2025-11-25.initializereturnsMCP-Session-Id; later POST and DELETE requests must send that header. Stale or expired sessions return HTTP404, which tells compliant clients to reinitialize.GET /dotcraft/mcpreturns HTTP405because the gateway does not expose an SSE stream.
dotcraft-unity provides one built-in Unity runtime tool based on Roslyn:
| Tool | Description |
|---|---|
unity_execute_csharp |
Compile and execute a C# method-body snippet in the Unity Editor process. |
Use unity_execute_csharp to read or modify scene state, selected objects, Console output, project metadata, and assets with C# snippets.
Unity Editor code can expose custom project tools by marking static methods with AgentToolAttribute. New custom tools are discovered in Edit → Project Settings → DotCraft → Unity Tools, default to disabled, and can be used from DotCraft or MCP clients after they are enabled.
using System.ComponentModel;
using DotCraft.Editor.Protocol;
using DotCraft.Editor.RuntimeTools;
public static class ExampleDotCraftTools
{
[Description("Return a greeting from an example Unity plugin.")]
[AgentTool(Namespace = "example", Name = "example_greet", Kind = AcpToolKind.Read)]
public static object Greet([Description("Name to greet.")] string name = "Unity")
{
return new { message = $"Hello, {name}." };
}
}Method parameters are converted to a JSON Schema with Newtonsoft.Json naming rules. See Documentation~/dynamic-tools.md for the full registration contract.
dotcraft-unity supports additional DotCraft features to improve development efficiency while reducing agent context overhead.
When using DotCraft as the ACP server, you do not need an MCP service. Built-in tools and custom tools are passed to the session through ACP extensions, reducing context overhead for non-Unity sessions.
Contributions are welcome in DotHarness/dotcraft-unity. For the agent harness itself, use DotHarness/dotcraft.
Apache License 2.0



