- 
                Notifications
    You must be signed in to change notification settings 
- Fork 485
server instruction cleanup #345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| WalkthroughThe PR consolidates MCP tool guidance by moving instructions from a separate prompt function into the FastMCP constructor parameter. Simultaneously, the README updates Claude Code client configuration commands to use user-scoped setup instead of project-scoped form for both macOS and Windows platforms. Changes
 Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
 Poem
 Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
 ✅ Passed checks (2 passed)
 ✨ Finishing touches
 🧪 Generate unit tests (beta)
 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. Comment  | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
MCPForUnity/UnityMcpServer~/src/server.py (1)
161-179: Consider natural line breaks in triple-quoted strings.The instructions use explicit
\nescape sequences within a triple-quoted string. While this works correctly, Python triple-quoted strings naturally preserve line breaks, so you could simplify the formatting:- instructions=""" -This server provides tools to interact with the Unity Game Engine Editor.\n\n -Available tools:\n -- `manage_editor`: Controls editor state and queries info.\n + instructions=""" +This server provides tools to interact with the Unity Game Engine Editor. + +Available tools: +- `manage_editor`: Controls editor state and queries info. ... -""" + """This makes the string more readable in the source code without changing runtime behavior.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
- MCPForUnity/UnityMcpServer~/src/server.py(1 hunks)
- README.md(1 hunks)
🔇 Additional comments (1)
README.md (1)
169-169: LGTM! User-scoped configuration is appropriate.The addition of
--scope userto the Claude Code MCP registration commands makes the server available across all user projects rather than being project-specific. This is a sensible default for a Unity integration tool.Also applies to: 175-175
| instructions=""" | ||
| This server provides tools to interact with the Unity Game Engine Editor.\n\n | ||
| Available tools:\n | ||
| - `manage_editor`: Controls editor state and queries info.\n | ||
| - `execute_menu_item`: Executes, lists and checks for the existence of Unity Editor menu items.\n | ||
| - `read_console`: Reads or clears Unity console messages, with filtering options.\n | ||
| - `manage_scene`: Manages scenes.\n | ||
| - `manage_gameobject`: Manages GameObjects in the scene.\n | ||
| - `manage_script`: Manages C# script files.\n | ||
| - `manage_asset`: Manages prefabs and assets.\n | ||
| - `manage_shader`: Manages shaders.\n\n | ||
| - Tips:\n | ||
| - Create prefabs for reusable GameObjects.\n | ||
| - Always include a camera and main light in your scenes.\n | ||
| - Unless specified otherwise, paths are relative to the project's `Assets/` folder.\n | ||
| - After creating or modifying scripts with `manage_script`, allow Unity to recompile; use `read_console` to check for compile errors.\n | ||
| - Use `execute_menu_item` for interacting with Unity systems and third party tools like a user would.\n | ||
| """ | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Incomplete tool list in instructions.
The instructions document 8 tools but the README (lines 41-51) lists 11 tools. The following tools are missing from the instructions:
- apply_text_edits: Precise text edits with precondition hashes and atomic multi-edit batches
- script_apply_edits: Structured C# method/class edits (insert/replace/delete) with safer boundaries
- validate_script: Fast validation (basic/standard) to catch syntax/structure issues before/after writes
These appear to be significant tools for script editing workflows. Please verify whether these tools are registered and add them to the instructions.
Run the following script to confirm which tools are actually registered:
🏁 Script executed:
#!/bin/bash
# Description: Find all tool registrations in the codebase
# Search for tool registration patterns
rg -n "def (apply_text_edits|script_apply_edits|validate_script)" -A 2Length of output: 2013
🏁 Script executed:
#!/bin/bash
# Description: Find tool registration/decoration patterns
# Search for how tools are decorated and registered
rg -n "@.*tool|@tool|register.*tool" MCPForUnity/UnityMcpServer~/src/ -B 1 -A 1 | head -50
echo "---"
# Check if the three tools use the same registration pattern as others
rg -n "^def (apply_text_edits|script_apply_edits|validate_script|manage_editor|execute_menu_item)" -B 3 | head -80Length of output: 3014
🏁 Script executed:
#!/bin/bash
# Description: Check server.py context and how tools are actually registered
# Look at the server.py around lines 160-180 to see full context
cat git/MCPForUnity/UnityMcpServer~/src/server.py | sed -n '155,185p'
echo "---"
# Check if tools are auto-discovered or manually registered
rg -n "apply_text_edits|script_apply_edits|validate_script" git/MCPForUnity/UnityMcpServer~/src/server.pyLength of output: 167
🏁 Script executed:
#!/bin/bash
# Description: Locate and read server.py with correct paths
# Find server.py files
fd -type f -name "server.py" | head -5
echo "---"
# Read the first found server.py, focusing on lines 155-185
fd -type f -name "server.py" -exec sed -n '155,185p' {} \; | head -40Length of output: 345
🏁 Script executed:
#!/bin/bash
# Description: Find and read server.py with correct syntax
# Find server.py files
find . -name "server.py" 2>/dev/null | head -5
echo "---"
# Read the MCPForUnity server.py around lines 155-185
find . -path "*MCPForUnity*server.py" -exec head -185 {} \; 2>/dev/null | tail -35Length of output: 1483
🏁 Script executed:
#!/bin/bash
# Description: Verify register_all_tools includes all decorated tools
# Find register_all_tools definition
rg -n "def register_all_tools" -A 20
echo "---"
# Also check how many @mcp_for_unity_tool decorations exist
rg -n "@mcp_for_unity_tool" | wc -l
rg -n "@mcp_for_unity_tool" | cut -d: -f1 | sort -u | wc -lLength of output: 3721
Incomplete tool list in instructions—add missing three tools.
The instructions parameter (lines 161-179) lists 8 tools, but the codebase registers 11 total tools via register_all_tools(). The three missing tools are:
- apply_text_edits: Precise text edits with precondition hashes and atomic multi-edit batches
- script_apply_edits: Structured C# method/class edits (insert/replace/delete) with safer boundaries
- validate_script: Fast validation (basic/standard) to catch syntax/structure issues before/after writes
Add these three tools to the instructions list so the server's documented capabilities match the actual available tools.
🤖 Prompt for AI Agents
In MCPForUnity/UnityMcpServer~/src/server.py around lines 161 to 179, the
instructions string omits three registered tools; update the multi-line
instructions text to include the missing tools `apply_text_edits`,
`script_apply_edits`, and `validate_script` (with short phrases matching the
style used for other tools, e.g., `- apply_text_edits: Precise text edits with
precondition hashes and atomic multi-edit batches.`, `- script_apply_edits:
Structured C# method/class edits (insert/replace/delete) with safer
boundaries.`, `- validate_script: Fast validation (basic/standard) to catch
syntax/structure issues before/after writes.`) so the documented tool list
matches register_all_tools().
I didn't see any downstream use cases for the @mcp.prompt that was registered.
Made use of the FastMCP instructions field instead.
Note, not all MCP hosts actually read the instructions. E.g. Cline does not, but Claude Code does.
Summary by CodeRabbit
Documentation
Refactor