unity-mcp/UnityMcpBridge/Editor/Helpers
Marcus Sanatan 5488af2c99
Make it easier to add tools (#301)
* Add a decorate that wraps around the `mcp.tool` decorator.

This will allow us to more easily collect tools

* Register tools that's defined in the tools folder

* Update Python tools to use new decorator

* Convert script_apply_edits tool

* Convert last remaining tools with new decorator

* Create an attribute so we can identify tools via Reflection

* Add attribute to all C# tools

* Use reflection to load tools

* Initialize command registry to load tools at startup

* Update tests

* Move Dev docs to docs folder

* Add docs for adding custom tools

* Update function docs for Python decorator

* Add working example of adding a screenshot tool

* docs: update relative links in README files

Updated the relative links in both README-DEV.md and README-DEV-zh.md to use direct filenames instead of paths relative to the docs directory, improving link correctness when files are accessed from the root directory.

* docs: update telemetry documentation path reference

Updated the link to TELEMETRY.md in README.md to point to the new docs/ directory location to ensure users can access the telemetry documentation correctly. Also moved the TELEMETRY.md file to the docs/ directory as part of the documentation restructuring.

* rename CursorHelp.md to docs/CURSOR_HELP.md

Moved the CursorHelp.md file to the docs directory to better organize documentation files and improve project structure.

* docs: update CUSTOM_TOOLS.md with improved tool naming documentation and path corrections

- Clarified that the `name` argument in `@mcp_for_unity_tool` decorator is optional and defaults to the function name
- Added documentation about using all FastMCP `mcp.tool` function decorator options
- Updated class naming documentation to mention snake_case conversion by default
- Corrected Python file path from `tools/screenshot_tool.py` to `UnityMcpServer~/src/tools/screenshot_tool.py`
- Enhanced documentation for tool discovery and usage examples

* docs: restructure development documentation and add custom tools guide

Rearranged the development section in README.md to better organize the documentation flow. Added a dedicated section for "Adding Custom Tools" with a link to the new CUSTOM_TOOLS.md file, and renamed the previous "For Developers" section to "Contributing to the Project" to better reflect its content. This improves discoverability and organization of the development setup documentation.

* docs: update developer documentation and add README links

- Added links to developer READMEs in CUSTOM_TOOLS.md to guide users to the appropriate documentation
- Fixed typo in README-DEV.md ("roote" → "root") for improved clarity
- These changes improve the developer experience by providing better documentation navigation and correcting technical inaccuracies

* feat(tools): enhance tool registration with wrapped function assignment

Updated the tool registration process to properly chain the mcp.tool decorator and telemetry wrapper, ensuring the wrapped function is correctly assigned to tool_info['func'] for proper tool execution and telemetry tracking. This change improves the reliability of tool registration and monitoring.

* Remove AI generated code that was never used...

* feat: Rebuild MCP server installation with embedded source

Refactored the server repair logic to implement a full rebuild of the MCP server installation using the embedded source. The new RebuildMcpServer method now:
- Uses embedded server source instead of attempting repair of existing installation
- Deletes the entire existing server directory before re-copying
- Handles UV process cleanup for the target path
- Simplifies the installation flow by removing the complex Python environment repair logic
- Maintains the same installation behavior but with a cleaner, more reliable rebuild approach

This change improves reliability of server installations by ensuring a clean slate rebuild rather than attempting to repair potentially corrupted environments.

* Add the rebuild server step

* docs: clarify tool description field requirements and client compatibility

* fix: move initialization flag after tool discovery to prevent race conditions

* refactor: remove redundant TryParseVersion overrides in platform detectors

* refactor: remove duplicate UV validation code from platform detectors

* Update UnityMcpBridge/Editor/Tools/CommandRegistry.cs

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* refactor: replace WriteToConfig reflection with direct McpConfigurationHelper call

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2025-10-03 18:53:09 -04:00
..
AssetPathUtility.cs Open and close prefabs in the stage view + create them (#283) 2025-09-26 19:28:56 -04:00
AssetPathUtility.cs.meta Open and close prefabs in the stage view + create them (#283) 2025-09-26 19:28:56 -04:00
CodexConfigHelper.cs Add Codex to autoconfig options (#288) 2025-09-26 18:05:30 -04:00
CodexConfigHelper.cs.meta Add Codex to autoconfig options (#288) 2025-09-26 18:05:30 -04:00
ConfigJsonBuilder.cs Claude‑friendly edit tools + framed transport + live Unity NL test framework (#243) 2025-08-30 09:55:38 -07:00
ConfigJsonBuilder.cs.meta Improve Windsurf MCP Config (#231) 2025-08-24 06:57:11 -04:00
ExecPath.cs Autoformat (#297) 2025-09-30 16:25:33 -04:00
ExecPath.cs.meta fix: Windows define UNITY_EDITOR_WIN; async stdout/stderr in TryRun and RepairPythonEnvironment; use EnvironmentVariables for PATH; prepend Unix PATH only on macOS/Linux; fix duplicate .meta GUIDs 2025-08-12 11:56:46 -07:00
GameObjectSerializer.cs Autoformat (#297) 2025-09-30 16:25:33 -04:00
GameObjectSerializer.cs.meta UnityMCP stability: robust auto-restart on compile/play transitions; stop on domain reload; start/stop locking; per-project sticky ports + brief release wait; Python discovery scans hashed+legacy files and probes; editor window live status refresh. 2025-08-07 15:53:53 -07:00
McpConfigFileHelper.cs Autoformat (#297) 2025-09-30 16:25:33 -04:00
McpConfigFileHelper.cs.meta Add Codex to autoconfig options (#288) 2025-09-26 18:05:30 -04:00
McpConfigurationHelper.cs feat: Unity Asset Store compliance with post-installation dependency setup (#281) 2025-10-03 16:43:40 -04:00
McpConfigurationHelper.cs.meta feat: Unity Asset Store compliance with post-installation dependency setup (#281) 2025-10-03 16:43:40 -04:00
McpLog.cs Autoformat (#297) 2025-09-30 16:25:33 -04:00
McpLog.cs.meta feat: installer cleanup, auto-migration, logging normalization 2025-08-23 22:13:47 -07:00
McpPathResolver.cs feat: Unity Asset Store compliance with post-installation dependency setup (#281) 2025-10-03 16:43:40 -04:00
McpPathResolver.cs.meta feat: Unity Asset Store compliance with post-installation dependency setup (#281) 2025-10-03 16:43:40 -04:00
PackageDetector.cs Autoformat (#297) 2025-09-30 16:25:33 -04:00
PackageDetector.cs.meta Allow the LLMs to read menu items, not just execute them (#263) 2025-09-12 11:19:58 -04:00
PackageInstaller.cs feat: Unity Asset Store compliance with post-installation dependency setup (#281) 2025-10-03 16:43:40 -04:00
PackageInstaller.cs.meta Add meta for PackageInstaller so Unity includes it in package cache 2025-08-07 19:09:52 -07:00
PortManager.cs Autoformat (#297) 2025-09-30 16:25:33 -04:00
PortManager.cs.meta Unity-MCP AutoConnect 2025-07-29 00:17:36 -04:00
Response.cs Autoformat (#297) 2025-09-30 16:25:33 -04:00
Response.cs.meta UnityMCP stability: robust auto-restart on compile/play transitions; stop on domain reload; start/stop locking; per-project sticky ports + brief release wait; Python discovery scans hashed+legacy files and probes; editor window live status refresh. 2025-08-07 15:53:53 -07:00
ServerInstaller.cs Make it easier to add tools (#301) 2025-10-03 18:53:09 -04:00
ServerInstaller.cs.meta UnityMCP stability: robust auto-restart on compile/play transitions; stop on domain reload; start/stop locking; per-project sticky ports + brief release wait; Python discovery scans hashed+legacy files and probes; editor window live status refresh. 2025-08-07 15:53:53 -07:00
ServerPathResolver.cs feat: Unity Asset Store compliance with post-installation dependency setup (#281) 2025-10-03 16:43:40 -04:00
ServerPathResolver.cs.meta fix: Windows define UNITY_EDITOR_WIN; async stdout/stderr in TryRun and RepairPythonEnvironment; use EnvironmentVariables for PATH; prepend Unix PATH only on macOS/Linux; fix duplicate .meta GUIDs 2025-08-12 11:56:46 -07:00
TelemetryHelper.cs Autoformat (#297) 2025-09-30 16:25:33 -04:00
TelemetryHelper.cs.meta added optional telemetry 2025-09-04 12:09:34 -04:00
Vector3Helper.cs Autoformat (#297) 2025-09-30 16:25:33 -04:00
Vector3Helper.cs.meta UnityMCP stability: robust auto-restart on compile/play transitions; stop on domain reload; start/stop locking; per-project sticky ports + brief release wait; Python discovery scans hashed+legacy files and probes; editor window live status refresh. 2025-08-07 15:53:53 -07:00