Commit Graph

46 Commits (c866e0625bc7ce2d48e953020686245a510e2215)

Author SHA1 Message Date
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
Marcus Sanatan f6796e61f7
Autoformat (#297) 2025-09-30 16:25:33 -04:00
dsarno 9d17061452
Add Windows legacy server cleanup for %LOCALAPPDATA%\Programs\UnityMCP\UnityMcpServer (#272)
- Detect and clean up legacy server installations in LocalApplicationData
- Prevents accumulation of old server copies during package updates
- Improves cleanup of Windows-specific legacy installation paths
2025-09-09 10:18:22 -07:00
dsarno 96326ee6a1 Editor: Detect Windows Store Python (PythonSoftwareFoundation) uv.exe in FindUvPath 2025-09-02 14:41:29 -07:00
David Sarno ad5c3112ca MCP: Fix macOS paths and VSCode manual setup
Normalize macOS to Application Support; use AppSupport symlink for Cursor args

Map XDG (~/.local/share, ~/.config) to Application Support

VSCode manual: show mcp.json path; use top-level servers JSON

VSCode macOS path: ~/Library/Application Support/Code/User/mcp.json
2025-08-24 14:18:08 -07:00
David Sarno 01ea2f46ac refactor(installer): revert to lean installer logic from ee23346c; fix macOS path via Application.platform; escape pgrep pattern 2025-08-24 11:47:04 -07:00
David Sarno ce1104e9e7 feat(installer): rewire known configs (EditorPrefs, Cursor mcp.json) to canonical path; then remove legacy if unreferenced 2025-08-24 11:39:01 -07:00
David Sarno 48c1b7a51e fix(installer): use Application.platform for OS detection; add canonical root logs; fallback to RuntimeInformation 2025-08-24 11:31:38 -07:00
David Sarno 742d168b51 sec(installer): escape server path in pgrep pattern to prevent injection/regex issues 2025-08-24 09:46:54 -07:00
David Sarno f21c2cedd5 fix(installer): skip legacy deletion when still referenced in prefs or Cursor config 2025-08-24 09:40:29 -07:00
David Sarno ee23346ca2 feat: installer cleanup, auto-migration, logging normalization 2025-08-23 22:13:47 -07:00
Marcus Sanatan ae13ef41d5
Rename namespace and public facing plugin output from "Unity MCP" to "MCP for Unity" (#225)
* refactor: rename namespace from UnityMcpBridge to MCPForUnity across all files

See thread in #6, we can't use Unity MCP because it violates their trademark.
That name makes us look affiliated. We can use MCP for Unity

* Change package display name, menu item and menu titles

These are front facing so has to change for Unity asset store review

* Misc name changes in logs and comments for better consistency

* chore: update editor window title from 'MCP Editor' to 'MCP for Unity'

* refactor: update branding from UNITY-MCP to MCP-FOR-UNITY across all log messages and warnings

* chore: rename Unity MCP to MCP For Unity across all files and bump version to 2.1.2

* docs: update restore script title to clarify Unity MCP naming

* Fix usage instructions

* chore: update log messages to use MCP For Unity branding instead of UnityMCP

* Add a README inside plugin, required for distributing via the asset store

* docs: update Unity port description and fix typo in troubleshooting section

* Address Rabbit feedback

* Update Editor prefs to use new name

Prevents overlap with other Unity MCPs, happy to revert if it's too much

* refactor: rename server logger and identifier from unity-mcp-server to mcp-for-unity-server

* Standardize casing of renamed project to "MCP for Unity", as it is on the asset store

* Remove unused folder

* refactor: rename Unity MCP to MCP for Unity across codebase

* Update dangling references

* docs: update product name from UnityMCP to MCP for Unity in README

* Update log and comments for new name
2025-08-20 15:59:49 -04:00
David Sarno 80d311ec13 chore(windows): WinGet Links resolution uses ProgramFiles (machine-wide) after LOCALAPPDATA; drop ProgramData; update comment 2025-08-13 19:15:03 -07:00
David Sarno 6e59b8fe8d fix: linux XDG config paths; prefer installed server; robust cursor detection; atomic writes; uv validation; WinGet Links ordering 2025-08-13 18:13:25 -07:00
David Sarno 4e1b905ea0 chore: bump version to 2.1.0; Windows uv resolver improvements; preserve existing uv command; Claude unregister UI fix; .ps1 handling; add generic mcp_source.py 2025-08-13 14:02:19 -07:00
David Sarno 9a9267c128 Windows: prefer WinGet Links uv.exe and preserve existing absolute uv command during config writes 2025-08-13 11:35:31 -07:00
David Sarno efd146ab53 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
David Sarno f6f8b24371 chore(uv): prepend ~/.local/bin and common bins to PATH for 'which uv' in GUI env 2025-08-12 10:48:46 -07:00
David Sarno 8984ab95bc feat: local-only package resolution + Claude CLI resolver; quieter install logs; guarded auto-registration 2025-08-12 08:32:51 -07:00
dsarno b179ce1ed8
Merge branch 'main' into feat/bridge-stability 2025-08-10 11:57:07 -07:00
David Sarno 9da9739751 Package Python server under UnityMcpServer~; remove redundant .meta files; delete old root UnityMcpServer; update editor lookup for tilde path; adjust deploy/restore scripts; remove orphan meta 2025-08-09 12:49:32 -07:00
David Sarno c0de38e1e7 Merge upstream/main: CoplayDev rebrand with bridge stability improvements
This merge combines upstream's organizational rebrand and updates with
our comprehensive bridge stability improvements:

**From Upstream:**
- CoplayDev organizational rebrand (README, LICENSE, documentation)
- Updated logo and deployment scripts
- Python version pinning (.python-version file)

**From Our Branch (Preserved):**
- Comprehensive bridge stability improvements (threading, heartbeat, retries)
- Enhanced debugging and diagnostic features
- Embedded server installation approach (more reliable than git-based)
- Broader Python compatibility (>=3.10 vs >=3.12)
- Advanced port management with per-project persistence
- Auto-setup and connection reliability features
- Robust error handling and recovery mechanisms

**Key Technical Decisions:**
- Used our comprehensive UnityMcpBridge.cs (625 lines vs 473) with all stability features
- Maintained embedded server approach over upstream's git-based installer
- Preserved broader Python compatibility (>=3.10) for better accessibility
- Used our optimized connection settings and retry logic
- Kept our user-centric server installation approach (on-demand vs automatic)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-09 12:05:47 -07:00
David Sarno f24e124c15 MCP: Embedded server reliability and UX\n\n- Embed-first installer: copies embedded server, adds RepairPythonEnvironment() (deletes .venv, runs 'uv sync'); robust uv path discovery; macOS install path -> Application Support\n- UI: Server Status shows Installed(Embedded); Python missing warning with install link; Repair button tooltip; header Show Debug Logs; cleaned layout\n- Python: unpin .python-version; set requires-python >=3.10 in both pyprojects\n- Dev: improved package/dev path resolution 2025-08-08 14:16:25 -07:00
Marcus Sanatan 5d148a7462 chore: update repository URLs and package name to use correct CoplayDev casing and main branch 2025-08-08 15:06:35 -04:00
David Sarno a65f10383a feat(bridge): embed Python server into package and remove Git-based installer
- Switch ServerInstaller to embedded copy-only (no network)
- Simplify Editor UI server status to 'Installed (Embedded)'
- Vendor UnityMcpServer/src into UnityMcpBridge/UnityMcpServer/src for UPM distribution
- Keep bridge recompile robustness (heartbeat + sticky port)
2025-08-08 08:08:30 -07:00
Justin Barnett b2f65f2ffc added public helper methods for project versions 2025-04-09 07:42:43 -04:00
Justin Barnett 99f38e21bd PR prep 2025-04-08 20:55:22 -04:00
Justin Barnett 8c50e01add update update path 2025-04-08 15:23:46 -04:00
Justin Barnett a3f1926338 pass content, not path 2025-04-08 15:19:52 -04:00
Justin Barnett 2f260861df update pyproject.toml path 2025-04-08 15:17:26 -04:00
Justin Barnett 64b771210b update version analysis 2025-04-08 15:13:41 -04:00
Justin Barnett f446b502ee removed logging 2025-04-08 15:02:59 -04:00
Justin Barnett e9bc45c0df updated PyprojectUrl 2025-04-08 14:20:54 -04:00
Justin Barnett d5917bdbec added loging, updated paths 2025-04-08 14:12:30 -04:00
Justin Barnett 3199421586 removed python and uv check during install 2025-04-08 14:03:56 -04:00
Justin Barnett 7b303b5ba3 update pyproject.toml get location 2025-04-08 11:44:12 -04:00
Justin Barnett e4ccf614c5 update server save location, again 2025-04-08 11:41:14 -04:00
Justin Barnett 0aa191c7e3 update pyproject name and save location again 2025-04-08 11:10:01 -04:00
Justin Barnett b8c8910323 update install location 2025-04-08 10:56:05 -04:00
Justin Barnett b36c4576d9 only install UnityMcpServer folder, not whole repo 2025-04-08 10:48:39 -04:00
Justin Barnett 33b6486b70 backslashes for windows 2025-04-08 10:39:14 -04:00
Justin Barnett 2f6d748607 updated server install process 2025-04-08 10:33:14 -04:00
Justin Barnett 99ceb49ac3 update server install process 2025-04-08 09:46:34 -04:00
Justin Barnett 7beaab1fcb updated GitUrl to include branch name 2025-04-08 08:59:26 -04:00
Justin Barnett 8a89f55daf update installer to account for different os 2025-04-08 07:52:44 -04:00
Justin Barnett 61a7cb9e28 added remote install of python server 2025-04-08 07:22:24 -04:00