Skip to content

Conversation

@dsarno
Copy link
Collaborator

@dsarno dsarno commented Jan 8, 2026

Changes

  • Default to PyPI: Changed default server source from git+https://github.com/CoplayDev/unity-mcp@v{version}#subdirectory=Server to mcpforunityserver=={version}
  • Renamed method: GetMcpServerGitUrl()GetMcpServerPackageSource() (deprecated wrapper kept for compatibility)
  • UI path display fix: Use forward slashes in deployment paths to avoid escape sequence rendering issues

Testing

  • Verified PyPI installation works: uvx --from mcpforunityserver==9.0.1 mcp-for-unity --help
  • All 269 EditMode tests pass
  • Manual testing in Unity Editor confirmed

Summary by Sourcery

Switch MCP server installation to use a PyPI package source by default and improve path handling in deployment UI.

Bug Fixes:

  • Avoid Windows installation failures due to long git clone paths by defaulting the MCP server source to a PyPI package reference instead of a Git URL.
  • Fix misleading or unreadable backslash escape sequences in deployment-related UI labels by displaying paths with forward slashes.

Enhancements:

  • Introduce a generalized MCP server package source helper, deprecating the Git-URL-specific method while keeping a compatibility wrapper.
  • Update configuration and status-check logic to rely on the new package source helper for uvx commands.

Tests:

  • Adjust Codex configuration tests to validate that the MCP server is referenced via the PyPI package name instead of a Git URL.

dsarno added 2 commits January 8, 2026 06:45
Fixes Windows installation failures caused by long path issues when
cloning the full repository (MAX_PATH 260 char limit exceeded).

- Change default from git+https://github.com/CoplayDev/unity-mcp to
  mcpforunityserver=={version} PyPI package
- Rename GetMcpServerGitUrl() to GetMcpServerPackageSource()
- Keep deprecated wrapper for backwards compatibility
- Update UI help text to show local dev override example only
- Update tests to expect PyPI package reference
Fixes UI rendering issue where backslashes in Windows paths were
interpreted as escape sequences (e.g. \U, \u showing as boxes).

Convert backslashes to forward slashes for display in:
- Target path label
- Backup path label
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 8, 2026

📝 Walkthrough

Walkthrough

This PR replaces Git URL-based references to the MCP server with PyPI package source references. A new GetMcpServerPackageSource() method is introduced in AssetPathUtility to return package names like mcpforunityserver or mcpforunityserver==<version>. The old GetMcpServerGitUrl() method is deprecated and delegates to the new one. All dependent code—configurators, services, and UI components—are updated to use the new method, and tests are updated to expect PyPI package references instead of Git URLs.

Changes

Cohort / File(s) Summary
Core Utility Refactoring
MCPForUnity/Editor/Helpers/AssetPathUtility.cs
Introduced new public method GetMcpServerPackageSource() that returns PyPI-style package references (mcpforunityserver or mcpforunityserver==<version>). Deprecated GetMcpServerGitUrl() with a delegate wrapper. Updated override handling (gitUrlOverride → sourceOverride) and fallback logic for version resolution. Updated internal callers to use the new method.
Configurator Updates
MCPForUnity/Editor/Clients/McpClientConfiguratorBase.cs
Replaced all usages of GetMcpServerGitUrl() with GetMcpServerPackageSource() across JSON-file, Codex TOML, and Claude CLI configurators. Updated local variable names (gitUrl → packageSource) in manual snippet generation paths.
UI and Path Display
MCPForUnity/Editor/Services/PackageDeploymentService.cs, MCPForUnity/Editor/Windows/Components/Settings/McpSettingsSection.cs
Added path normalization to convert backslashes to forward slashes for UI display in GetTargetDisplayPath() and backup path labels. Prevents escape sequence issues in UI text rendering.
Settings UI Help Text
MCPForUnity/Editor/Windows/Components/Settings/McpSettingsSection.uxml
Updated displayed help text from Git-based examples to PyPI-based override example with local development path guidance.
Test Updates
TestProjects/UnityMCPTests/Assets/Tests/EditMode/Helpers/CodexConfigHelperTests.cs
Updated four test assertions to expect PyPI package reference ("mcpforunityserver") instead of Git URL in generated Codex server blocks across Windows and Non-Windows scenarios.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested reviewers

  • msanatan

