Skip to content

Restore Unity connections across managed frontends - #241

Merged
wallstop merged 3 commits into
mainfrom
fix/unity-bridge-readiness
Oct 14, 2026
Merged

wallstop merged 3 commits into
mainfrom
fix/unity-bridge-readiness

Conversation

@wallstop

@wallstop wallstop commented Oct 14, 2026 •

Copy link
Copy Markdown
Owner

DISCLOSURE: LLM-GENERATED TEXT

Why: Managed frontends can fail to drive a running Unity host bridge.

What:

  • Verify the serving HTTP instance before publishing its port.
  • Keep HTTP responsive while frontend configuration sync runs.
  • Preserve optional authentication and share the pinned bridge across frontends.
  • Fail diagnostics on connection, RPC, and editor errors.
  • Cover startup, authentication, concurrent requests, and crash recovery.

Fixes #239. Refs #171, #114, #226.


Note

Medium Risk
Changes shared MCP URLs, optional auth semantics, VS Code port-forward defaults, and host bridge startup/port selection—high impact on agent↔Unity connectivity but guarded by new contract tests.

Overview
Fixes managed agent frontends failing to reach a host-side Unity MCP HTTP bridge by aligning config, devcontainer networking, and diagnostics with container→host access (not VS Code reverse tunnels).

Devcontainer / VS Code: Disables automatic port forwarding, restoration, and forward-on-open so bridge ports are not shadowed by loopback tunnels; docs explain clearing stale forwards in the Ports view.

mcp:sync / configure.mjs: All managed frontends (including Cursor) now share the same pinned host.docker.internal bridge URL, with optional UNITY_MCP_HTTP_URL and auth only when UNITY_MCP_TOKEN is already set (sync no longer auto-generates or rotates tokens). VS Code Unity entries get safer mcp-remote quoting and valid command/args shape.

Host bridge (unity-mcp-host.mjs): Verifies the bound HTTP instance (instanceId / bridgePid on /healthz) before persisting port or syncing clients; keeps HTTP responsive during async config sync; tightens Windows port checks, env precedence (workspace over legacy ~/.unity-mcp for transport), and CLI crash/EPIPE recovery.

Doctors: Unity checks honor UNITY_MCP_HTTP_URL, always exercise MCP initialize, and fail on health/RPC/editor canary problems (container mode targets host.docker.internal; Windows path pins compare with ntpath).

Tests: New bridge integration suite plus expanded sync/doctor contracts.

Reviewed by Cursor Bugbot for commit 0cb1293. Bugbot is set up for automated code reviews on this repo. Configure here.

Managed clients could not drive the host editor because reverse tunnels shadowed loopback traffic and connection settings diverged. Verify the serving HTTP instance before publishing the port, keep configuration sync asynchronous, preserve the optional token, and route managed frontends through the pinned bridge.

Validation: full non-Unity gate passed (10 steps), strict pyright passed, eight subprocess bridge contracts and all sync/doctor contracts passed. The live doctor discovered 160 tools and drove the configured host project with zero failures or warnings. npm pack dry-run passed. No shipped C# changed.

Host Unity 6000.5.2f1 on Windows: PlayMode 15/15 and AssetProcessorRelevanceTests 5/5 passed. Full EditMode twice passed 382/384; the same unrelated performance-driver contracts failed and are tracked in #240. Windows wildcard coexistence was observed in the prior host investigation; this session executes the subprocess regressions on Linux and leaves Windows execution to CI. Revert this commit to restore the previous connection behavior.

Fixes #239. Refs #171, #114, #226, #240.
Windows terminates the bridge parent without stopping the fixture CLI child. The child keeps its current directory open, so temporary-directory cleanup fails even when the assertions pass. Stop the fixture process tree before removing its files; keep every behavior assertion.

Validation: scoped fast check, strict pyright, and full non-Unity gate pass. Windows CI on PR #241 exposed this cleanup failure and will validate the repair. Refs #239.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b32384d. Configure here.

Comment thread scripts/unity_mcp_doctor.py
Comment thread .llm/mcp/mcp-doctor.mjs
Equivalent Windows project pins and endpoint URLs could fail healthy bridge diagnostics. Normalize Windows dot segments and trailing separators before comparing case, and strip endpoint slashes before constructing the JS health URL.

Regression tests fail before the repair for three Windows pin variants and the trailing-slash JS probe. All 13 doctor tests, strict pyright, the scoped fast check, and the full 39-file harness gate now pass. The live doctor confirms the correct host editor with zero failures or warnings. No Unity C# changed; the two separately recorded performance-driver failures remain on #240.

Address both review findings on PR #241. Refs #239, #171.
@wallstop
wallstop merged commit c62aa5c into main Oct 14, 2026
5 checks passed
@wallstop
wallstop deleted the fix/unity-bridge-readiness branch October 14, 2026 21:34
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.

Unity MCP startup can advertise an unreachable bridge

1 participant