From 217766ed0f53bde167cb80b115f7eb79664ffe5a Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Tue, 20 Oct 2026 21:46:02 +0200 Subject: [PATCH] fix: MCP list results from FastMCP servers reach the model twice (#32726) When a tool on a server built with the standalone FastMCP package returned a list, the model got the list twice, once as plain text and once as structured data, so every list result cost two to three times the tokens. That package sends the whole list as a single piece of text, a format Open WebUI did not recognise as a duplicate. The list now reaches the model once, and structured data that the text does not already contain is still passed along. Fixes #32719 --- backend/open_webui/utils/mcp/client.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/backend/open_webui/utils/mcp/client.py b/backend/open_webui/utils/mcp/client.py index cd5e7b301c..09fcacfe7e 100644 --- a/backend/open_webui/utils/mcp/client.py +++ b/backend/open_webui/utils/mcp/client.py @@ -219,6 +219,9 @@ class MCPClient: # FastMCP wraps scalar/list results while keeping their original text blocks. values = structured_content.get('result') + # The standalone fastmcp package sends the whole list as one text block. + if structured_content.keys() == {'result'} and text_jsons == [JSONCodec.dumps(values, sort_keys=True)]: + return result_content values = values if isinstance(values, list) else [values] if ( structured_content.keys() == {'result'}