From 4eefe65bd4edefbbea1bef9a5a72492c823b541b Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Mon, 23 Nov 2026 16:15:19 +0100 Subject: [PATCH] fix: chats fail when an MCP server from Tether is enabled (#34728) MCP servers added in Tether have IDs with colons, and Open WebUI puts the server ID in front of every MCP tool name it offers to the model. OpenAI-compatible providers only accept letters, digits, underscores and dashes in tool names, so every chat with such a server turned on was rejected with `Invalid 'tools[0].function.name'`. The same happened for MCP servers whose admin-chosen ID has dots or spaces. Characters outside that set are now replaced with underscores, so these tools reach the model and their calls still go to the right MCP server. Names that were already valid are unchanged. Fixes #34718 --- backend/open_webui/utils/middleware.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/open_webui/utils/middleware.py b/backend/open_webui/utils/middleware.py index b2cd2db1cf..9b54886012 100644 --- a/backend/open_webui/utils/middleware.py +++ b/backend/open_webui/utils/middleware.py @@ -2760,7 +2760,7 @@ async def process_chat_payload(request, form_data, user, metadata, model): tool_function = await make_tool_function(client, tool_spec['name']) - tool_name = f'{server_id}_{tool_spec["name"]}' + tool_name = re.sub(r'[^a-zA-Z0-9_-]', '_', f'{server_id}_{tool_spec["name"]}') # Providers reject tool names over 64 characters if len(tool_name) > 64: tool_name = f'{tool_name[:55]}_{hashlib.sha256(tool_name.encode()).hexdigest()[:8]}'