fix: filter tools by disallowed_tools config during tool listing

The MCP tool listing logic only checked allowed_tools but never
filtered out tools in disallowed_tools, causing disallowed_tools
config to have no effect in the UI or API responses.

Add a filtering step in _get_tools_from_server() that uses the
existing check_allowed_or_banned_tools() method to exclude tools
matching the disallowed_tools list before returning them.

Fixes #23549
This commit is contained in:
Alvin Tang 2026-03-14 21:48:16 +08:00
parent 25ee2fb3f9
commit a90906f75a

View file

@ -1074,6 +1074,14 @@ class MCPServerManager:
else:
tools = await self._fetch_tools_with_timeout(client, server.name)
# Filter tools based on allowed_tools / disallowed_tools config
if server.allowed_tools or server.disallowed_tools:
tools = [
tool
for tool in tools
if self.check_allowed_or_banned_tools(tool.name, server)
]
prefixed_or_original_tools = self._create_prefixed_tools(
tools, server, add_prefix=add_prefix
)