メインコンテンツまでスキップ

CLIリファレンス

mcp-for-unity / unity-mcp CLIは、MCP toolと同じUnity側C# handlerへterminalからアクセスするためのinterfaceです。MCPとCLIを分ける理由はPython serverの3つのsurfaceを参照してください。

起動

uvx --from mcpforunityserver mcp-for-unity <command> [args]
cd Server && uv run mcp-for-unity <command> [args]
uvx --from mcpforunityserver unity-mcp <command> [args]

Unityへの通信

CLIはPython serverのHTTP endpoint(既定http://127.0.0.1:8080)を使用します。Python serverからUnity EditorへはWebSocket経由でcommandを送ります。

共通option

Option既定内容
--host127.0.0.1Python server host
--port8080Python server port
--instance自動対象Unity instance
--formattexttext / json
--verbose, -voffrequest / response詳細を表示
--versionCLI versionを表示
--helphelpを表示

複数instanceは複数Unityインスタンスを参照してください。

主なcommand groupと対応MCP tool

CLI group内容対応tool
instanceinstance一覧・選択set_active_instance
scenescene操作manage_scene
gameobjectGameObject操作manage_gameobject
componentcomponent操作manage_components
scriptC# script操作manage_script
assetasset操作manage_asset
materialmaterial操作manage_material
prefabPrefab操作manage_prefabs
texturetexture生成manage_texture
shadershader操作manage_shader
vfxVFX操作manage_vfx
cameraCamera / Cinemachinemanage_camera
graphicsrender pipeline / lightingmanage_graphics
physics2D / 3D physicsmanage_physics
animationAnimator / AnimationClipmanage_animation
uiUI Toolkitmanage_ui
buildPlayer buildmanage_build
editorEditor state / test等manage_editorほか
packagesUPM package操作manage_packages
probuilderProBuildermanage_probuilder
profilerProfilermanage_profiler
codeC#実行execute_code
batch複数operationbatch_execute
tooltool group可視性manage_tools
reflectUnity API reflectionunity_reflect
docsUnity docs取得unity_docs

optionの正本

各command自身のhelpを最終的な正本とします。

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

詳細な実行例はCLI使用例を参照してください。

実装:

  • Server/src/cli/commands/
  • Server/src/cli/main.py