Skip to content

Conversation

@JosvanderWesthuizen
Copy link
Contributor

@JosvanderWesthuizen JosvanderWesthuizen commented Oct 24, 2025

image

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

    • Updated CLI configuration commands for macOS and Windows to use user-scoped settings instead of project-scoped configuration.
  • Refactor

    • Reorganized internal tool guidance implementation for improved maintainability.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 24, 2025

Walkthrough

The 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

Cohort / File(s) Summary
Server implementation
MCPForUnity/UnityMcpServer~/src/server.py
Moved tool instructions into FastMCP constructor's instructions parameter; removed asset_creation_strategy() prompt function and its decorator
Documentation updates
README.md
Updated macOS and Windows Claude Code client commands to include --scope user flag, changing configuration scope from project to user level

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • #212: Updates Claude Code client configuration commands in README, modifying the same macOS and Windows command snippets and configuration scope settings.

Poem

🐰 Instructions hopped from function to home,
Nested within the constructor's warm dome,
User-scoped commands now take the lead,
Config consolidated—exactly what we need! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title Check ❓ Inconclusive The title "server instruction cleanup" is related to the changeset since it does reference the main change area (server instructions), but the word "cleanup" is a generic term that lacks specificity. While the PR does involve consolidating how instructions are provided in the server (moving from a prompt function to the FastMCP initialization parameter and removing the unused asset_creation_strategy() function), the title doesn't clearly convey these specific changes to someone scanning the commit history. The term "cleanup" alone could describe various types of refactoring, leaving the reader uncertain about the exact nature of the modifications without examining the full changeset. Consider making the title more specific and descriptive, such as "Move server instructions to FastMCP initialization parameter" or "Replace asset_creation_strategy prompt with FastMCP instructions parameter". This would clearly communicate the key refactoring without requiring additional context, making it easier for team members to understand the primary change at a glance.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch jos/server-instructions

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

@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: 1

🧹 Nitpick comments (1)
MCPForUnity/UnityMcpServer~/src/server.py (1)

161-179: Consider natural line breaks in triple-quoted strings.

The instructions use explicit \n escape 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

📥 Commits

Reviewing files that changed from the base of the PR and between a0287af and 75d90ad.

📒 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 user to 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

Comment on lines +161 to +179
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
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 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 2

Length 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 -80

Length 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.py

Length 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 -40

Length 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 -35

Length 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 -l

Length 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().

@msanatan msanatan merged commit dbda5ea into main Oct 24, 2025
1 check passed
@msanatan msanatan deleted the jos/server-instructions branch October 24, 2025 05:01
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