Poem

🐰✨ From Git to PyPI we hop with glee,
Package sources now flow so free!
Backslashes tamed in UI display,
Tests align in the modern way,
A cleaner path for users to see! 🌟

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: switching from git URL to PyPI package source to fix Windows MAX_PATH installation failures, which is clearly reflected in the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 275422e and 63002e1.

📒 Files selected for processing (6)
  • MCPForUnity/Editor/Clients/McpClientConfiguratorBase.cs
  • MCPForUnity/Editor/Helpers/AssetPathUtility.cs
  • MCPForUnity/Editor/Services/PackageDeploymentService.cs
  • MCPForUnity/Editor/Windows/Components/Settings/McpSettingsSection.cs
  • MCPForUnity/Editor/Windows/Components/Settings/McpSettingsSection.uxml
  • TestProjects/UnityMCPTests/Assets/Tests/EditMode/Helpers/CodexConfigHelperTests.cs
🧰 Additional context used
🧠 Learnings (6)
📓 Common learnings
Learnt from: dsarno
Repo: CoplayDev/unity-mcp PR: 265
File: README.md:204-204
Timestamp: 2025-09-05T16:22:04.960Z
Learning: In the Unity MCP project, the ServerInstaller.cs creates a symlink from ~/Library/AppSupport to ~/Library/Application Support on macOS to mitigate argument parsing and quoting issues in some MCP clients. The README documentation should use the shortened AppSupport path, not the full "Application Support" path with spaces.
Learnt from: dsarno
Repo: CoplayDev/unity-mcp PR: 265
File: README.md:204-204
Timestamp: 2025-09-05T16:22:04.960Z
Learning: In the Unity MCP project, the ServerInstaller.cs creates a symlink from ~/Library/AppSupport to ~/Library/Application Support on macOS to mitigate argument parsing and quoting issues in some MCP clients. The README documentation should use the shortened AppSupport path, not the full "Application Support" path with spaces.
Learnt from: dsarno
Repo: CoplayDev/unity-mcp PR: 265
File: README.md:204-204
Timestamp: 2025-09-05T16:22:04.960Z
Learning: In the Unity MCP project, the ServerInstaller.cs creates a symlink from ~/Library/AppSupport to ~/Library/Application Support on macOS to avoid spaces in paths that can cause arg parsing and quoting issues in some MCP clients. The README documentation should use the shortened AppSupport path, not the full "Application Support" path.
Learnt from: dsarno
Repo: CoplayDev/unity-mcp PR: 490
File: Server/pyproject.toml:33-33
Timestamp: 2025-12-29T04:54:25.306Z
Learning: For fastmcp dependency in Server/pyproject.toml: prefer exact version pinning (e.g., fastmcp==2.14.1) rather than range pins like >=2.13.0, due to past issues where fastmcp introduced breaking changes that affected all MCP tools.
📚 Learning: 2025-09-05T16:22:04.960Z
Learnt from: dsarno
Repo: CoplayDev/unity-mcp PR: 265
File: README.md:204-204
Timestamp: 2025-09-05T16:22:04.960Z
Learning: In the Unity MCP project, the ServerInstaller.cs creates a symlink from ~/Library/AppSupport to ~/Library/Application Support on macOS to mitigate argument parsing and quoting issues in some MCP clients. The README documentation should use the shortened AppSupport path, not the full "Application Support" path with spaces.

Applied to files:

  • MCPForUnity/Editor/Services/PackageDeploymentService.cs
  • MCPForUnity/Editor/Helpers/AssetPathUtility.cs
  • MCPForUnity/Editor/Windows/Components/Settings/McpSettingsSection.cs
  • MCPForUnity/Editor/Clients/McpClientConfiguratorBase.cs
📚 Learning: 2025-09-05T16:22:04.960Z
Learnt from: dsarno
Repo: CoplayDev/unity-mcp PR: 265
File: README.md:204-204
Timestamp: 2025-09-05T16:22:04.960Z
Learning: In the Unity MCP project, the ServerInstaller.cs creates a symlink from ~/Library/AppSupport to ~/Library/Application Support on macOS to avoid spaces in paths that can cause arg parsing and quoting issues in some MCP clients. The README documentation should use the shortened AppSupport path, not the full "Application Support" path.

