{"record":{"id":"2be3532407520c95","repo":"rohitg00/ai-engineering-from-scratch","slug":"error","errorCode":null,"errorMessage":"error","messagePattern":"error","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"certifications/claude/lessons/11-mcp-server-design-and-integration/code/main.py","lineNumber":527,"sourceCode":"            \"params\": {**request_params, \"_meta\": metadata},\n        }\n        self.next_id += 1\n        return request\n\n    def send(\n        self,\n        method: str,\n        params: dict[str, Any] | None = None,\n        *,\n        server: MCPServer | None = None,\n    ) -> tuple[dict[str, Any], dict[str, Any]]:\n        request = self.build_request(method, params)\n        response, notifications = (server or self.server).exchange(request)\n        self.notifications.extend(notifications)\n        if response is None or response.get(\"id\") != request[\"id\"]:\n            raise RuntimeError(\"invalid response correlation\")\n        if \"error\" in response:\n            raise RuntimeError(json.dumps(response[\"error\"], sort_keys=True))\n        return request, response[\"result\"]\n\n    def request(\n        self,\n        method: str,\n        params: dict[str, Any] | None = None,\n        *,\n        server: MCPServer | None = None,\n    ) -> dict[str, Any]:\n        _request, result = self.send(method, params, server=server)\n        return result\n\n    def call_with_mrtr(\n        self,\n        params: dict[str, Any],\n        *,\n        first_server: MCPServer,\n        retry_server: MCPServer,","sourceCodeStart":509,"sourceCodeEnd":545,"githubUrl":"https://github.com/rohitg00/ai-engineering-from-scratch/blob/39ea8a1c6d0b61f071226eff7ede4d4105fed820/certifications/claude/lessons/11-mcp-server-design-and-integration/code/main.py#L509-L545","documentation":"A sentinel error re-raised in MCPClient.send when the correlated JSON-RPC response carries an 'error' member instead of a 'result'. It surfaces the server-side failure (protocol error, tool failure, or bad params) to the caller of request/call_with_mrtr instead of silently returning a malformed payload.","triggerScenarios":"Thrown at certifications/claude/lessons/11-mcp-server-design-and-integration/code/main.py:527 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the response error.code and error.message to identify which JSON-RPC error the server returned","Fix the request params or method that triggered the server-side error","For transient server errors (overloaded, timeout), retry the request with the same client id sequencing"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"39ea8a1c6d0b61f071226eff7ede4d4105fed820","analyzedAt":"2026-08-26T03:13:46.626Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}