mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-10 22:41:41 +00:00
fix: strip server prefix from OpenAPI tool names before filter check
For OpenAPI-backed MCP servers (spec_path), tools are stored with already-prefixed names (e.g. "myserver-get_pet"). When filtering against disallowed_tools, the unprefixed name must be used so that entries like "get_pet" match correctly at listing time. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
a90906f75a
commit
cbe480ba87
1 changed files with 10 additions and 1 deletions
|
|
@ -1075,11 +1075,20 @@ class MCPServerManager:
|
|||
tools = await self._fetch_tools_with_timeout(client, server.name)
|
||||
|
||||
# Filter tools based on allowed_tools / disallowed_tools config
|
||||
# For OpenAPI servers (spec_path), tools already have the server
|
||||
# prefix in their name (e.g. "myserver-get_pet"). Strip it before
|
||||
# checking so that unprefixed disallowed_tools entries match.
|
||||
if server.allowed_tools or server.disallowed_tools:
|
||||
prefix = f"{server.name}-"
|
||||
tools = [
|
||||
tool
|
||||
for tool in tools
|
||||
if self.check_allowed_or_banned_tools(tool.name, server)
|
||||
if self.check_allowed_or_banned_tools(
|
||||
tool.name.removeprefix(prefix)
|
||||
if server.spec_path
|
||||
else tool.name,
|
||||
server,
|
||||
)
|
||||
]
|
||||
|
||||
prefixed_or_original_tools = self._create_prefixed_tools(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue