mirror of
https://github.com/GH05TCREW/pentestagent.git
synced 2026-03-07 22:33:38 +00:00
fix(mcp): correct indentation and robust /sse URL handling
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user