Fix port discovery protocol mismatch (#341)
- Update _try_probe_unity_mcp to recognize Unity bridge welcome message - Unity bridge sends 'WELCOME UNITY-MCP' instead of JSON pong response - Maintains backward compatibility with JSON pong format - Fixes MCP server connection to Unity Editormain
parent
26eafbfe11
commit
15bf79391f
|
|
@ -56,7 +56,7 @@ class PortDiscovery:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _try_probe_unity_mcp(port: int) -> bool:
|
def _try_probe_unity_mcp(port: int) -> bool:
|
||||||
"""Quickly check if a MCP for Unity listener is on this port.
|
"""Quickly check if a MCP for Unity listener is on this port.
|
||||||
Tries a short TCP connect, sends 'ping', expects a JSON 'pong'.
|
Tries a short TCP connect, sends 'ping', expects Unity bridge welcome message.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
with socket.create_connection(("127.0.0.1", port), PortDiscovery.CONNECT_TIMEOUT) as s:
|
with socket.create_connection(("127.0.0.1", port), PortDiscovery.CONNECT_TIMEOUT) as s:
|
||||||
|
|
@ -64,8 +64,8 @@ class PortDiscovery:
|
||||||
try:
|
try:
|
||||||
s.sendall(b"ping")
|
s.sendall(b"ping")
|
||||||
data = s.recv(512)
|
data = s.recv(512)
|
||||||
# Minimal validation: look for a success pong response
|
# Check for Unity bridge welcome message format
|
||||||
if data and b'"message":"pong"' in data:
|
if data and (b"WELCOME UNITY-MCP" in data or b'"message":"pong"' in data):
|
||||||
return True
|
return True
|
||||||
except Exception:
|
except Exception:
|
||||||
return False
|
return False
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue