AI Agent Guide
July 12, 2026 ยท View on GitHub
Unity Cursor Toolkit is designed to give agents direct Unity Editor context without requiring users to paste console logs, scene state, or .meta files manually.
What Agents Can Do
- Read recent Unity console output with
read_console. - Capture current console/profiler context with
profiler_snapshot. - Read compact whole-console session transcripts with
profiler_snapshotusingaction: "readConsoleTranscript"after capturing or listing a session id. - Scan, summarize, query, and read the local Unity asset/object/reference graph with
unity_context. - Inspect project state with
project_info. - Inspect active scene hierarchy with
manage_sceneandaction: "getHierarchy". - Resolve Unity
.metafiles withresolve_meta. - Discover and schedule game-authored runtime workflows with
game_command. - Regenerate project files and verify script compilation with
editor_validation. - Inspect save state, save all open scenes and assets, and close Unity safely with
editor_lifecycle. - Control play mode, capture screenshots, execute menu items, manage assets, edit GameObjects/components, and trigger builds when allowed.
Safe Default Workflow
- Call
project_info. - Call
unity_contextwithaction: "summary"when.umetacontext/index.jsonalready exists, or ask to runaction: "scan"when the index is missing or stale. - Call
read_consolewithlevel: "error"and then without a level filter. - Call
profiler_snapshotwithaction: "current"when investigating performance, hitches, GC allocations, frame timing, or console event timelines. - When the compact grouped console timeline is needed, call
profiler_snapshotwithaction: "readConsoleTranscript"and the captured session id. - Call
manage_scenewithaction: "getHierarchy"before any scene edit. - Call
game_commandwithaction: "list"before scheduling a project-owned command. - After generated C# or project-file changes, preview
editor_validationwithaction: "sync_and_compile"anddryRun: true, then run it and pollaction: "status"untilpendingis false. - Use
dryRun: truefor the first mutating call. - Execute the real mutating call only after the user has approved the intended change.
- Before closing or restarting a user editor, exit Play Mode, call
editor_lifecyclewithaction: "status", previewaction: "saveAndQuit"withdryRun: true, then run it and wait for Unity's normal process exit.
Safety Controls
- Set
UNITY_CURSOR_TOOLKIT_MCP_READ_ONLY=1to block mutating MCP tool calls. - Pass
dryRun: trueto mutating Unity tools to return the normalized command without sending it to Unity. resolve_metarejects absolute paths and traversal outside the Unity project root.unity_contextwrites only.umetacontext/index.jsonduringaction: "scan";summary,query, andreadare read-only.- Tools include MCP annotations such as
readOnlyHint,destructiveHint,idempotentHint, andopenWorldHintso clients can expose safer approval UX. profiler_snapshotread actions are allowed in read-only mode, includingreadConsoleTranscript. Saving or clearing retained profiler sessions is treated as mutating.game_commandread actions arelistandstatus; scheduling and cancellation are mutating because they execute or stop game code.editor_validationread actions arelistandstatus; project-file synchronization and compile requests are mutating and supportdryRun.editor_lifecycleactionstatusis read-only.saveandsaveAndQuitare mutating;saveAndQuitcloses the editor only after dirty scenes and loaded persistent assets no longer report unsaved changes. Prefab Mode must be closed manually first.- Never force-terminate a user editor process. If the bridge cannot save, leave Unity open unless the user explicitly accepts the unsaved-work risk.
Runtime Game Commands
Use game_command when the Unity project has registered workflows through UnityCursorToolkit.AgentCommands. Commands run in play mode on Unity's main thread and should call the game's existing public subsystem methods.
Recommended flow:
- Call
game_commandwithaction: "list". - Start the command with
action: "run"and a stablecommandName. - Poll with
action: "status"and the returnedrunId. - Use
action: "cancel"only when the run is still pending or running.
Example:
{ "action": "run", "commandName": "auth.select_us_east", "args": {} }
See docs/GAME_COMMANDS.md for registration patterns and project integration notes.
Use host: "editorBatchmode" for command list/run calls that should execute through a fresh Unity batchmode process instead of the currently attached editor bridge. Pass unityPath or set UNITY_CURSOR_TOOLKIT_UNITY_PATH when Unity cannot be found from the project version.
Unity Context Index
Use unity_context when an agent needs project structure before deciding which files or Unity objects to inspect. The scanner reads Assets, Packages, and ProjectSettings, extracts .meta GUIDs plus Unity YAML anchors, and writes .umetacontext/index.json.
Recommended context flow:
- Call
unity_contextwithaction: "summary". - If the index is missing or stale and writes are allowed, call
action: "scan"; usedryRun: truefirst when approval is required. - Call
action: "query"withquery,path,guid,type,scenePath,prefabPath, ordependency. - Call
action: "read"with a returnednodeId,path,guid, ornameto include adjacent references.
Dependency Changes
- Prefer
npm cifor local installs. - Use npm 11.14.1 or newer with
--min-release-age=7for dependency updates. - Keep audit remediations lockfile-scoped when possible, and do not update packages newer than 7 days without an explicit documented security hotfix approval.
Agent Prompts
The standalone MCP server exposes prompts for common Unity workflows:
diagnose_unity_errorsinspect_active_sceneprepare_buildsafe_scene_edit_plan
These prompts are intentionally conservative: inspect first, summarize state, then use dry runs before mutation.
Useful Feature Ideas
- Prefab workflow tools: unpack/apply variants, inspect overrides, and instantiate prefabs safely.
- Unity Test Runner tools: list tests, run EditMode/PlayMode tests, and return structured failures.
- Build report tools: parse build output, surface warnings/errors, and compare artifact sizes.
- Package Manager tools: list packages, inspect versions, and propose dependency changes with dry-run output.