Skip to content

Conversation

@triepod-ai
Copy link

@triepod-ai triepod-ai commented Dec 23, 2025

Summary

Adds MCP tool annotations (readOnlyHint, destructiveHint, title) to all 23 tools to help LLMs better understand tool behavior and make safer decisions about tool execution.

Changes

  • Added readOnlyHint: true to 5 read-only tools:

    • debug_request_context - Returns current FastMCP request context
    • find_in_file - Searches files with regex patterns
    • validate_script - Validates C# scripts and returns diagnostics
    • manage_script_capabilities - Gets supported operations and limits
    • get_sha - Gets SHA256 and metadata for scripts
  • Added destructiveHint: true to 18 tools that modify state:

    • CRUD tools: manage_asset, manage_gameobject, manage_material, manage_prefabs, manage_scene, manage_shader, manage_editor
    • Script editing: apply_text_edits, create_script, delete_script, manage_script, script_apply_edits
    • Execution: execute_menu_item, execute_custom_tool, batch_execute, run_tests
    • State: set_active_instance, read_console (can clear console)
  • Added title annotations for human-readable display

  • Imported ToolAnnotations from mcp.types in all tool files

Why This Matters

Tool annotations are advisory hints for MCP clients that enable:

  • Safety automation: Clients like Claude Code auto-approve tools with readOnlyHint: true without user confirmation
  • UI/UX improvements: Visual indicators help users understand tool behavior
  • Tool discovery: Clients can filter/group tools by characteristics

Testing

  • Server dependencies install successfully (`uv sync`)
  • Linter passes (ruff) - no new errors introduced
  • All 23 tools register with correct annotations
  • `ToolAnnotations` imports work correctly with `mcp>=1.16.0`

Tool Annotation Summary

Tool Name Title Hint
debug_request_context Debug Request Context readOnly
find_in_file Find in File readOnly
validate_script Validate Script readOnly
manage_script_capabilities Manage Script Capabilities readOnly
get_sha Get SHA readOnly
batch_execute Batch Execute destructive
execute_custom_tool Execute Custom Tool destructive
execute_menu_item Execute Menu Item destructive
manage_asset Manage Asset destructive
manage_editor Manage Editor destructive
manage_gameobject Manage GameObject destructive
manage_material Manage Material destructive
manage_prefabs Manage Prefabs destructive
manage_scene Manage Scene destructive
apply_text_edits Apply Text Edits destructive
create_script Create Script destructive
delete_script Delete Script destructive
manage_script Manage Script destructive
manage_shader Manage Shader destructive
read_console Read Console destructive
run_tests Run Tests destructive
script_apply_edits Script Apply Edits destructive
set_active_instance Set Active Instance destructive

🤖 Generated with Claude Code

Summary by Sourcery

Add MCP ToolAnnotations metadata to Unity MCP tools to indicate read-only vs destructive behavior and provide human-readable titles for safer client-side usage.

New Features:

  • Introduce ToolAnnotations metadata on script management, editor, asset, scene, shader, prefab, console, test, batch execution, and custom tool MCP endpoints to describe their behavior and risk level.

Enhancements:

  • Mark read-only tools with readOnlyHint and state-mutating tools with destructiveHint to enable safer automation and better UI in MCP clients.

Summary by CodeRabbit

  • New Features

    • Tools now expose explicit metadata labels (destructive vs read-only) so users see operation impact.
    • Many tools include human-friendly titles for clearer identification.
  • Improvements

    • Tool descriptions expanded with safety notes and action categorizations (read-only vs destructive).
    • Several management tools (scenes, scripts, assets, editor, materials, prefabs, shaders, etc.) surface richer parameters and clearer workflows.

✏️ Tip: You can customize this high-level summary in your review settings.

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 <[email protected]>
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Dec 23, 2025

Reviewer's Guide

Adds MCP ToolAnnotations (title, readOnlyHint, destructiveHint) across all Unity MCP tools to improve client understanding of tool behavior and safety characteristics, plus a uv.lock update for the newer MCP dependency.

Sequence diagram for LLM client using tool annotations for safety decisions

