mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-10 22:41:41 +00:00
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:
parent
25ee2fb3f9
commit
a90906f75a
1 changed files with 8 additions and 0 deletions
|
|
@ -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
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue