Skip to content

Commit e613607

Browse files
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 work
1 parent 2f50962 commit e613607

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Server/src/transport/legacy/port_discovery.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import glob
1515
import json
1616
import logging
17+
import os
18+
import struct
1719
from datetime import datetime
1820
from pathlib import Path
1921
import socket

0 commit comments

Comments
 (0)