sequenceDiagram
    actor User
    participant LlmClient
    participant McpServer
    participant UnityEditor

    User->>LlmClient: Request Unity project change
    LlmClient->>McpServer: List available tools
    McpServer-->>LlmClient: Tool metadata with ToolAnnotations

    LlmClient->>LlmClient: Classify tools by readOnlyHint and destructiveHint

    LlmClient->>User: Present plan using read-only tools first

    User->>LlmClient: Approve read-only steps
    LlmClient->>McpServer: Call FindInFileTool (readOnlyHint true)
    McpServer->>UnityEditor: Read file contents
    UnityEditor-->>McpServer: File matches
    McpServer-->>LlmClient: Read-only results

    LlmClient->>LlmClient: Auto-approve further read-only tools

    LlmClient->>User: Request confirmation for destructive tools
    User->>LlmClient: Confirm destructive actions

    LlmClient->>McpServer: Call ApplyTextEditsTool (destructiveHint true)
    McpServer->>UnityEditor: Apply code edits
    UnityEditor-->>McpServer: Edit success
    McpServer-->>LlmClient: Operation result
    LlmClient-->>User: Summarize changes and status
Loading

Class diagram for MCP tools using ToolAnnotations

classDiagram
    class ToolAnnotations {
        +string title
        +bool readOnlyHint
        +bool destructiveHint
    }

    class ApplyTextEditsTool {
        +Context ctx
        +string uri
        +string edits
        +ToolAnnotations annotations
    }

    class CreateScriptTool {
        +Context ctx
        +string path
        +string contents
        +ToolAnnotations annotations
    }

    class DeleteScriptTool {
        +Context ctx
        +string uri
        +ToolAnnotations annotations
    }

    class ValidateScriptTool {
        +Context ctx
        +string uri
        +ToolAnnotations annotations
    }

    class ManageScriptTool {
        +Context ctx
        +string action
        +ToolAnnotations annotations
    }

    class ManageScriptCapabilitiesTool {
        +Context ctx
        +ToolAnnotations annotations
    }

    class GetShaTool {
        +Context ctx
        +string uri
        +ToolAnnotations annotations
    }

    class DebugRequestContextTool {
        +Context ctx
        +ToolAnnotations annotations
    }

    class FindInFileTool {
        +Context ctx
        +string uri
        +string pattern
        +ToolAnnotations annotations
    }

    class ExecuteMenuItemTool {
        +Context ctx
        +string menu_path
        +ToolAnnotations annotations
    }

    class ManageAssetTool {
        +Context ctx
        +string action
        +ToolAnnotations annotations
    }

    class ManageEditorTool {
        +Context ctx
        +string action
        +ToolAnnotations annotations
    }

    class ManageGameobjectTool {
        +Context ctx
        +string action
        +ToolAnnotations annotations
    }

    class ManageMaterialTool {
        +Context ctx
        +string action
        +ToolAnnotations annotations
    }

    class ManagePrefabsTool {
        +Context ctx
        +string action
        +ToolAnnotations annotations
    }

    class ManageSceneTool {
        +Context ctx
        +string action
        +ToolAnnotations annotations
    }

    class ManageShaderTool {
        +Context ctx
        +string action
        +ToolAnnotations annotations
    }

    class ReadConsoleTool {
        +Context ctx
        +string action
        +ToolAnnotations annotations
    }

    class SetActiveInstanceTool {
        +Context ctx
        +string instance
        +ToolAnnotations annotations
    }

    class BatchExecuteTool {
        +Context ctx
        +list batch
        +ToolAnnotations annotations
    }

    class ExecuteCustomToolTool {
        +Context ctx
        +string tool_name
        +dict parameters
        +ToolAnnotations annotations
    }

    class RunTestsTool {
        +Context ctx
        +string filter
        +ToolAnnotations annotations
    }

    class ScriptApplyEditsTool {
        +Context ctx
        +string name
        +list edits
        +ToolAnnotations annotations
    }

    ToolAnnotations <.. ApplyTextEditsTool : uses
    ToolAnnotations <.. CreateScriptTool : uses
    ToolAnnotations <.. DeleteScriptTool : uses
    ToolAnnotations <.. ValidateScriptTool : uses
    ToolAnnotations <.. ManageScriptTool : uses
    ToolAnnotations <.. ManageScriptCapabilitiesTool : uses
    ToolAnnotations <.. GetShaTool : uses
    ToolAnnotations <.. DebugRequestContextTool : uses
    ToolAnnotations <.. FindInFileTool : uses
    ToolAnnotations <.. ExecuteMenuItemTool : uses
    ToolAnnotations <.. ManageAssetTool : uses
    ToolAnnotations <.. ManageEditorTool : uses
    ToolAnnotations <.. ManageGameobjectTool : uses
    ToolAnnotations <.. ManageMaterialTool : uses
    ToolAnnotations <.. ManagePrefabsTool : uses
    ToolAnnotations <.. ManageSceneTool : uses
    ToolAnnotations <.. ManageShaderTool : uses
    ToolAnnotations <.. ReadConsoleTool : uses
    ToolAnnotations <.. SetActiveInstanceTool : uses
    ToolAnnotations <.. BatchExecuteTool : uses
    ToolAnnotations <.. ExecuteCustomToolTool : uses
    ToolAnnotations <.. RunTestsTool : uses
    ToolAnnotations <.. ScriptApplyEditsTool : uses

    class McpForUnityToolDecorator {
        +ToolAnnotations annotations
        +string description
        +string name
    }

    McpForUnityToolDecorator o-- ToolAnnotations
    McpForUnityToolDecorator <.. ApplyTextEditsTool
    McpForUnityToolDecorator <.. ValidateScriptTool
    McpForUnityToolDecorator <.. DebugRequestContextTool
    McpForUnityToolDecorator <.. BatchExecuteTool
    McpForUnityToolDecorator <.. ScriptApplyEditsTool
Loading

File-Level Changes

Change Details Files
Add ToolAnnotations to script management tools to mark read-only vs destructive behavior and provide human-readable titles.
  • Wrap existing mcp_for_unity_tool decorators for script tools in multi-argument form to add annotations parameter.
  • Mark apply_text_edits, create_script, delete_script, manage_script, and script_apply_edits as destructiveHint with appropriate title values.
  • Mark validate_script, manage_script_capabilities, and get_sha as readOnlyHint with appropriate title values.
Server/src/services/tools/manage_script.py
Server/src/services/tools/script_apply_edits.py
Annotate general Unity editor/tools APIs with titles and destructive hints for safer client execution.
  • Import ToolAnnotations where needed for tool decorators.
  • Add annotations with destructiveHint=True and descriptive titles to tools that can modify project/editor state, including menu execution, asset/editor/gameobject/material/prefab/scene/shader management, console operations, test runs, batch execution, custom tool execution, and active instance changes.
Server/src/services/tools/execute_menu_item.py
Server/src/services/tools/manage_asset.py
Server/src/services/tools/manage_editor.py
Server/src/services/tools/manage_gameobject.py
Server/src/services/tools/manage_material.py
Server/src/services/tools/manage_prefabs.py
Server/src/services/tools/manage_scene.py
Server/src/services/tools/manage_shader.py
Server/src/services/tools/read_console.py
Server/src/services/tools/run_tests.py
Server/src/services/tools/set_active_instance.py
Server/src/services/tools/batch_execute.py
Server/src/services/tools/execute_custom_tool.py
Annotate read-only diagnostic/introspection tools for automatic safe execution by clients.
  • Import ToolAnnotations and add annotations with readOnlyHint=True and descriptive titles to debug_request_context and find_in_file.
Server/src/services/tools/debug_request_context.py
Server/src/services/tools/find_in_file.py
Update dependency lockfile to align with ToolAnnotations usage (mcp>=1.16.0).
  • Refresh uv.lock to capture the MCP version that exposes ToolAnnotations and any transitive dependency adjustments.
Server/uv.lock

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 23, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Walkthrough

This PR adds ToolAnnotations metadata (titles and readOnly/destructive hints) to many @mcp_for_unity_tool-decorated server tools, and expands public signatures for manage_scene and several endpoints in manage_script with additional parameters and richer descriptions.

Changes

