Commit Graph

7 Commits (350337813b9dc1cf1032ac2a991af669bdce4db9)

Author SHA1 Message Date
Marcus Sanatan 85cc93f33c
Allow users to easily add tools in the Asset folder (#324)
* Fix issue #308: Find py files in MCPForUnityTools and version.txt

This allows for auto finding new tools. A good dir on a custom tool would look like this:
CustomTool/
├── CustomTool.MCPEnabler.asmdef
├── CustomTool.MCPEnabler.asmdef.meta
├── ExternalAssetToolFunction.cs
├── ExternalAssetToolFunction.cs.meta
├── external_asset_tool_function.py
├── external_asset_tool_function.py.meta
├── version.txt
└── version.txt.meta

CS files are left in the tools folder. The asmdef is recommended to allow for dependency on MCPForUnity when MCP For Unity is installed:

asmdef example
{
    "name": "CustomTool.MCPEnabler",
    "rootNamespace": "MCPForUnity.Editor.Tools",
    "references": [
        "CustomTool",
        "MCPForUnity.Editor"
    ],
    "includePlatforms": [
        "Editor"
    ],
    "excludePlatforms": [],
    "allowUnsafeCode": false,
    "overrideReferences": false,
    "precompiledReferences": [],
    "autoReferenced": true,
    "defineConstraints": [],
    "versionDefines": [],
    "noEngineReferences": false
}

* Follow-up: address CodeRabbit feedback for #308 (<GetToolsFolderIdentifier was duplicated>)

* Follow-up: address CodeRabbit feedback for #308 – centralize GetToolsFolderIdentifier, fix tools copy dir, and limit scan scope

* Fixing so the MCP don't removes _skipDirs e.g. __pycache__

* skip empty folders with no py files

* Rabbit: "Fix identifier collision between different package roots."

* Update MCPForUnity/Editor/Helpers/ServerInstaller.cs

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

* Rabbbit: Cleanup may delete server’s built-in tool subfolders — restrict to managed names.

* Fixed minor + missed onadding rabit change

* Revert "Fixed minor + missed onadding rabit change"

This reverts commit 571ca8c5de3d07da3791dad558677909a07e886d.

* refactor: remove Unity project tools copying and version tracking functionality

* refactor: consolidate module discovery logic into shared utility function

* Remove unused imports

* feat: add Python tool registry and sync system for MCP server integration

* feat: add auto-sync processor for Python tools with Unity editor integration

* feat: add menu item to reimport all Python files in project

Good to give users a manual option

* Fix infinite loop error

Don't react to PythonToolAsset changes - it only needs to react to Python file changes.
And we also batch asset edits to minimise the DB refreshes

* refactor: move Python tool sync menu items under Window/MCP For Unity/Tool Sync

* Update docs

* Remove duplicate header

* feat: add OnValidate handler to sync Python tools when asset is modified

This fixes the issue with deletions in the asset, now file removals are synced

* test: add unit tests for Python tools asset and sync services

* Update MCPForUnity/Editor/Helpers/PythonToolSyncProcessor.cs

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

* style: remove trailing whitespace from Python tool sync files

* test: remove incomplete unit tests from ToolSyncServiceTests

* perf: optimize Python file reimport by using AssetDatabase.FindAssets instead of GetAllAssetPaths

---------

Co-authored-by: Johan Holtby <72528418+JohanHoltby@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2025-10-18 00:18:25 -04:00
GitHub Actions 3d82cb26b0 chore: bump version to 6.1.0 2025-10-13 15:27:36 +00:00
Marcus Sanatan f2c57ca91e
Add testing and move menu items to resources (#316)
* deps: add tomli>=2.3.0 dependency to UnityMcpServer package

* feat: dynamically fetch package version from pyproject.toml for telemetry

* Add pydantic

* feat: add resource registry for MCP resource auto-discovery

* feat: add telemetry decorator for tracking MCP resource usage

* feat: add auto-discovery and registration system for MCP resources

* feat: add resource registration to MCP server initialization

* feat: add MCPResponse model class for standardized API responses

* refactor: replace Debug.Log calls with McpLog wrapper for consistent logging

* feat: add test discovery endpoints for Unity Test Framework integration

We haven't connected them as yet, still thinking about how to do this neatly

* Fix server setup

* refactor: reduce log verbosity by changing individual resource/tool registration logs to debug level

* chore: bump mcp[cli] dependency from 1.15.0 to 1.17.0

* refactor: remove Context parameter and add uri keyword argument in resource decorator

The Context parameter doesn't work on our version of FastMCP

* chore: upgrade Python base image to 3.13 and simplify Dockerfile setup

* fix: apply telemetry decorator before mcp.tool to ensure proper wrapping order

* fix: swap order of telemetry and resource decorators to properly wrap handlers

* fix: update log prefixes for consistency in logging methods

* Fix compile errors

* feat: extend command registry to support both tools and resources

* Run get tests as a coroutine because it doesn't return results immediately

This works but it spams logs like crazy, maybe there's a better/simpler way

* refactor: migrate from coroutines to async/await for test retrieval and command execution

* feat: add optional error field to MCPResponse model

* Increased timeout because loading tests can take some time

* Make message optional so error responses that only have success and error don't cause Pydantic errors

* Set max_retries to 5

This connection module needs a lookover. The retries should be an exponential backoff and we could structure why it's failing so much

* Use pydantic model to structure the error output

* fix: initialize data field in GetTestsResponse to avoid potential errors

* Don't return path parameter

* feat: add Unity test runner execution with structured results and Python bindings

* refactor: simplify GetTests by removing mode filtering and related parsing logic

* refactor: move test runner functionality into dedicated service interface

* feat: add resource retrieval telemetry tracking with new record type and helper function

* fix: convert tool functions to async and await ctx.info calls

* refactor: reorganize menu item functionality into separate execute and get commands

An MCP resource for retrieval, and a simple command to execute. Because it's a resource, it's easier for the user to see what's in the menu items

* refactor: rename manage_menu_item to execute_menu_item and update tool examples to use async/await

We'll eventually put a section for resources

* Revert "fix: convert tool functions to async and await ctx.info calls"

This reverts commit 012ea6b7439bd1f2593864d98d03d9d95d7bdd03.

* fix: replace tomllib with tomli for Python 3.10 compatibility in telemetry module

* Remove confusing comment

* refactor: improve error handling and simplify test retrieval logic in GetTests commands

* No cache by default

* docs: remove redundant comment for HandleCommand method in ExecuteMenuItem
2025-10-13 11:16:43 -04:00
Marcus Sanatan 3a9ec4f1a6
docs: replace "Unity MCP" with "MCP for Unity" in all text strings (#314) 2025-10-11 04:01:51 -04:00
GitHub Actions 32cb8137cc chore: bump version to 6.0.0 2025-10-11 07:12:26 +00:00
GitHub Actions ba1e488f32 chore: bump version to 5.0.0 2025-10-04 01:01:06 +00: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