{"record":{"id":"ee1bed35fe0d72c8","repo":"CoplayDev/unity-mcp","slug":"http-error-from-server-e-response-status-code","errorCode":null,"errorMessage":"HTTP error from server: {e.response.status_code} - {e.response.text}","messagePattern":"HTTP error from server: (.+?) - (.+?)","errorType":"exception","errorClass":"UnityConnectionError","httpStatus":null,"severity":"error","filePath":"Server/src/cli/utils/connection.py","lineNumber":122,"sourceCode":"                url,\n                json=payload,\n                timeout=timeout or cfg.timeout,\n            )\n            response.raise_for_status()\n            return response.json()\n    except httpx.ConnectError as e:\n        raise UnityConnectionError(\n            f\"Cannot connect to Unity MCP server at {cfg.host}:{cfg.port}. \"\n            f\"Make sure the server is running and Unity is connected.\\n\"\n            f\"Error: {e}\"\n        )\n    except httpx.TimeoutException:\n        raise UnityConnectionError(\n            f\"Connection to Unity timed out after {timeout or cfg.timeout}s. \"\n            f\"Unity may be busy or unresponsive.\"\n        )\n    except httpx.HTTPStatusError as e:\n        raise UnityConnectionError(\n            f\"HTTP error from server: {e.response.status_code} - {e.response.text}\"\n        )\n    except Exception as e:\n        raise UnityConnectionError(f\"Unexpected error: {e}\")\n\n\ndef run_command(\n    command_type: str,\n    params: Dict[str, Any],\n    config: Optional[CLIConfig] = None,\n    timeout: Optional[int] = None,\n) -> Dict[str, Any]:\n    \"\"\"Synchronous wrapper for send_command.\n\n    Args:\n        command_type: The command type\n        params: Command parameters\n        config: Optional CLI configuration","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/CoplayDev/unity-mcp/blob/c21bf496bca87d54e75bad048563c3adb1782081/Server/src/cli/utils/connection.py#L104-L140","documentation":"Thrown by send_command() when the server returns a non-2xx HTTP status (raise_for_status fails). The message includes the status code and the raw response body. Unlike connection or timeout errors, this means the server was reached and actively rejected the request — bad params, internal server error, or a missing Unity instance.","triggerScenarios":"Posting a command with invalid params that the server rejects (400), a server-side exception (500), or hitting an endpoint that requires a unity_instance that is not connected (4xx). Also from auth/routing errors if the server is reverse-proxied.","commonSituations":"Malformed command payload, server bug producing a 500, or the target Unity instance disconnected so the server returns an error status. Common when the CLI version and server version disagree on the command schema.","solutions":["Read the status code and response body in the message to identify the cause (4xx vs 5xx).","For 4xx, correct the command params; verify CLI and server versions match.","For 5xx, inspect the server logs for the underlying exception.","Confirm the unity_instance (if set) is connected to the server."],"exampleFix":"# before\n# passing an invalid action\nunity-mcp texture create --pattern bogus\n# after\n# use a supported value and check server logs on 5xx\nunity-mcp texture create --pattern checkerboard","handlingStrategy":"try-catch","validationCode":"import httpx\nr = httpx.post(url, json=payload, timeout=cfg.timeout)\nif r.status_code >= 400:\n    raise RuntimeError(f\"server returned {r.status_code}: {r.text}\")","typeGuard":null,"tryCatchPattern":"try:\n    return await send_command(cmd, params)\nexcept UnityConnectionError as e:\n    msg = str(e)\n    if \"HTTP error\" in msg:\n        # parse status code, surface body for 4xx/5xx triage\n        ...\n    raise","preventionTips":["Keep CLI and server versions in sync to avoid schema mismatches.","Inspect server logs for any 5xx."],"tags":["cli","network","http","server-error"],"backgroundTag":null,"analyzedSha":"c21bf496bca87d54e75bad048563c3adb1782081","analyzedAt":"2026-08-13T17:36:56.095Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}