Applied to files:

  • MCPForUnity/Editor/Services/PackageDeploymentService.cs
  • MCPForUnity/Editor/Helpers/AssetPathUtility.cs
  • MCPForUnity/Editor/Clients/McpClientConfiguratorBase.cs
📚 Learning: 2025-12-29T15:23:11.613Z
Learnt from: msanatan
Repo: CoplayDev/unity-mcp PR: 491
File: MCPForUnity/Editor/Windows/EditorPrefs/EditorPrefsWindow.cs:78-115
Timestamp: 2025-12-29T15:23:11.613Z
Learning: In MCPForUnity, prefer relying on the established testing process to catch UI initialization issues instead of adding defensive null checks for UI elements in editor windows. This means during reviews, verify that tests cover UI initialization paths and that code avoids repetitive null-check boilerplate in Editor Windows. If a UI element can be null, ensure there is a well-tested fallback or that its initialization is guaranteed by design, rather than sprinkling null checks throughout editor code.

Applied to files:

  • MCPForUnity/Editor/Services/PackageDeploymentService.cs
  • MCPForUnity/Editor/Helpers/AssetPathUtility.cs
  • MCPForUnity/Editor/Windows/Components/Settings/McpSettingsSection.cs
  • MCPForUnity/Editor/Clients/McpClientConfiguratorBase.cs
📚 Learning: 2025-10-13T13:41:00.086Z
Learnt from: JohanHoltby
Repo: CoplayDev/unity-mcp PR: 309
File: MCPForUnity/Editor/Helpers/ServerInstaller.cs:478-508
Timestamp: 2025-10-13T13:41:00.086Z
Learning: In the MCPForUnityTools feature (MCPForUnity/Editor/Helpers/ServerInstaller.cs), the design intentionally forces users to have only one .py file per MCPForUnityTools folder to keep file tracking simple. Package-style tools (subdirectories with __init__.py) are not supported.

Applied to files:

  • MCPForUnity/Editor/Helpers/AssetPathUtility.cs
📚 Learning: 2025-10-13T13:27:23.040Z
Learnt from: msanatan
Repo: CoplayDev/unity-mcp PR: 316
File: TestProjects/UnityMCPTests/Assets/Tests/EditMode/Resources.meta:1-8
Timestamp: 2025-10-13T13:27:23.040Z
Learning: UnityMcpBridge is a legacy project kept for backwards compatibility; MCPForUnity is the only active Unity plugin project. GUID collisions between UnityMcpBridge and MCPForUnity are acceptable.

Applied to files:

  • MCPForUnity/Editor/Helpers/AssetPathUtility.cs
🧬 Code graph analysis (2)
MCPForUnity/Editor/Helpers/AssetPathUtility.cs (2)
MCPForUnity/Editor/Constants/EditorPrefKeys.cs (1)
  • EditorPrefKeys (7-56)
MCPForUnity/Editor/Services/PathResolverService.cs (1)
  • GetUvxPath (22-45)
MCPForUnity/Editor/Clients/McpClientConfiguratorBase.cs (1)
MCPForUnity/Editor/Helpers/AssetPathUtility.cs (2)
  • AssetPathUtility (15-302)
  • GetMcpServerPackageSource (157-175)
🔇 Additional comments (15)
MCPForUnity/Editor/Services/PackageDeploymentService.cs (1)

69-76: LGTM! UI-safe path normalization.

The path normalization correctly converts backslashes to forward slashes for display, avoiding escape-sequence issues in Unity's UI text rendering. The null/empty check before normalization is appropriate.

MCPForUnity/Editor/Windows/Components/Settings/McpSettingsSection.cs (1)

311-312: LGTM! Consistent path normalization for backup display.

The null-conditional backupPath?.Replace('\\', '/') safely handles the path display, consistent with the similar change in PackageDeploymentService.GetTargetDisplayPath().

MCPForUnity/Editor/Windows/Components/Settings/McpSettingsSection.uxml (1)

41-42: LGTM! Updated help text reflects the new PyPI default.

The simplified help text correctly indicates that PyPI is now the default source, with the local dev path example retained for developers who need to override.

TestProjects/UnityMCPTests/Assets/Tests/EditMode/Helpers/CodexConfigHelperTests.cs (4)

251-251: LGTM! Test assertion correctly updated for PyPI reference.

