From 376fd6cdbeac861e6ac1aa1be933a1b16282dfca Mon Sep 17 00:00:00 2001 From: Tarshann Washington <138724143+Tarshann@users.noreply.github.com> Date: Mon, 14 Sep 2026 01:02:47 -0700 Subject: [PATCH] fix(mcp): assign parsed response once --- litellm/proxy/_experimental/mcp_server/server.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/litellm/proxy/_experimental/mcp_server/server.py b/litellm/proxy/_experimental/mcp_server/server.py index fb0936aa602..0b3633cf54e 100644 --- a/litellm/proxy/_experimental/mcp_server/server.py +++ b/litellm/proxy/_experimental/mcp_server/server.py @@ -3794,14 +3794,15 @@ if MCP_AVAILABLE: ) -> _JSONRPCErrorEnvelopeForLogging | None: stripped_body: Final = raw_body.lstrip() if stripped_body.startswith(b"{"): - json_body: Final = stripped_body + candidate_body = stripped_body else: data_lines: Final = tuple( line.removeprefix(b"data:").lstrip() for line in raw_body.splitlines() if line.startswith(b"data:") ) if len(data_lines) != 1: return None - json_body = data_lines[0] + candidate_body = data_lines[0] + json_body: Final = candidate_body try: return _JSONRPC_ERROR_FOR_LOGGING_ADAPTER.validate_json(json_body) except ValidationError: