Skip to content

Add a Python Unity HTTP bridge - #299

Merged
Eli Pinkerton (wallstop) merged 3 commits into
refactor/python-mcp-configuratorfrom
refactor/python-unity-bridge
Oct 19, 2026
Merged

Eli Pinkerton (wallstop) merged 3 commits into
refactor/python-mcp-configuratorfrom
refactor/python-unity-bridge

Conversation

@wallstop

@wallstop Eli Pinkerton (wallstop) commented Oct 18, 2026 •

Copy link
Copy Markdown
Collaborator

DISCLOSURE: LLM-GENERATED TEXT

Why: The Unity HTTP bridge still depends on a Node implementation.

What:

  • Add a typed Python bridge using the existing startup settings.
  • Preserve RPC routing, authentication, recovery, and body draining.
  • Verify port publication and Docker host route identity.
  • Exercise both implementations through shared HTTP contracts.

Refs #171.

Type of Change

  • Refactor (code change that neither fixes a bug nor adds a feature)

Checklist

  • I have added tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • My changes do not introduce breaking changes, or breaking changes are documented

Note

Medium Risk
New network-facing bridge code paths (auth, port binding, Docker route checks, CLI process management) parallel the Node host; behavior is heavily tested but mistakes could break MCP connectivity or port publication.

Overview
Adds a typed Python Unity MCP HTTP bridge (scripts/unity_mcp_host.py) as a Node-free host option, runnable via uv run scripts/unity_mcp_host.py, using the same unity_mcp_settings resolution, /healthz identity, bearer auth, JSON-RPC over /mcp, Unity CLI subprocess lifecycle, and startup flow (local self-check, Docker host.docker.internal instance verification, dynamic port selection, .env.local publication, optional mcp_configure.py sync).

Tests extend the shared HostTests harness with PythonHostTests (Python fake CLI, config-sync fixture) plus focused unit tests for Docker-route failures, publication guards, spawn/timeout/batch/parse behavior, and Windows port probing. Docs note the Python bridge alongside the legacy Node host.

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

The Unity HTTP host is the last substantive Node implementation in the tooling migration. Add a direct Python bridge while keeping the existing entry active for a bounded cutover.

Keep lazy CLI ownership, ID remapping, authentication, batch and notification semantics, timeout and crash recovery, early-body draining, dynamic port publication, Docker route identity checks, and responsive config sync. Share real HTTP contracts with the old implementation and cover Python route failures separately.

Strict pyright and actual Python 3.9 contracts pass. The final 17-step gate passes the full harness suite. An isolated native Windows startup verifies the Docker route; container initialization, 160-tool discovery, and editor status reach the pinned Unity project. The validation process tree was stopped and its temporary workspace deleted. C# remains at the previously validated 395 EditMode and 15 PlayMode passes.

Refs #171. A later bounded layer switches the existing host entry point.
@wallstop
Eli Pinkerton (wallstop) added this pull request to stack #297 October 18, 2026 20:57
Windows virtual-environment python.exe redirects to a separate interpreter process. The fixtures compared the redirector PID with the bridge PID. Use the base interpreter for both fixture processes so process identity assertions keep checking the actual server.

All three failing cases pass in a fresh native Windows venv. Strict pyright, the affected fast check, and the complete 17-step gate pass. The repair changes tests only. Refs #171.

@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 1fd531f. Configure here.

Comment thread scripts/unity_mcp_host.py
Comment thread scripts/unity_mcp_host.py
A failed spawn could remove the previous request's pending entry before the new request acquired an ID. Remove only the ID acquired by the failing request. Add a regression that keeps the earlier waiter reachable until CLI failure completes it.

Windows SO_REUSEADDR can bind beside an active listener. Use default Windows binding for both probes and the HTTP server; retain Unix TIME_WAIT reuse. libuv uses the same Windows policy because SO_EXCLUSIVEADDRUSE also rejects TIME_WAIT sockets: https://github.com/libuv/libuv/blob/v1.x/src/win/tcp.c

Both regressions fail before repair. Native Windows passes all seven startup unit cases, including the occupied reusable listener; all 14 shared Python host cases complete with four expected platform/legacy skips. Strict pyright and the final 17-step gate pass. Refs #171 and PR #299 review findings.
@wallstop
Eli Pinkerton (wallstop) merged commit 61ca781 into main Oct 19, 2026
3 checks passed
@wallstop
Eli Pinkerton (wallstop) deleted the refactor/python-unity-bridge branch October 19, 2026 02:16
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