Commit Graph

659 Commits (8ee97003273c66fa4797c2f1669093a157aab90a)

Author SHA1 Message Date
Marcus Sanatan 50844c20f4 docs: add Unity disclaimer and update package installation steps 2025-10-03 22:22:19 -04:00
GitHub Actions ba1e488f32 chore: bump version to 5.0.0 2025-10-04 01:01:06 +00:00
Marcus Sanatan 9d9652eb4d docs: add v5 migration guide with installation screenshots and steps 2025-10-03 20:56:02 -04:00
Marcus Sanatan e9b1ae44c5
Rename plugin folder to MCPForUnity (#303)
* Copy UnityMcpBridge into a new MCPForUnity folder

This is to close #284

* refactor: rename UnityMcpBridge directory to MCPForUnity in docs

* chore: rename UnityMcpBridge directory to MCPForUnity across workflow files

* chore: rename UnityMcpBridge directory to MCPForUnity across all files

* refactor: update import paths from UnityMcpBridge to MCPForUnity across test files

* fix: update module import paths to use MCPForUnity instead of UnityMcpBridge

* chore: update unity-mcp package path to MCPForUnity directory

* feat: add OneTimeSetUp to initialize CommandRegistry before tests run

Hopefully fix the CI failures

* Apply recent fix to new folder

* Temporarily trigger tests to see if CI works

* Revert "Temporarily trigger tests to see if CI works"

It works!

This reverts commit 8c6eaaad07545cef047769f2c52fe506545a8161.
2025-10-03 20:23:28 -04:00
dsarno ff736012fa
Fix read_console includeStacktrace parameter behavior (#304)
The includeStacktrace parameter was working backwards - when false,
it would return the full message with embedded stack traces, and when
true, it would extract the stack trace but the logic was inverted.

Changes:
- Always extract the first line as the message text
- Only populate stackTrace field when includeStacktrace is true
- Ensures clean, summary-only messages when includeStacktrace is false
- Properly separates stack traces into their own field when requested

This matches the expected Unity console behavior where the summary
is shown by default, and stack traces are only shown when expanded.
2025-10-03 17:08:39 -07:00
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
Justin Barnett 7c23f245ab
feat: Unity Asset Store compliance with post-installation dependency setup (#281)
* feat: implement Unity Asset Store compliance with post-installation dependency setup

- Remove bundled Python dependencies from Unity package
- Add comprehensive 6-step setup wizard with auto-trigger on first import
- Implement cross-platform dependency detection (Windows, macOS, Linux)
- Add integrated MCP client configuration within setup process
- Create production-ready menu structure with clean UI/UX
- Ensure complete end-to-end setup requiring no additional configuration
- Add comprehensive error handling and recovery mechanisms

This implementation ensures Asset Store compliance while maintaining full
functionality through guided user setup. Users are left 100% ready to use
MCP after completing the setup wizard.

* refactor: improve Asset Store compliance implementation with production-ready setup

- Remove automatic installation attempts on package import
- Always show setup wizard on package install/reinstall
- Integrate MCP client configuration as part of setup wizard process
- Ensure MCP client config window remains accessible via menu
- Remove testing components for production readiness
- Replace automatic installation with manual guidance only
- Add complete 4-step setup flow: Welcome → Dependencies → Installation Guide → Client Configuration → Complete
- Improve user experience with clear instructions and accessible client management

* feat: add comprehensive dependency requirement warnings

- Add critical warnings throughout setup wizard that package cannot function without dependencies
- Update package.json description to clearly state manual dependency installation requirement
- Prevent setup completion if dependencies are missing
- Enhance skip setup warning to emphasize package will be non-functional
- Add error messages explaining consequences of missing dependencies
- Update menu item to indicate setup wizard is required
- Ensure users understand package is completely non-functional without proper dependency installation

* refactor: simplify setup wizard for production

BREAKING: Reduced setup wizard from 5 steps to 3 streamlined steps:
- Step 1: Setup (welcome + dependency check + installation guide)
- Step 2: Configure (client configuration with direct access to full settings)
- Step 3: Complete (final status and quick access to resources)

Simplifications:
- Consolidated UI components with DRY helper methods (DrawSectionTitle, DrawSuccessStatus, DrawErrorStatus)
- Simplified dependency status display with clean icons and essential info
- Removed complex state management - using simple EditorPrefs instead
- Removed unused InstallationOrchestrator and SetupState classes
- Streamlined client configuration to direct users to full settings window
- Simplified navigation with back/skip/next buttons
- Reduced code complexity while maintaining solid principles

Results:
- 40% less code while maintaining all functionality
- Cleaner, more intuitive user flow
- Faster setup process with fewer clicks
- Production-ready simplicity
- Easier maintenance and debugging

* fix: add missing using statement for DependencyCheckResult

Add missing 'using MCPForUnity.Editor.Dependencies.Models;' to resolve
DependencyCheckResult type reference in SetupWizard.cs

* refactor: optimize dependency checks and remove dead code

* fix: remove unused DrawInstallationProgressStep method

Removes leftover method that references deleted _isInstalling and _installationStatus fields, fixing compilation errors.

* feat: improve setup wizard UX and add real client configuration

1. Remove dependency mentions from package.json description
2. Only show dependency warnings when dependencies are actually missing
3. Add actual MCP client configuration functionality within the wizard:
   - Client selection dropdown
   - Individual client configuration
   - Claude Code registration/unregistration
   - Batch configuration for all clients
   - Manual setup instructions
   - Real configuration file writing

Users can now complete full setup including client configuration without leaving the wizard.

* refactor: improve menu text and client restart tip

- Remove '(Required)' from Setup Wizard menu item for cleaner appearance
- Update tip to reflect that most AI clients auto-detect configuration changes

* refactor: simplify client restart tip message

* fix: add missing using statement for MCPForUnityEditorWindow

Add 'using MCPForUnity.Editor.Windows;' to resolve unresolved symbol error for MCPForUnityEditorWindow in SetupWizard.cs

* Format code

* Remove unused folders

* Same for validators

* Same for Setup...

* feat: add setup wizard persistence to avoid showing on subsequent imports

* fix: update Python version check to support Python 4+ across all platform detectors

* refactor: extract common platform detection logic into PlatformDetectorBase class

* feat: add configuration helpers for MCP client setup with sophisticated path resolution

* fix: add missing override keyword to DetectPython method in platform detectors

* fix: update menu item labels for consistent capitalization and naming

* fix: standardize "MCP For Unity" capitalization in window titles and dialogs

* refactor: update package ID from justinpbarnett to coplaydev across codebase

* refactor: remove unused validation and configuration helper methods

* refactor: remove unused warnOnLegacyPackageId parameter from TryFindEmbeddedServerSource

---------

Co-authored-by: Claude <claude@anthropic.com>
Co-authored-by: Marcus Sanatan <msanatan@gmail.com>
2025-10-03 16:43:40 -04:00
Marcus Sanatan f6796e61f7
Autoformat (#297) 2025-09-30 16:25:33 -04:00
GitHub Actions 47ec46ce93 chore: bump version to 4.1.1 2025-09-30 03:48:44 +00:00
dsarno 10d4e3bd4a
Merge pull request #296 from dsarno/managegameobject-fix
fix: add parameter validation to manage_gameobject tool
2025-09-29 20:48:02 -07:00
David Sarno a435973f78 Add get_component action to manage_gameobject
Adds a new 'get_component' action that retrieves a single component's
serialized data instead of all components, improving efficiency and
avoiding token limits when only specific component data is needed.
2025-09-29 20:33:58 -07:00
David Sarno 1ad8c6e504 resolve merge conflicts from main 2025-09-29 20:15:56 -07:00
David Sarno c38fc330d2 fix: reject 'name' parameter for find action in all cases
- Simplify validation to reject 'name' parameter whenever present for find action
- Remove ambiguity when both 'name' and 'search_term' are provided
- Update error message to clarify that 'name' should be removed
2025-09-29 20:15:56 -07:00
David Sarno d5292567a3 fix: add parameter validation to manage_gameobject tool
- Prevent silent failures when using 'name' instead of 'search_term' for find action
- Add clear error messages guiding users to correct parameter usage
- Validate that 'search_term' is only used with 'find' action
- Update parameter annotations to clarify when each parameter should be used
2025-09-29 20:15:56 -07:00
dsarno bce6afaf24
Merge branch 'CoplayDev:main' into main 2025-09-29 20:01:54 -07:00
GitHub Actions 048b1252de chore: bump version to 4.1.0 2025-09-27 17:53:28 +00:00
Marcus Sanatan 5acf10769e
Standardize how we define MCP tools (#292)
* refactor: migrate command routing to use CommandRegistry lookup instead of switch statement

* style: improve code formatting and indentation consistency

* refactor: clean up imports and type hints across tool modules

* Revert "feat: Implement Asset Store Compliance for Unity MCP Bridge"

This reverts commit 2fca7fc3da.

* Revert "feat(asset-store): implement post-installation prompt system for Asset Store compliance"

This reverts commit ab25a71bc5.

* chore: upgrade mcp[cli] dependency from 1.4.1 to 1.15.0

* style: fix formatting and whitespace in Python server files

* Remove description, probably a Python versionn change

* feat: add type hints and parameter descriptions to Unity MCP tools

* docs: improve shader management tool parameter descriptions and types

* refactor: add type annotations and improve documentation for script management tools

* refactor: improve type annotations and documentation in manage_scene tool

* refactor: add type annotations and improve parameter descriptions across MCP tools

* feat: add explicit name parameters to all MCP tool decorators

* refactor: remove unused Unity connection instance in manage_asset_tools

* chore: update type hints in manage_editor function parameters for better clarity

* feat: make name and path parameters optional for scene management operations

* refactor: remove unused get_unity_connection import from manage_asset.py

* chore: rename Operation parameter annotation to Operations for consistency

* feat: add logging to MCP clients for tool actions across MCP server components

* chore: add FastMCP type hint to register_all_tools parameter

* style: reformat docstring in apply_text_edits tool to use multiline string syntax

* refactor: update type hints from Dict/List/Tuple/Optional to modern Python syntax

* refactor: clean up imports and add type annotations to script editing tools

* refactor: update type hints to use | None syntax for optional parameters

* Minor fixes

* docs: improve tool descriptions with clearer action explanations

* refactor: remove legacy update action migration code from manage_script.py

* style: replace em dashes with regular hyphens in tool descriptions [skip ci]

* refactor: convert manage_script_capabilities docstring to multiline format [skip ci]
2025-09-27 13:53:10 -04:00
Marcus Sanatan af4ddf1dd6 Revert "chore: bump version to 4.1.0"
This reverts commit e76a7565e8.
2025-09-27 13:51:27 -04:00
GitHub Actions e76a7565e8 chore: bump version to 4.1.0 2025-09-27 17:50:17 +00:00
Marcus Sanatan f50acf46b3
Revert asset store changes (#291)
* Revert "feat: Implement Asset Store Compliance for Unity MCP Bridge"

This reverts commit 2fca7fc3da.

* Revert "feat(asset-store): implement post-installation prompt system for Asset Store compliance"

This reverts commit ab25a71bc5.
2025-09-26 20:36:50 -04:00
GitHub Actions e3cc99c3ab chore: bump version to 4.0.0 2025-09-26 23:32:09 +00:00
Marcus Sanatan ac4eae926e
Open and close prefabs in the stage view + create them (#283)
* refactor: remove unused UnityEngine references from menu item classes

* Add new tools to manage a prefab, particularly, making them staged.

This might be enough, but it's possible we may have to extract some logic from ManageGameObject

* feat: add AssetPathUtility for asset path normalization and update references in ManageAsset and ManagePrefabs

* feat: add prefab management tools and register them with the MCP server

* feat: update prefab management commands to use 'prefabPath' and add 'create_from_gameobject' action

* fix: update parameter references to 'prefabPath' in ManagePrefabs and manage_prefabs tools

* fix: clarify error message for missing 'prefabPath' in create_from_gameobject command

* fix: ensure pull request triggers for unity tests workflow

* Revert "fix: ensure pull request triggers for unity tests workflow"

This reverts commit 10bfe54b5b7f3c449852b1bf1bb72f498289a1a0.

* Remove delayed execution of executing menu item, fixing #279
This brings the Unity window into focus but that seems to be a better UX for devs.
Also streamline manage_menu_item tool info, as FastMCP recommends

* docs: clarify menu item tool description with guidance to use list action first

* feat: add version update for server_version.txt in bump-version workflow

* fix: simplify error message for failed menu item execution
2025-09-26 19:28:56 -04:00
Marcus Sanatan 549ac1eb0c
Add Codex to autoconfig options (#288)
* feat: add Codex CLI client support with config.toml handling

* feat: add config helpers for managing Codex and MCP server configurations

* feat: add TOML array parsing support for multi-line and trailing comma formats

* fix: handle TOML inline comments in section headers during parsing

* fix: strip TOML comments before processing section headers

* fix: improve JSON parsing to handle escaped single quotes in config strings

* Use Tommy for TOML parsing

It's a single file and OSS, easy to integrate into Unity

* fix: patched Tommy’s literal-string handling so doubled single quotes inside literal strings are treated as embedded apostrophes instead of prematurely ending the value

* Don't overwrite MCP configs while testing

Seeing random JSON in my codex config was pretty annoying

* PR Feedback

* Keep Tommy compatible with Unity 2021

* Re-include Tommy's license

Probably a good habit to keep all 3rd party licenses and copyrights, even if they're also MIT licenses
2025-09-26 18:05:30 -04:00
许兴逸 da91f256a2
Replace command dispatcher with CommandRegistry, allow to add custom command handlers. (#261)
* Replace hard coded command dispatcher to command registry

* Bug fixed.

* bug fixed.

* bug fixed.

* Bug fixed.

* Fix tests.
2025-09-26 18:05:17 -04:00
Shutong Wu b57a3b8500
Change package requisite for Code Validation
Updated package installation instructions for NuGet to avoid compilation issue.
2025-09-24 00:24:01 -04:00
Shutong Wu 91849c7aa4 1 2025-09-23 14:45:26 -04:00
Shutong Wu df919e4812 Add Language: zh 中文 2025-09-23 14:41:29 -04:00
Justin Barnett 2fca7fc3da feat: Implement Asset Store Compliance for Unity MCP Bridge 2025-09-23 07:06:29 -04:00
Justin Barnett ab25a71bc5 feat(asset-store): implement post-installation prompt system for Asset Store compliance
Add comprehensive dependency detection system with cross-platform support:
- DependencyManager: Main orchestrator for dependency validation
- SetupWizard: Auto-trigger logic with InitializeOnLoad
- SetupWizardWindow: Complete EditorWindow implementation
- Platform detectors: Windows, macOS, Linux specific detection
- InstallationOrchestrator: Guided installation workflow

Asset Store compliance features:
- No bundled Python interpreter or UV package manager
- User-guided installation process with platform-specific instructions
- Clean package structure without large binary dependencies
- Fallback modes for incomplete installations
- Clear error messages with actionable guidance

Integration:
- Maintains backward compatibility with existing functionality
- Integrates with existing ServerInstaller and MCP infrastructure
- Adds menu items for manual setup wizard access and dependency checking
- Comprehensive error handling and user guidance
2025-09-23 06:51:48 -04:00
Alex Bagnolini 6e72b33309
Specify version for Microsoft.CodeAnalysis.CSharp package (#278) 2025-09-19 09:29:37 -04:00
Shutong Wu 94ad8dea50
Update Windows installation command for Astral UV
Current Windows command does not work on some machines such like mine. Copy and paste the command from Astral website to ensure the installation process go smoothly.
2025-09-17 23:50:15 -04:00
Jos Van der westhuizen 0c7945b36a add github repo stats 2025-09-14 11:30:24 -07:00
Jos Van der westhuizen 80b51f3e6a change telemetry endpoint to prod 2025-09-14 11:22:17 -07:00
David Sarno a940741bf1 CI: revert unity-tests.yml to upstream/main version 2025-09-12 11:33:53 -07:00
David Sarno 692d7199cb CI: Unity tests use serial/license again (restore UNITY_LICENSE) 2025-09-12 11:12:15 -07:00
David Sarno 8ee1f50001 CI: Unity tests use EBL only (drop UNITY_LICENSE) 2025-09-12 11:07:44 -07:00
David Sarno ee5db9285e CI: update unity-tests workflow 2025-09-12 11:03:18 -07:00
Marcus Sanatan b5e0446348
Allow the LLMs to read menu items, not just execute them (#263)
* Move the current test to a Tools folder

* feat: add env object and disabled flag handling for MCP client configuration

* Format manual config specially for Windsurf and Kiro

* refactor: extract config JSON building logic into dedicated ConfigJsonBuilder class

* refactor: extract unity node population logic into centralized helper method

* refactor: only add env property to config for Windsurf and Kiro clients

If it ain't broke with the other clients, don't fix...

* fix: write UTF-8 without BOM encoding for config files to avoid Windows compatibility issues

* fix: enforce UTF-8 encoding without BOM when writing files to disk

* refactor: replace execute_menu_item with enhanced manage_menu_item tool supporting list/exists/refresh

* Update meta files for older Unity versions

* test: add unit tests for menu item management and execution

* feat: add tips for paths, script compilation, and menu item usage in asset creation strategy

* Use McpLog functionality instead of Unity's Debug

* Add telemetry

* Annotate parameters

More info to LLMs + better validation

* Remove the refresh command

It's only ever useful in the context of listing menu items

* Updated meta files since running in Unity 2021

* Slightly better README

* fix: rename server-version.txt to server_version.txt and update menu item description
2025-09-12 11:19:58 -04:00
GitHub Actions 2a992117e2 chore: bump version to 3.4.0 2025-09-10 20:03:48 +00:00
dsarno 23fbdc81e3 chore(server): bump server_version.txt to 3.3.2 2025-09-10 13:03:01 -07:00
dsarno fe962114b9
Merge pull request #264 from CoplayDev/feat/telemetry
Added optional telemetry
2025-09-10 13:00:01 -07:00
dsarno 283597dc24 fix(startup): capture exception message before deferred telemetry lambda 2025-09-10 12:58:09 -07:00
dsarno 33979d348b telemetry: use Cloud Run default, reject localhost overrides, add startup diagnostics, and normalize logging
- config: point telemetry_endpoint to Cloud Run default

- telemetry: log effective endpoint/timeout; reject localhost endpoints

- server: telemetry logger at normal level with rotating file; default timeout=5s when unset
2025-09-10 11:57:43 -07:00
David Sarno 9b5488dcaf telemetry_decorator: guard record_tool_usage and milestone emits (sync/async) 2025-09-10 09:38:53 -07:00
David Sarno 9f7308b4c2 mcp-unity: telemetry fire-and-forget; safer sender reg; defer startup/conn telemetry; writer IO logs; manage_scene tolerant params; test worker wake 2025-09-10 09:24:09 -07:00
David Sarno 89714d022c telemetry: record sub_action for tool executions; decorator extracts 'action'; add tests for keyword/positional extraction 2025-09-10 08:52:38 -07:00
David Sarno 2fd74f5dab manage_scene: tolerant params + optional buildIndex; add writer IO logs; keep direct write path 2025-09-10 08:23:25 -07:00
David Sarno 397ba32a99 telemetry: fire-and-forget queue; remove context propagation; reduce timeouts; fix milestone lock reentrancy 2025-09-10 07:50:05 -07:00
David Sarno 46df7250b5 attempted ManageScene debugging for hang 2025-09-09 19:26:17 -07:00
David Sarno c1bde804d4 telemetry: main-thread routing + timeout for manage_scene; stderr + rotating file logs; Cloud Run endpoint in config; minor robustness in scene tool 2025-09-09 18:46:42 -07:00