Cohort / File(s) Summary
Destructive Tools with ToolAnnotations
Server/src/services/tools/batch_execute.py, Server/src/services/tools/execute_custom_tool.py, Server/src/services/tools/execute_menu_item.py, Server/src/services/tools/manage_asset.py, Server/src/services/tools/manage_editor.py, Server/src/services/tools/manage_gameobject.py, Server/src/services/tools/manage_material.py, Server/src/services/tools/manage_prefabs.py, Server/src/services/tools/manage_shader.py, Server/src/services/tools/run_tests.py, Server/src/services/tools/script_apply_edits.py, Server/src/services/tools/set_active_instance.py
Added from mcp.types import ToolAnnotations and annotations=ToolAnnotations(title="...", destructiveHint=True) to each tool's @mcp_for_unity_tool decorator; several decorator descriptions expanded to list read-only vs destructive actions.
Read-Only Tools with ToolAnnotations
Server/src/services/tools/debug_request_context.py, Server/src/services/tools/find_in_file.py, Server/src/services/tools/read_console.py
Added ToolAnnotations import and annotations=ToolAnnotations(title="...", readOnlyHint=True) to @mcp_for_unity_tool decorators; no runtime logic changes.
Multi-Tool Annotation & Signature Updates
Server/src/services/tools/manage_script.py
Added ToolAnnotations to multiple tool decorators (apply_text_edits, create_script, delete_script, validate_script, manage_script, manage_script_capabilities, get_sha); expanded several endpoint signatures (e.g., create_scriptcontents, script_type, namespace; validate_scriptlevel, include_diagnostics; manage_script → added contents, script_type, namespace) and enriched descriptions.
Tool with Signature Expansion
Server/src/services/tools/manage_scene.py
Added ToolAnnotations(title="Manage Scene", destructiveHint=True), expanded manage_scene public signature with optional parameters (name, path, build_index, screenshot_file_name, screenshot_super_size) and more detailed Annotated type hints; description expanded.

Sequence Diagram(s)

(Skipped — changes are metadata and signature additions without new multi-component control flow.)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • justinpbarnett

Poem

🐰 I hopped through lines with carrot-bright,

I labeled tools both safe and blight.
Read-only whispers, destructive drum,
Decorator tunes — the changes hum.
A rabbit's cheer: the registry's done.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: Add tool annotations for improved LLM tool understanding' accurately summarizes the main change: adding MCP tool annotations to improve LLM understanding of tool behavior.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • Several tools that can be either read-only or mutating depending on the action (e.g., manage_* routers, read_console, batch_execute) are marked unconditionally with destructiveHint=True; consider whether you want more granular signaling (e.g., per-action parameters or separate tools) so clients can auto-approve genuinely read-only invocations.
  • The ToolAnnotations blocks repeat very similar title/readOnlyHint/destructiveHint definitions across many tools; consider centralizing these (e.g., constants or a small helper wrapper around mcp_for_unity_tool) to reduce duplication and make future changes to annotation conventions easier.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Several tools that can be either read-only or mutating depending on the action (e.g., `manage_*` routers, `read_console`, `batch_execute`) are marked unconditionally with `destructiveHint=True`; consider whether you want more granular signaling (e.g., per-action parameters or separate tools) so clients can auto-approve genuinely read-only invocations.
- The `ToolAnnotations` blocks repeat very similar `title`/`readOnlyHint`/`destructiveHint` definitions across many tools; consider centralizing these (e.g., constants or a small helper wrapper around `mcp_for_unity_tool`) to reduce duplication and make future changes to annotation conventions easier.

## Individual Comments

