server instruction cleanup (#345)

* clean up unused prompt and add server instructions

* simplify claude code instructions with global installation
main
Jos van der Westhuizen 2025-10-23 22:01:26 -07:00 committed by GitHub
parent bbf6cacfe2
commit dbda5ea46e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 26 deletions

View File

@ -157,7 +157,26 @@ async def server_lifespan(server: FastMCP) -> AsyncIterator[Dict[str, Any]]:
# Initialize MCP server
mcp = FastMCP(
name="mcp-for-unity-server",
lifespan=server_lifespan
lifespan=server_lifespan,
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
"""
)
# Register all tools
@ -167,28 +186,6 @@ register_all_tools(mcp)
register_all_resources(mcp)
@mcp.prompt()
def asset_creation_strategy() -> str:
"""Guide for discovering and using MCP for Unity tools effectively."""
return (
"Available MCP for Unity Server Tools:\n\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"
)
def main():
"""Entry point for uvx and console scripts."""
mcp.run(transport='stdio')

View File

@ -171,18 +171,17 @@ If Auto-Setup fails or you use a different client:
**Claude Code**
If you're using Claude Code, you can register the MCP server using the below commands:
🚨**make sure to run these from your Unity project's home directory**🚨
**macOS:**
```bash
claude mcp add UnityMCP -- uv --directory /Users/USERNAME/Library/AppSupport/UnityMCP/UnityMcpServer/src run server.py
claude mcp add --scope user UnityMCP -- uv --directory /Users/USERNAME/Library/AppSupport/UnityMCP/UnityMcpServer/src run server.py
```
**Windows:**
```bash
claude mcp add UnityMCP -- "C:/Users/USERNAME/AppData/Local/Microsoft/WinGet/Links/uv.exe" --directory "C:/Users/USERNAME/AppData/Local/UnityMCP/UnityMcpServer/src" run server.py
claude mcp add --scope user UnityMCP -- "C:/Users/USERNAME/AppData/Local/Microsoft/WinGet/Links/uv.exe" --directory "C:/Users/USERNAME/AppData/Local/UnityMCP/UnityMcpServer/src" run server.py
```
**VSCode (all OS)**