From fc021eea76ef7cfc960a7ebbf6daae2c34d5c04a Mon Sep 17 00:00:00 2001 From: Henry Mao <1828968+calclavia@users.noreply.github.com> Date: Thu, 6 Mar 2025 20:12:51 +0800 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Marcelo Trylesinski --- src/mcp/client/websocket.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/mcp/client/websocket.py b/src/mcp/client/websocket.py index 7e60104..228bfc6 100644 --- a/src/mcp/client/websocket.py +++ b/src/mcp/client/websocket.py @@ -59,8 +59,7 @@ async def websocket_client( try: async for raw_text in ws: try: - data = json.loads(raw_text) - message = types.JSONRPCMessage.model_validate(data) + message = types.JSONRPCMessage.model_validate_json(raw_text) await read_stream_send.send(message) except Exception as exc: # If JSON parse or model validation fails, send the exception