diff --git a/backend/open_webui/utils/middleware.py b/backend/open_webui/utils/middleware.py index efa187a382..cc2de8e1c7 100644 --- a/backend/open_webui/utils/middleware.py +++ b/backend/open_webui/utils/middleware.py @@ -1409,11 +1409,12 @@ async def process_chat_payload(request, form_data, user, metadata, model): headers=headers if headers else None, ) - function_name_filter_list = ( - mcp_server_connection.get("config", {}) - .get("function_name_filter_list", "") - .split(",") - ) + function_name_filter_list = mcp_server_connection.get( + "config", {} + ).get("function_name_filter_list", "") + + if isinstance(function_name_filter_list, str): + function_name_filter_list = function_name_filter_list.split(",") tool_specs = await mcp_clients[server_id].list_tool_specs() for tool_spec in tool_specs: diff --git a/backend/open_webui/utils/tools.py b/backend/open_webui/utils/tools.py index 268624135d..2baff503ee 100644 --- a/backend/open_webui/utils/tools.py +++ b/backend/open_webui/utils/tools.py @@ -150,11 +150,12 @@ async def get_tools( ) specs = tool_server_data.get("specs", []) - function_name_filter_list = ( - tool_server_connection.get("config", {}) - .get("function_name_filter_list", "") - .split(",") - ) + function_name_filter_list = tool_server_connection.get( + "config", {} + ).get("function_name_filter_list", "") + + if isinstance(function_name_filter_list, str): + function_name_filter_list = function_name_filter_list.split(",") for spec in specs: function_name = spec["name"]