INNER CODE UNIT · Python
_request
codedpro/mt5-trade-split-manager · mcp_server.py:54
def _request(method: str, path: str, json_body: Optional[dict] = None):
"""Call the REST bridge and return parsed JSON, or a readable error string.
All httpx failures are caught here so tools never leak a traceback."""
try:
resp = httpx.request(
method,
f"{BRIDGE_URL}{path}",
json=json_body,
headers=_headers(),
timeout=TIMEOUT,
)
except httpx.ConnectError:
return f"bridge unreachable at {BRIDGE_URL}"
except httpx.TimeoutException:
return f"bridge timed out after {TIMEOUT:.0f}s at {BRIDGE_URL}"
except httpx.HTTPError as e:
return f"bridge request failed: {e}"