Skip to content

Py files not found and tracked by external tools added. #308

Closed

Description

@JohanHoltby

The current implementation requires MCP4Unity to be placed in the package folder and cannot be added directly, like a git url. As that prevents edits needed to add py to the tools folder. It doesn't also track and automatically find py files, so this makes it hard for other tools to extend their own functionality with MCP.

I would like to see MCPForUnity automatically find all folders in the project having some standard name and then identify the py file and a version.txt so it's easy to track the version of the MCP integration and update it when the user updates it...automatically on domain reload. C-sharp files can be done as before, because that's a good solution.

I have this implementation in my fork so happy to do a PR.

Activity

  1. JohanHoltby commented on Oct 9, 2025

    @JohanHoltby
    ContributorAuthor

    The user would need to create a folder somewhere in their Assets that looks like this:

    Image
  2. JohanHoltby commented on Oct 9, 2025

    @JohanHoltby
    ContributorAuthor

    So I believe the PR is ready for human review. :)

  3. msanatan commented on Oct 9, 2025

    @msanatan
    Member

    Thanks for contributing @JohanHoltby!

    The current implementation requires MCP4Unity to be placed in the package folder and cannot be added directly, like a git url.

    Hmm... I wonder if we should release a .unitypackage that makes installing in the Assets folder easier?

    Are you sure? It's primarily installed as a package, but it works from the Asset folder as well. At least it did, it has to work from that folder for the Asset store submission to work.

    As that prevents edits needed to add py to the tools folder. It doesn't also track and automatically find py files, so this makes it hard for other tools to extend their own functionality with MCP.

    This I totally get, it's not convenient at all. And I think I see the PR and example helps me understand! You have a folder with both the C# and Python code for the tools!

    version.txt so it's easy to track the version of the MCP integration and update it when the user updates it

    I see.. this part feels a bit like extra management though. When you update the package, the Python server is overwritten, so the custom tools are gone. "Rebuild MCP Server" should keep your custom tools, and ideally that function is what's called after an update

  4. msanatan commented on Oct 9, 2025

    @msanatan
    Member

    One thing we may do in a couple of weeks is #293. How I think it can work is:

    1. Add more attributes for tools and parameters, like descriptions
    2. Expand the current reflection to parse that info as well
    3. Save the tools as JSON in the server
    4. (The unfortunate part) use a template to map the JSON entries into tool files

    However, that's a bit further away, so something like this would be really useful.

    Is it possible to have the Rebuild button capture these folder tools as well?

  5. JohanHoltby commented on Oct 9, 2025

    @JohanHoltby
    ContributorAuthor

    One thing we may do in a couple of weeks is #293. How I think it can work is:

    1. Add more attributes for tools and parameters, like descriptions
    2. Expand the current reflection to parse that info as well
    3. Save the tools as JSON in the server
    4. (The unfortunate part) use a template to map the JSON entries into tool files

    However, that's a bit further away, so something like this would be really useful.

    Is it possible to have the Rebuild button capture these folder tools as well?

    So yes that is handled like this. So sl is automatic. Just did a rebuild and it re adds the tool.

    <color=#2EA3FF>MCP-FOR-UNITY: Deleted existing server at C:\Users\JohanHoltby\AppData\Local\UnityMCP\UnityMcpServer
    UnityEngine.Debug:Log (object)
    MCPForUnity.Editor.Helpers.ServerInstaller:RebuildMcpServer () (at ./Packages/unity-mcp-MooseRunner/MCPForUnity/Editor/Helpers/ServerInstaller.cs:657)
    MCPForUnity.Editor.Windows.MCPForUnityEditorWindow:DrawServerStatusSection () (at ./Packages/unity-mcp-MooseRunner/MCPForUnity/Editor/Windows/MCPForUnityEditorWindow.cs:380)
    MCPForUnity.Editor.Windows.MCPForUnityEditorWindow:OnGUI () (at ./Packages/unity-mcp-MooseRunner/MCPForUnity/Editor/Windows/MCPForUnityEditorWindow.cs:189)
    UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

    <color=#2EA3FF>MCP-FOR-UNITY: Copied Unity project tool: run_play_mode_tests.py from MooseRunnerGit_MCPForUnityTools (v1.0.6)
    UnityEngine.Debug:Log (object)
    MCPForUnity.Editor.Helpers.McpLog:Info (string,bool) (at ./Packages/unity-mcp-MooseRunner/MCPForUnity/Editor/Helpers/McpLog.cs:18)
    MCPForUnity.Editor.Helpers.ServerInstaller:CopyUnityProjectTools (string) (at ./Packages/unity-mcp-MooseRunner/MCPForUnity/Editor/Helpers/ServerInstaller.cs:493)
    MCPForUnity.Editor.Helpers.ServerInstaller:RebuildMcpServer () (at ./Packages/unity-mcp-MooseRunner/MCPForUnity/Editor/Helpers/ServerInstaller.cs:673)
    MCPForUnity.Editor.Windows.MCPForUnityEditorWindow:DrawServerStatusSection () (at ./Packages/unity-mcp-MooseRunner/MCPForUnity/Editor/Windows/MCPForUnityEditorWindow.cs:380)
    MCPForUnity.Editor.Windows.MCPForUnityEditorWindow:OnGUI () (at ./Packages/unity-mcp-MooseRunner/MCPForUnity/Editor/Windows/MCPForUnityEditorWindow.cs:189)
    UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

    <color=#2EA3FF>MCP-FOR-UNITY: Copied 1 Unity project tool(s) to server
    UnityEngine.Debug:Log (object)
    MCPForUnity.Editor.Helpers.McpLog:Info (string,bool) (at ./Packages/unity-mcp-MooseRunner/MCPForUnity/Editor/Helpers/McpLog.cs:18)
    MCPForUnity.Editor.Helpers.ServerInstaller:CopyUnityProjectTools (string) (at ./Packages/unity-mcp-MooseRunner/MCPForUnity/Editor/Helpers/ServerInstaller.cs:522)
    MCPForUnity.Editor.Helpers.ServerInstaller:RebuildMcpServer () (at ./Packages/unity-mcp-MooseRunner/MCPForUnity/Editor/Helpers/ServerInstaller.cs:673)
    MCPForUnity.Editor.Windows.MCPForUnityEditorWindow:DrawServerStatusSection () (at ./Packages/unity-mcp-MooseRunner/MCPForUnity/Editor/Windows/MCPForUnityEditorWindow.cs:380)
    MCPForUnity.Editor.Windows.MCPForUnityEditorWindow:OnGUI () (at ./Packages/unity-mcp-MooseRunner/MCPForUnity/Editor/Windows/MCPForUnityEditorWindow.cs:189)
    UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

    <color=#2EA3FF>MCP-FOR-UNITY: Server rebuilt successfully at C:\Users\JohanHoltby\AppData\Local\UnityMCP\UnityMcpServer (version 5.0.0)
    UnityEngine.Debug:Log (object)
    MCPForUnity.Editor.Helpers.ServerInstaller:RebuildMcpServer () (at ./Packages/unity-mcp-MooseRunner/MCPForUnity/Editor/Helpers/ServerInstaller.cs:686)
    MCPForUnity.Editor.Windows.MCPForUnityEditorWindow:DrawServerStatusSection () (at ./Packages/unity-mcp-MooseRunner/MCPForUnity/Editor/Windows/MCPForUnityEditorWindow.cs:380)
    MCPForUnity.Editor.Windows.MCPForUnityEditorWindow:OnGUI () (at ./Packages/unity-mcp-MooseRunner/MCPForUnity/Editor/Windows/MCPForUnityEditorWindow.cs:189)
    UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

    The version.txt might seam overhead but is needed for the senario when a new version of an other asset is released. And need to force an update of just that tool. That will happen automatically after domain reload which happens just after every package update.

  6. JohanHoltby commented on Oct 9, 2025

    @JohanHoltby
    ContributorAuthor

    The current implementation requires MCP4Unity to be placed in the package folder and cannot be added directly, like a git url.

    ... I mean that when you install it using the git url it ends up as an immutable package in the package cache. You can move it to Packsges folder to add tools manually but that is a lot of hassle and break some other update functions.

    If I did miss understod or missed any question just ping @msanatan

    Thank you so much on all great work on this mcp and Copley! :)

  7. JohanHoltby commented on Oct 10, 2025

    @JohanHoltby
    ContributorAuthor

    Thank you for taking the time to review @msanatan!

    So a more concrete feature list:
    MCPForUnity now allows external tools to installed automatic as long they are placed under Assets, Packages and Library\PackageCache. All they need is to add a folder MCPForUnityTools with four files.
    *One Asmdef which has conditional compilation if MCPForUnity is installed.
    *One Python file with the server code.
    *One C# file with the Unity side code of the tool acting as a bridge to the asset.
    *One version.txt with the version like 1.0.1 to allow automatic update on Asset update. Checked on domain reload.

    On domain reload and normal installation of the server (including rebuild) ALL tools are checked:
    If MCPForUnity is updated then on domain reload the tools are installed again automatically.
    If tool is removed it's uninstalled from server on domain reload. This is since all MCPForUnityTools are checked and compared on domain reload.
    If a tool is updated the version mismatch will trigger re installing that specific tool.

    This allow for zero end user engagement to enable a tool. If MCPForUnity is installed and an MCPForUnity ready asset is installed in the project it's registered and found by the MCPForUnity.

    Hope this is more concrete. Geting my point across is not my strong suit. ;) So if any thing is unclear just ask or suggest improvement.

  8. JohanHoltby commented on Oct 10, 2025

    @JohanHoltby
    ContributorAuthor

    I did just found a bug. some pycache foder gets removed in the tools folder. I need to exclude that folder from cleaning. Don't push PR forward yet.

  9. JohanHoltby commented on Oct 10, 2025

    @JohanHoltby
    ContributorAuthor

    So now pycache fix is done. Used the _skipDirs as that sounds about right ;) @msanatan

  10. msanatan commented on Oct 10, 2025

    @msanatan
    Member

    The current implementation requires MCP4Unity to be placed in the package folder and cannot be added directly, like a git url.

    ... I mean that when you install it using the git url it ends up as an immutable package in the package cache. You can move it to Packsges folder to add tools manually but that is a lot of hassle and break some other update functions.

    If I did miss understod or missed any question just ping @msanatan

    Thank you so much on all great work on this mcp and Copley! :)

    My bad, you're correct an that's very clear!

  11. msanatan commented on Oct 10, 2025

    @msanatan
    Member

    Thank you for taking the time to review @msanatan!

    So a more concrete feature list: MCPForUnity now allows external tools to installed automatic as long they are placed under Assets, Packages and Library\PackageCache. All they need is to add a folder MCPForUnityTools with four files. *One Asmdef which has conditional compilation if MCPForUnity is installed. *One Python file with the server code. *One C# file with the Unity side code of the tool acting as a bridge to the asset. *One version.txt with the version like 1.0.1 to allow automatic update on Asset update. Checked on domain reload.

    On domain reload and normal installation of the server (including rebuild) ALL tools are checked: If MCPForUnity is updated then on domain reload the tools are installed again automatically. If tool is removed it's uninstalled from server on domain reload. This is since all MCPForUnityTools are checked and compared on domain reload. If a tool is updated the version mismatch will trigger re installing that specific tool.

    This allow for zero end user engagement to enable a tool. If MCPForUnity is installed and an MCPForUnity ready asset is installed in the project it's registered and found by the MCPForUnity.

    Hope this is more concrete. Geting my point across is not my strong suit. ;) So if any thing is unclear just ask or suggest improvement.

    Thank you, this helps a lot! I really appreciate the effort you took to explain it. I like the fact that domain reloads gets the tools re-registered. Having all your tools in a fixed folder is a limitation, but I think this is good for now and we can iterate later with the C# only method.

    Can you update the CUSTOM_TOOLS readme with these instructions?

  12. JohanHoltby commented on Oct 10, 2025

    @JohanHoltby
    ContributorAuthor

    Thank you :). Happy to contribute! Sure will do and ping once done :)

  13. msanatan commented on Oct 10, 2025

    @msanatan
    Member

    Thank you! This is awesome

  14. added
    enhancement
    on Oct 10, 2025
  15. JohanHoltby commented on Oct 13, 2025

    @JohanHoltby
    ContributorAuthor

    @msanatan I believe what the rabbit comes with now is not relevant. Please review and see if all is adaptable. Have been using the branch as for one week and nothing seams out of place but not too heavy testing. What is your testing work flow? Any thing I should do?

  16. JohanHoltby commented on Oct 13, 2025

    @JohanHoltby
    ContributorAuthor

    @msanatan did just found a bug.

  17. msanatan commented on Oct 14, 2025

    @msanatan
    Member

    @msanatan I believe what the rabbit comes with now is not relevant. Please review and see if all is adaptable. Have been using the branch as for one week and nothing seams out of place but not too heavy testing. What is your testing work flow? Any thing I should do?

    Generally we test locally (and tbh we just trust you haha). Sorry for the silence! I had some more thoughts as I was checking it out, and left fairly detailed feedback on the PR (which I should have done instead of communicating here). I'd like some changes to match the current code pattens we've introduced, remove the caveats mentioned before.

    Let's move technical feedback to #309, as the critical feedback is there

  18. msanatan commented on Oct 18, 2025

    @msanatan
    Member

    @JohanHoltby thanks for your help. I built upon your work and added the SciptableObject solution from the review: #324

  19. JohanHoltby commented on Oct 18, 2025

    @JohanHoltby
    ContributorAuthor

    @msanatan Thank you so much! Happy you fixed it! I will adapt my to to it immediately and start using it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions