Back to Unity Mcp

CLI Reference

website/docs/reference/cli.md

9.7.15.5 KB
Original Source

CLI Reference

The mcp-for-unity CLI is a developer-facing terminal for the same Unity automations the MCP tools expose. Both invoke the same C# HandleCommand methods on the Unity side — see Three-Layer Python Design for why both layers exist.

Invocation

bash
# Run via uvx (no install)
uvx --from mcpforunityserver mcp-for-unity <command> [args]

# Run from a Server checkout
cd Server && uv run mcp-for-unity <command> [args]

# Run via the dedicated CLI entry point (alias)
uvx --from mcpforunityserver unity-mcp <command> [args]

How it talks to Unity

The CLI uses HTTP to the Python server (default http://127.0.0.1:8080), regardless of how your MCP clients are configured. The Python server in turn talks to the connected Unity Editor via WebSocket. MCP tools take a similar path via WebSocket directly; CLI commands take HTTP.

Global flags

FlagDefaultMeaning
--host127.0.0.1Python server host to connect to
--port8080Python server port
--instance(auto)Target Unity instance (Name@hash, hash prefix, or port number)
--formattextOutput format: text or json
--verbose / -voffPrint full request/response payloads
--versionPrint CLI version and exit
--helpShow command help

For multi-instance setups, see Multi-Instance Routing.

Command groups

The CLI mirrors the MCP tool catalog. Each command group wraps one or more manage_* tools.

GroupWhat it doesEquivalent MCP tool
mcp-for-unity instanceList instances, check connection, set activeset_active_instance
mcp-for-unity sceneLoad/save/query/edit scenesmanage_scene
mcp-for-unity gameobjectCreate/transform/delete GameObjectsmanage_gameobject
mcp-for-unity componentAdd/remove/configure componentsmanage_components
mcp-for-unity scriptCreate/read/modify C# scriptsmanage_script
mcp-for-unity assetAsset import/create/modify/searchmanage_asset
mcp-for-unity materialMaterial CRUD + shader propsmanage_material
mcp-for-unity prefabPrefab create/instantiate/unpackmanage_prefabs
mcp-for-unity textureTexture create + patterns/gradientsmanage_texture
mcp-for-unity shaderShader CRUDmanage_shader
mcp-for-unity vfxVFX, particle systems, trailsmanage_vfx
mcp-for-unity cameraCamera + Cinemachine presetsmanage_camera
mcp-for-unity graphicsVolumes, post-processing, light bakemanage_graphics
mcp-for-unity lightingLighting-specific operations(subset of graphics)
mcp-for-unity physics3D + 2D physics, joints, queriesmanage_physics
mcp-for-unity audioAudio operations(subset of asset)
mcp-for-unity animationAnimator + AnimationClipmanage_animation
mcp-for-unity uiUI Toolkit — UXML/USS/UIDocumentmanage_ui
mcp-for-unity buildPlayer builds across platformsmanage_build
mcp-for-unity editorEditor state, play mode, undo/redomanage_editor
mcp-for-unity packagesUPM install/remove/embedmanage_packages
mcp-for-unity probuilderProBuilder meshesmanage_probuilder
mcp-for-unity profilerProfiler session + counters + snapshotsmanage_profiler
mcp-for-unity codeExecute arbitrary C# in the Editorexecute_code
mcp-for-unity batchRun multiple operations atomicallybatch_execute
mcp-for-unity toolActivate/deactivate tool groupsmanage_tools
mcp-for-unity reflectInspect Unity APIs via reflectionunity_reflect
mcp-for-unity docsFetch Unity docs (ScriptReference, Manual)unity_docs

Discovering subcommands and flags

Every group supports --help:

bash
mcp-for-unity scene --help
mcp-for-unity scene load --help

The help text is the authoritative per-command reference — flags, choices, and defaults all live there because the CLI is built on Click and self-describes.

Examples

See CLI Examples for end-to-end walkthroughs and the CLI Usage Guide for narrative context (when to use the CLI vs an MCP client).

Source

CLI command definitions: Server/src/cli/commands/. Entry point: Server/src/cli/main.py.