### Comment 1
<location> `Server/src/services/tools/batch_execute.py:25` </location>
<code_context>
 from transport.plugin_hub import PluginHub


 @mcp_for_unity_tool(
-    description="Return the current FastMCP request context details (client_id, session_id, and meta dump)."
+    description="Return the current FastMCP request context details (client_id, session_id, and meta dump).",
</code_context>

<issue_to_address>
**suggestion:** Clarify the destructive nature of `batch_execute`, since it can also wrap read-only calls.

Labeling `batch_execute` as destructive is reasonable for safety, but it will cause all uses to be treated as risky, even read-only batches. Consider adjusting the description to clarify that *batches may be destructive depending on the tools they contain*, so clients and agents can reflect that nuance instead of assuming every `batch_execute` call mutates state.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

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 <[email protected]>
@triepod-ai
Copy link
Author

Thank you for the review feedback!

Re: Dual-purpose tools: I've updated the descriptions for batch_execute, read_console, and all manage_* routers to clarify that their safety characteristics depend on the specific operations/tools being invoked. Each tool description now explicitly lists which actions are read-only vs destructive.

I've kept destructiveHint=True as a conservative default since MCP annotations are static metadata and these tools can perform destructive operations. This ensures clients show appropriate warnings for potentially risky invocations.

Re: Centralization: Valid point for larger codebases. For this PR's scope (23 tools), I prefer keeping annotations explicit per-tool for clarity and auditability. The repetitive pattern is intentional—it makes each tool self-documenting and easy to audit. Happy to refactor if the maintainers prefer centralized constants.

Changes pushed in commit 79c5ec7.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
Server/src/services/tools/manage_script.py (1)

512-519: Consolidate multiple annotation strings into single descriptions for consistency.

Lines 513-519 contain multiple string metadata values in Annotated types (name, path, contents, script_type). The codebase convention uses single description strings. Combine the metadata into a single, more informative description string—for example: name: Annotated[str, "Script name without .cs extension"] and path: Annotated[str, "Path under Assets/ to create the script, e.g., 'Assets/Scripts/My.cs'"].

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3e406a4 and 79c5ec7.

📒 Files selected for processing (9)
  • Server/src/services/tools/batch_execute.py
  • Server/src/services/tools/manage_asset.py
  • Server/src/services/tools/manage_editor.py
  • Server/src/services/tools/manage_gameobject.py
  • Server/src/services/tools/manage_material.py
  • Server/src/services/tools/manage_scene.py
  • Server/src/services/tools/manage_script.py
  • Server/src/services/tools/manage_shader.py
  • Server/src/services/tools/read_console.py
🚧 Files skipped from review as they are similar to previous changes (5)
  • Server/src/services/tools/batch_execute.py
  • Server/src/services/tools/manage_shader.py
  • Server/src/services/tools/manage_asset.py
  • Server/src/services/tools/manage_editor.py
  • Server/src/services/tools/read_console.py
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: msanatan
Repo: CoplayDev/unity-mcp PR: 301
File: docs/CUSTOM_TOOLS.md:54-62
Timestamp: 2025-10-03T22:11:46.002Z
Learning: In Unity MCP, the `description` parameter in the `mcp_for_unity_tool` decorator is technically optional but should always be included as a best practice. Without it, there's a higher chance that MCP clients will not parse the tool correctly. All Unity MCP tools should include the description in the decorator for compatibility.
📚 Learning: 2025-10-03T22:11:46.002Z
Learnt from: msanatan
Repo: CoplayDev/unity-mcp PR: 301
File: docs/CUSTOM_TOOLS.md:54-62
Timestamp: 2025-10-03T22:11:46.002Z
Learning: In Unity MCP, the `description` parameter in the `mcp_for_unity_tool` decorator is technically optional but should always be included as a best practice. Without it, there's a higher chance that MCP clients will not parse the tool correctly. All Unity MCP tools should include the description in the decorator for compatibility.

Applied to files:

  • Server/src/services/tools/manage_gameobject.py
  • Server/src/services/tools/manage_material.py
  • Server/src/services/tools/manage_script.py
  • Server/src/services/tools/manage_scene.py
📚 Learning: 2025-11-05T18:23:12.349Z
Learnt from: msanatan
Repo: CoplayDev/unity-mcp PR: 368
File: MCPForUnity/UnityMcpServer~/src/resources/menu_items.py:15-15
Timestamp: 2025-11-05T18:23:12.349Z
Learning: In Unity MCP, the `name` parameter in the `mcp_for_unity_resource` decorator is the external API name exposed to MCP clients (LLMs, AI agents). The command string passed to `async_send_command_with_retry` or `async_send_with_unity_instance` (e.g., "get_menu_items") is the internal command identifier that must match the C# side. These are decoupled, allowing external API naming to evolve independently of internal command routing.

Applied to files:

  • Server/src/services/tools/manage_script.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Sourcery review
🔇 Additional comments (5)
Server/src/services/tools/manage_gameobject.py (1)

15-21: Annotations and description correctly applied.

The destructiveHint=True is appropriate since this tool supports destructive operations (create, modify, delete, etc.), even though some actions are read-only. The description clearly documents which actions fall into each category, enabling LLMs to make informed decisions.

Server/src/services/tools/manage_material.py (1)

17-23: Annotations properly configured.

The tool annotation correctly marks this as destructive since most operations modify material state. The description comprehensively categorizes all 7 actions (ping, get_material_info as read-only; the rest as destructive).

Server/src/services/tools/manage_scene.py (1)

12-18: Annotations correctly applied with accurate action classification.

The description properly categorizes screenshot as read-only (captures without modifying) and scene-modifying operations (create, load, save) as destructive. Good alignment between the action literals and documented behavior.

Server/src/services/tools/manage_script.py (2)

67-86: Well-documented tool with appropriate destructive hint.

The multi-line description provides excellent guidance for safe usage, including the recommended workflow and notes about alternative tools. The destructiveHint=True correctly reflects that this tool modifies script files.


377-383: All tool annotations correctly configured.

Each tool has appropriate hints:

  • create_script, delete_script, manage_scriptdestructiveHint=True
  • validate_script, manage_script_capabilities, get_shareadOnlyHint=True

The descriptions clearly document tool purposes. Based on learnings, including description in the decorator is a best practice for MCP client compatibility.

Also applies to: 428-434, 456-462, 503-509, 577-590, 615-621

@dsarno
Copy link
Collaborator

dsarno commented Dec 24, 2025

Read console can't do anything destructive can it?

Address maintainer feedback from dsarno. Console clearing affects
ephemeral UI state, not project data - it's not "destructive" in the
MCP sense (irreversible data loss/modification).

Co-Authored-By: Claude <[email protected]>
@triepod-ai
Copy link
Author

You're right! Clearing the console affects ephemeral UI state, not project data – it's not "destructive" in the MCP sense (irreversible data loss/modification). Changed to readOnlyHint=True in 9752549.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
Server/src/services/tools/read_console.py (1)

15-21: Annotations and description look good!

The readOnlyHint=True annotation accurately reflects that this tool doesn't modify persistent project state, and the updated description provides helpful guidance about the count parameter format. The defensive coercion code (lines 67-82) already handles both int and string inputs correctly.

Optional: Consider clarifying "read-only" scope in the description

Since the tool supports both action='get' (read-only) and action='clear' (modifies ephemeral console UI), you might optionally expand the description to clarify that "read-only" refers to project/persistent state, not the console buffer itself. For example:

-    description="Gets messages from or clears the Unity Editor console. Note: For maximum client compatibility, pass count as a quoted string (e.g., '5').",
+    description="Gets messages from or clears the Unity Editor console (clears ephemeral UI state only, no project modifications). Note: For maximum client compatibility, pass count as a quoted string (e.g., '5').",

This is purely for explicitness and not required given the maintainer's deliberate decision on the hint semantics.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 79c5ec7 and 9752549.

📒 Files selected for processing (1)
  • Server/src/services/tools/read_console.py
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: msanatan
Repo: CoplayDev/unity-mcp PR: 301
File: docs/CUSTOM_TOOLS.md:54-62
Timestamp: 2025-10-03T22:11:46.002Z
Learning: In Unity MCP, the `description` parameter in the `mcp_for_unity_tool` decorator is technically optional but should always be included as a best practice. Without it, there's a higher chance that MCP clients will not parse the tool correctly. All Unity MCP tools should include the description in the decorator for compatibility.
📚 Learning: 2025-10-03T22:11:46.002Z
Learnt from: msanatan
Repo: CoplayDev/unity-mcp PR: 301
File: docs/CUSTOM_TOOLS.md:54-62
Timestamp: 2025-10-03T22:11:46.002Z
Learning: In Unity MCP, the `description` parameter in the `mcp_for_unity_tool` decorator is technically optional but should always be included as a best practice. Without it, there's a higher chance that MCP clients will not parse the tool correctly. All Unity MCP tools should include the description in the decorator for compatibility.

Applied to files:

  • Server/src/services/tools/read_console.py
🧬 Code graph analysis (1)
Server/src/services/tools/read_console.py (2)
Server/src/transport/unity_transport.py (1)
  • send_with_unity_instance (78-103)
Server/src/transport/legacy/unity_connection.py (1)
  • async_send_command_with_retry (753-785)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Sourcery review
  • GitHub Check: Sourcery review
🔇 Additional comments (1)
Server/src/services/tools/read_console.py (1)

7-8: LGTM!

The ToolAnnotations import is correctly added and necessary for the annotations block below.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants