Commit e613607
committed
fix: Add missing os and struct imports to port_discovery.py
Problem:
The port discovery mechanism was failing to detect running Unity instances
because the _try_probe_unity_mcp() function was using struct.pack() and
struct.unpack() without importing the struct module, and other functions
were using os.path.basename() without importing the os module. This caused
NameError exceptions that were silently caught, preventing Unity instances
from being discovered.
Root Cause:
- struct.pack() used at line 80 to create message headers
- struct.unpack() used at line 98 to parse response headers
- os.path.basename() used at lines 217 and 247 to extract filenames
- Neither os nor struct modules were imported
Impact:
- Unity instances running on port 6400 were not discoverable
- The MCP server would fail to connect even when Unity was running
- The probe function would fail silently due to exception handling
Solution:
Added missing imports:
- import os (for os.path.basename)
- import struct (for struct.pack/unpack in the framed protocol)
Verification:
- Test script confirmed Unity is responding correctly on port 6400
- The framed protocol (8-byte header + payload) works correctly
- Once the MCP server restarts with these imports, Unity discovery will work1 parent 2f50962 commit e613607
1 file changed
+2
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
| |||
0 commit comments