fix(mcp): correct indentation and robust /sse URL handling

This commit is contained in:
giveen
2026-01-14 15:01:44 -07:00
parent f940288a94
commit 82aca6a324

View File

@@ -456,15 +456,18 @@ class MCPManager:
use_http = True
# If args specify a --server URL, prefer that
if not http_url:
from urllib.parse import urlparse
for i, a in enumerate(config.args or []):
if a == "--server" and i + 1 < len(config.args):
candidate = config.args[i + 1]
if isinstance(candidate, str) and candidate.startswith("http"):
# If the provided server URL doesn't include a path, default to the MCP SSE path
if candidate.rstrip('/').endswith(str(port)) or candidate.rstrip('/') == candidate.split('//')[-1].split(':')[0]:
http_url = candidate.rstrip('/') + '/sse'
else:
http_url = candidate
# If the provided server URL doesn't include a path, default to the MCP SSE path
p = urlparse(candidate)
if p.path and p.path != "/":
http_url = candidate
else:
http_url = candidate.rstrip("/") + "/sse"
use_http = True
break