* feat: Add tool annotations for improved LLM tool understanding
Add readOnlyHint and destructiveHint annotations to all 23 tools
to help LLMs better understand tool behavior and make safer decisions.
Changes:
- Added readOnlyHint: true to 5 read-only tools:
- debug_request_context, find_in_file, validate_script,
manage_script_capabilities, get_sha
- Added destructiveHint: true to 18 tools that modify data:
- All CRUD tools, execution tools, and state-modifying tools
- Added title annotations for human-readable display
- Imported ToolAnnotations from mcp.types in all tool files
This improves tool safety metadata for MCP clients.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* docs: Clarify dual-purpose tool behavior in annotations
Address Sourcery AI review feedback by updating descriptions for
batch_execute and manage_* tools to clarify their safety characteristics
depend on the specific actions/operations being performed.
Updated tools:
- batch_execute: clarifies safety depends on contained tools
- read_console: clarifies 'get' is read-only, 'clear' is destructive
- manage_asset: lists read-only vs destructive actions
- manage_gameobject: lists read-only vs destructive actions
- manage_scene: lists read-only vs destructive actions
- manage_editor: lists read-only vs destructive actions
- manage_material: lists read-only vs destructive actions
- manage_shader: lists read-only vs destructive actions
- manage_script: lists read-only vs destructive actions
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix: Remove destructiveHint from mixed-behavior tools
Address maintainer feedback on annotation semantics. Tools that
have both read-only and modifying actions based on the 'action'
parameter should not be marked as destructive.
Changed to title-only annotations:
- manage_gameobject (find/get vs create/modify/delete)
- manage_scene (get_hierarchy vs create/load/save)
- manage_prefabs (open_stage vs save/create)
- manage_material (ping/get vs create/set)
- manage_shader (read vs create/update/delete)
- manage_editor (telemetry_status vs play/pause)
- manage_script router (read vs create/delete)
- batch_execute (depends on contained operations)
- execute_menu_item (behavior varies by menu item)
- execute_custom_tool (behavior varies by custom tool)
- read_console (get vs clear - ephemeral UI state)
Kept destructiveHint=True for always-destructive tools:
- apply_text_edits (always writes files)
- create_script (always creates files)
- delete_script (always deletes files)
- script_apply_edits (always writes files)
- run_tests (always executes tests)
- set_active_instance (always modifies session)
* fix: Remove destructiveHint from set_active_instance
set_active_instance is a session-scoped operation that switches which
Unity instance is active. It doesn't persist data and is easily reversible,
so it should not be marked as destructive.
* fix: Re-apply destructiveHint per maintainer guidance on MCP spec
Per maintainer feedback referencing MCP docs, tools should have
destructiveHint=True if they MAY perform a destructive action,
even if they also support read-only operations.
Re-applied to tools that can destroy Unity resources:
- manage_gameobject, manage_scene, manage_prefabs
- manage_material, manage_shader, manage_script
- manage_asset, batch_execute
- execute_menu_item, execute_custom_tool
Kept as-is (no destructiveHint):
- read_console (clearing is ephemeral UI state)
- set_active_instance (session toggle, not destructive)
- manage_editor (no destructive actions)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
* feat: Add tool annotations to manage_scriptable_object
Per reviewer request (@dsarno), add ToolAnnotations with destructiveHint=True
to manage_scriptable_object tool since it can create/modify ScriptableObject assets.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
* feat: Add tool annotations to new async test and refresh tools
Add readOnlyHint and destructiveHint annotations to tools added
since the last commit:
- refresh_unity: destructiveHint=True (triggers asset DB refresh)
- run_tests_async: destructiveHint=True (starts test execution)
- get_test_job: readOnlyHint=True (queries job status only)
Also regenerate uv.lock after rebase.
---------
Co-authored-by: triepod-ai <noreply@github.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: triepod-ai <199543909+triepod-ai@users.noreply.github.com>
|
||
|---|---|---|
| .. | ||
| src | ||
| tests | ||
| DOCKER_OVERVIEW.md | ||
| Dockerfile | ||
| LICENSE | ||
| README.md | ||
| __init__.py | ||
| pyproject.toml | ||
| pyrightconfig.json | ||
| uv.lock | ||
README.md
MCP for Unity Server
Model Context Protocol server for Unity Editor integration. Control Unity through natural language using AI assistants like Claude, Cursor, and more.
Maintained by Coplay - This project is not affiliated with Unity Technologies.
💬 Join our community: Discord Server
Required: Install the Unity MCP Plugin to connect Unity Editor with this MCP server. You also need uvx (requires uv) to run the server.
Installation
Option 1: PyPI
Install and run directly from PyPI using uvx.
Run Server (HTTP):
uvx --from mcpforunityserver mcp-for-unity --transport http --http-url http://localhost:8080
MCP Client Configuration (HTTP):
{
"mcpServers": {
"UnityMCP": {
"url": "http://localhost:8080/mcp"
}
}
}
MCP Client Configuration (stdio):
{
"mcpServers": {
"UnityMCP": {
"command": "uvx",
"args": [
"--from",
"mcpforunityserver",
"mcp-for-unity",
"--transport",
"stdio"
]
}
}
}
Option 2: From GitHub Source
Use this to run the latest released version from the repository. Change the version to main to run the latest unreleased changes from the repository.
{
"mcpServers": {
"UnityMCP": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/CoplayDev/unity-mcp@v8.7.1#subdirectory=Server",
"mcp-for-unity",
"--transport",
"stdio"
]
}
}
}
Option 3: Docker
Use Pre-built Image:
docker run -p 8080:8080 msanatan/mcp-for-unity-server:latest --transport http --http-url http://0.0.0.0:8080
Build Locally:
docker build -t unity-mcp-server .
docker run -p 8080:8080 unity-mcp-server --transport http --http-url http://0.0.0.0:8080
Configure your MCP client with "url": "http://localhost:8080/mcp".
Option 4: Local Development
For contributing or modifying the server code:
# Clone the repository
git clone https://github.com/CoplayDev/unity-mcp.git
cd unity-mcp/Server
# Run with uv
uv run src/main.py --transport stdio
Configuration
The server connects to Unity Editor automatically when both are running. No additional configuration needed.
Environment Variables:
DISABLE_TELEMETRY=true- Opt out of anonymous usage analyticsLOG_LEVEL=DEBUG- Enable detailed logging (default: INFO)
Example Prompts
Once connected, try these commands in your AI assistant:
- "Create a 3D player controller with WASD movement"
- "Add a rotating cube to the scene with a red material"
- "Create a simple platformer level with obstacles"
- "Generate a shader that creates a holographic effect"
- "List all GameObjects in the current scene"
Documentation
For complete documentation, troubleshooting, and advanced usage:
Requirements
- Python: 3.10 or newer
- Unity Editor: 2021.3 LTS or newer
- uv: Python package manager (Installation Guide)
License
MIT License - See LICENSE