{"record":{"id":"bf4d54e8ace5ee06","repo":"rohitg00/ai-engineering-from-scratch","slug":"response-error-message","errorCode":null,"errorMessage":"response[\"error\"][\"message\"]","messagePattern":"response\\[\"error\"\\]\\[\"message\"\\]","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"phases/11-llm-engineering/14-model-context-protocol/code/main.py","lineNumber":308,"sourceCode":"        return {\"jsonrpc\": \"2.0\", \"id\": request_id, \"result\": result}\n\n\nclass MCPClient:\n    def __init__(self, server: MCPServer) -> None:\n        self.server = server\n        self._id = 0\n\n    def request(self, method: str, params: dict[str, Any] | None = None) -> dict[str, Any]:\n        self._id += 1\n        request_params = dict(params or {})\n        request_params[\"_meta\"] = request_metadata()\n        response = self.server.handle(\n            {\"jsonrpc\": \"2.0\", \"id\": self._id, \"method\": method, \"params\": request_params}\n        )\n        if response is None:\n            raise RuntimeError(\"request did not receive a response\")\n        if \"error\" in response:\n            raise RuntimeError(response[\"error\"][\"message\"])\n        return response[\"result\"]\n\n\nserver = MCPServer(\"demo-server\")\n\n\n@server.tool(\n    \"add\",\n    \"Add two integers and return the sum.\",\n    {\n        \"type\": \"object\",\n        \"properties\": {\"a\": {\"type\": \"integer\"}, \"b\": {\"type\": \"integer\"}},\n        \"required\": [\"a\", \"b\"],\n    },\n)\ndef add(a: int, b: int) -> dict[str, int]:\n    return {\"sum\": a + b}\n","sourceCodeStart":290,"sourceCodeEnd":326,"githubUrl":"https://github.com/rohitg00/ai-engineering-from-scratch/blob/39ea8a1c6d0b61f071226eff7ede4d4105fed820/phases/11-llm-engineering/14-model-context-protocol/code/main.py#L290-L326","documentation":"Error \"response[\"error\"][\"message\"]\" thrown in rohitg00/ai-engineering-from-scratch.","triggerScenarios":"Thrown at phases/11-llm-engineering/14-model-context-protocol/code/main.py:308 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"39ea8a1c6d0b61f071226eff7ede4d4105fed820","analyzedAt":"2026-08-26T03:13:46.626Z","schemaVersion":2},"datasetVersion":"2026-08-26T07:17:17.940Z"}