The assertion now expects "mcpforunityserver" in the second arg, aligning with the new GetMcpServerPackageSource() behavior.


316-316: LGTM! Non-Windows test correctly updated.


383-383: LGTM! Upsert Windows test correctly updated.


457-457: LGTM! Upsert non-Windows test correctly updated.

MCPForUnity/Editor/Clients/McpClientConfiguratorBase.cs (3)

151-151: LGTM! Updated to use new package source method.

The status check now correctly compares against the PyPI package reference from GetMcpServerPackageSource().


253-253: LGTM! Codex configurator updated consistently.


588-593: LGTM! Manual snippet generation updated with clearer variable naming.

The variable rename from gitUrl to packageSource improves code clarity and aligns with the semantic change from Git URLs to PyPI package references.

MCPForUnity/Editor/Helpers/AssetPathUtility.cs (5)

177-182: Good deprecation pattern for backward compatibility.

The [System.Obsolete] attribute with a clear migration message and delegation to the new method ensures existing callers continue to work while being guided to migrate.


188-195: LGTM! Internal caller updated to use new method.


217-226: LGTM! IsLocalServerPath() updated consistently.


232-245: LGTM! GetLocalServerPath() updated consistently.


152-175: Well-designed transition from Git URL to PyPI package source.

The implementation correctly:

  1. Preserves backward compatibility by respecting the existing GitUrlOverride EditorPrefs key
  2. Pins to an exact version when available (mcpforunityserver=={version})
  3. Falls back to latest when version is unknown for test scenarios

The EditorPref key name (GitUrlOverride) is intentionally preserved to avoid breaking existing user overrides. The PyPI package mcpforunityserver is published and stable (Production/Stable status), with multiple versions available for version pinning.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Jan 8, 2026

Reviewer's Guide

Defaults MCP server installation to a PyPI package source instead of a git repository URL, updates all usages and tests to the new package source helper, and fixes Windows UI path display by normalizing paths to forward slashes.

Sequence diagram for uvx configuration and manual snippet generation with new package source

sequenceDiagram
    participant User
    participant UnityEditor
    participant McpClientConfiguratorBase as Configurator
    participant AssetPathUtility as Paths
    participant MCPServiceLocatorPaths as Locator
    participant McpConfigurationHelper as ConfigHelper

    User->>UnityEditor: Open MCP settings window
    UnityEditor->>Configurator: CheckStatus(attemptAutoRewrite)
    Configurator->>Paths: GetMcpServerPackageSource()
    Paths->>EditorPrefs: GetString(GitUrlOverride, "")
    alt override present
        EditorPrefs-->>Paths: sourceOverride
        Paths-->>Configurator: sourceOverride
    else no override
        Paths->>Paths: GetPackageVersion()
        alt version unknown
            Paths-->>Configurator: mcpforunityserver
        else version known
            Paths-->>Configurator: mcpforunityserver==version
        end
    end
    Configurator->>McpServiceLocator.Paths: GetUvxPath()
    Configurator->>ConfigHelper: ExtractUvxUrl(args)
    Configurator->>ConfigHelper: PathsEqual(configuredUvxUrl, expectedUvxUrl)
    ConfigHelper-->>Configurator: matches or not
    Configurator-->>UnityEditor: McpStatus

    User->>UnityEditor: View manual setup snippet
    UnityEditor->>Configurator: GetManualSnippet()
    Configurator->>Locator: GetUvxPath()
    Configurator->>Paths: ShouldForceUvxRefresh()
    Configurator->>Paths: GetMcpServerPackageSource()
    Configurator-->>UnityEditor: Shell snippet with uvx --from packageSource
Loading

Class diagram for updated MCP server package source helper

