INNER CODE UNIT · Python

_headers

codedpro/mt5-trade-split-manager · mcp_server.py:39

def _headers() -> dict:
    return {"X-API-Key": API_KEY} if API_KEY else {}


def _format_http_error(resp: httpx.Response):
    """Turn a >=400 response into a readable string, preferring the bridge's
    own error detail (FastAPI puts it under "detail")."""
    try:
        body = resp.json()
    except Exception:
        return f"bridge returned HTTP {resp.status_code}: {resp.text}"
    detail = body.get("detail", body) if isinstance(body, dict) else body
    return f"bridge returned HTTP {resp.status_code}: {detail}"


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."""

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…