{"record":{"id":"05d4bf7857097ebe","repo":"iflytek/astron-agent","slug":"mcp-request-error","errorCode":"MCP_REQUEST_ERROR","errorMessage":"Status code: {resp.status}, Response content: {await resp.text()}","messagePattern":"Status code: (.+?), Response content: (.+?)","errorType":"http","errorClass":"CustomException","httpStatus":null,"severity":"error","filePath":"core/workflow/engine/nodes/mcp/mcp_node.py","lineNumber":96,"sourceCode":"            # Prepare MCP tool call request\n            url = f\"{os.getenv('MCP_BASE_URL')}/api/v1/mcp/call_tool\"\n            req_body = {\n                \"mcp_server_id\": self.mcpServerId,\n                \"mcp_server_url\": self.mcpServerUrl,\n                \"tool_name\": self.toolName,\n                \"tool_args\": inputs,\n            }\n            # Execute MCP tool call\n            async with aiohttp.ClientSession(\n                timeout=ClientTimeout(total=5 * 60, sock_connect=30)\n            ) as session:\n                async with session.post(url, json=req_body) as resp:\n                    if resp.status != httpx.codes.OK:\n                        cause_error = (\n                            f\"Status code: {resp.status}, \"\n                            f\"Response content: {await resp.text()}\"\n                        )\n                        raise CustomException(\n                            err_code=CodeEnum.MCP_REQUEST_ERROR,\n                            cause_error=cause_error,\n                        )\n\n                    res_json = json.loads(await resp.text())\n                    await span.add_info_events_async(\n                        {\"mcp_response\": json.dumps(res_json, ensure_ascii=False)}\n                    )\n\n                    # Check for errors in response\n                    if res_json.get(\"code\") != 0:\n                        msg = f\"reason {res_json.get('message')}\"\n                        span.add_error_event(msg)\n                        raise CustomException(\n                            err_code=CodeEnum.MCP_REQUEST_ERROR,\n                            err_msg=msg,\n                            cause_error=msg,\n                        )","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/workflow/engine/nodes/mcp/mcp_node.py#L78-L114","documentation":"The MCP node POSTs a JSON-RPC-ish request body to the MCP server; if the HTTP response status is not 200, it builds a cause_error string containing the status code and the raw response text and raises CustomException with MCP_REQUEST_ERROR. The err_msg is not set, so the useful detail is in cause_error.","triggerScenarios":"The HTTP call to the MCP server (mcpServerUrl or resolved from mcpServerId) returns 404 (wrong URL/path), 401/403 (auth), 500 (server crash), or 502 (gateway) instead of 200.","commonSituations":"MCP server URL mistyped or pointing at a retired endpoint; server not deployed/reachable in the cluster; missing auth headers rejected by the server; MCP service overloaded behind a gateway.","solutions":["Inspect cause_error in the node run logs for the status code and response body","Verify the MCP server URL and that the service is up (curl the endpoint directly)","Fix authentication/headers if the status is 401/403; if 5xx, check MCP server logs and retry after recovery"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"import aiohttp\nasync def mcp_reachable(url: str) -> bool:\n    try:\n        async with aiohttp.ClientSession() as s:\n            async with s.get(url, timeout=aiohttp.ClientTimeout(total=5)) as r:\n                return r.status < 500\n    except aiohttp.ClientError:\n        return False","typeGuard":null,"tryCatchPattern":"try:\n    result = await node.async_execute(variable_pool, span)\nexcept CustomException as e:\n    if e.err_code == CodeEnum.MCP_REQUEST_ERROR:\n        log.error(\"MCP HTTP failure: %s\", e.cause_error)  # status + response text\n        # 5xx: retry with backoff; 4xx: fix URL/auth","preventionTips":["Verify the MCP server URL resolves to a live service","Include required auth headers for the MCP server","Add retries with backoff for transient 5xx","Monitor MCP server availability"],"tags":["python","http","network","mcp"],"backgroundTag":"http-error-response","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}