classDiagram
    class AssetPathUtility {
        +JObject GetPackageJson()
        +string GetMcpServerPackageSource()
        <<obsolete>> +string GetMcpServerGitUrl()
        + (string uvxPath, string fromUrl, string packageName) GetUvxCommandParts()
        +bool ShouldForceUvxRefresh()
        +bool IsLocalServerPath()
        +string GetLocalServerPath()
    }

    class McpClientConfiguratorBase {
        +McpStatus CheckStatus(bool attemptAutoRewrite)
        +string GetManualSnippet()
    }

    class PackageDeploymentService {
        +string GetTargetPath()
        +string GetTargetDisplayPath()
        +string GetLastBackupPath()
        +bool HasBackup()
    }

    class McpSettingsSection {
        -Label deployBackupLabel
        +void UpdateDeploymentSection()
    }

    class MCPServiceLocatorPaths {
        +string GetUvxPath()
    }

    class McpConfigurationHelper {
        +string ExtractUvxUrl(string[] args)
        +bool PathsEqual(string pathA, string pathB)
    }

    AssetPathUtility --> MCPServiceLocatorPaths : uses
    McpClientConfiguratorBase --> AssetPathUtility : uses package source
    McpClientConfiguratorBase --> McpConfigurationHelper : uses for comparison
    PackageDeploymentService --> AssetPathUtility : uses paths (indirectly in system)
    McpSettingsSection --> PackageDeploymentService : uses backup path
Loading

File-Level Changes

Change Details Files
Generalize MCP server source helper to return a generic package source and default to PyPI instead of a git URL.
  • Rename helper from GetMcpServerGitUrl to GetMcpServerPackageSource and update XML docs to describe generic package sources usable with uvx --from.
  • Read the existing EditorPrefs override as a generic source string (supporting git URLs, file:// paths, local paths) instead of a git-specific URL.
  • Change the default source from a version-pinned git+https repository URL to a PyPI reference mcpforunityserver=={version}, with unknown version falling back to the unpinned PyPI name mcpforunityserver.
  • Introduce an obsolete GetMcpServerGitUrl wrapper that delegates to GetMcpServerPackageSource for backwards compatibility.
  • Update GetUvxCommandParts, IsLocalServerPath, and GetLocalServerPath to use GetMcpServerPackageSource rather than the old git URL helper.
MCPForUnity/Editor/Helpers/AssetPathUtility.cs
Update configurator logic and manual CLI snippet generation to use the new package source helper and PyPI-based --from value.
  • Use AssetPathUtility.GetMcpServerPackageSource() instead of GetMcpServerGitUrl() when validating configured uvx URLs in CheckStatus.
  • Update the manual Claude configuration snippet to pass the new package source string into the --from argument instead of the git URL.
MCPForUnity/Editor/Clients/McpClientConfiguratorBase.cs
Adjust tests to expect a PyPI package reference in the uvx --from argument instead of a git repository URL.
  • Change CodexConfigHelper tests on Windows and non-Windows platforms to assert that the second argument to --from contains mcpforunityserver (PyPI reference) instead of a git+https GitHub URL.
TestProjects/UnityMCPTests/Assets/Tests/EditMode/Helpers/CodexConfigHelperTests.cs
Normalize deployment and backup paths to use forward slashes in UI labels to avoid backslash escape issues on Windows.
  • Change GetTargetDisplayPath to return a forward-slash-normalized path when a target path exists, keeping the existing fallback message when path is missing.
  • Normalize the backup path in the settings UI label by replacing backslashes with forward slashes before rendering the 'Last backup' text.
MCPForUnity/Editor/Services/PackageDeploymentService.cs
MCPForUnity/Editor/Windows/Components/Settings/McpSettingsSection.cs
MCPForUnity/Editor/Windows/Components/Settings/McpSettingsSection.uxml

Possibly linked issues

  • #(unassigned): Issue reports Windows git install failure on v9.0.1; PR switches to PyPI to fix that failure path.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@dsarno dsarno merged commit cba0933 into CoplayDev:main Jan 8, 2026
1 of 2 checks passed
ZhangJiaLong90524 pushed a commit to ZhangJiaLong90524/unity-mcp-2020-compatible that referenced this pull request Jan 14, 2026
上游變更 (v7.0.0 → v9.0.3):
- GameObject 工具集重構 (CoplayDev#518)
- VFX 管理功能 (CoplayDev#520)
- 批次執行錯誤處理改進 (CoplayDev#531)
- Windows 長路徑問題修復 (CoplayDev#534)
- HTTP/Stdio 傳輸 UX 改進 (CoplayDev#530)
- LLM 工具註解功能 (CoplayDev#480)

衝突解決:
- modify/delete:接受刪除(架構已重構)
- content:接受 v9.0.3 版本(2020 相容性修正將另行處理)
@dsarno dsarno deleted the fix/pypi-default-source branch January 15, 2026 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant