Repository navigation
fix(mcp): use a toolset row's stored tool name as written - #34559
Conversation
Greptile SummaryThe PR makes toolset permission resolution preserve each stored native tool name verbatim and updates regression coverage for names that resemble server wire prefixes. Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains in the fix for the previously reported ambiguous tool-name resolution.
|
| Filename | Overview |
|---|---|
| litellm/proxy/_experimental/mcp_server/mcp_server_manager.py | Removes stored-name prefix normalization so each toolset row resolves only to the exact server-scoped tool name selected by the administrator. |
| tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_toolset_scope.py | Updates prefix-resolution tests and verifies that a prefix-like native name grants only the selected tool rather than its stripped sibling. |
Reviews (3): Last reviewed commit: "fix(mcp): use a toolset row's stored too..." | Re-trigger Greptile
PR overviewAll previously flagged issues have been addressed. No open security concerns remain on this pull request. Security reviewNo open security issues remain on this pull request. Fixed/addressed: 1 · PR risk: 0/10 |
94efe3a to
31caaec
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
bugbot run |
A toolset row is {server_id, tool_name}. The server is already identified by
server_id, so the stored name is the tool's own name and there is nothing for a
prefix to disambiguate. Resolution nevertheless reduced the stored name by the
server's wire prefix, which is a guess about a string that carries no such
marker.
The wire prefix is added on the way out and is not part of any tool's identity,
so when a native tool name happens to begin with it the guess renamed the tool:
a row for greyhound_internal_events on a server prefixed greyhound resolved to
internal_events. That is a different tool on the same server, so the selected
tool disappeared from /toolset/<name>/mcp and an unselected sibling was served,
and executed, under the selected tool's wire name. Toolsets are the tool-level
permission boundary, so the row granted access to something never selected.
Match the stored name as written and keep stripping the prefix off the live name
only. This is the only producer that rewrote allowlist values; every other one
stores what the admin typed, so the tools/list filter, the tools/call permission
check, the REST listing and the Responses API path are all corrected without
touching them.
A row that stores an already-prefixed name no longer resolves. Such a row names
a tool that does not exist on the server, and the dashboard has never written
one; it was only ever accepted because of the guess this removes.
31caaec to
3489e65
Compare
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
1 issue from previous review remains unresolved.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 3489e65. Configure here.

TLDR
Problem this solves:
/toolset/<name>/mcpand an unselected sibling was served, and executed, under the selected tool's wire nameMCP_TOOL_PREFIX_SEPARATOR, so it reaches the default-separator too: a server aliaseddeepwikiserving a nativedeepwiki-contentsreduces tocontentstools/liststill returned the expected count under the expected nameHow it solves it:
server_id, so the storedtool_nameis the tool's own name and is matched as written; only the live name coming off the server still has the wire prefix strippedRelevant issues
resolve_toolset_tool_permissions, the single producer of the allowlist, so the MCPtools/listfilter, thetools/callpermission check, the REST listing and the Responses API path are all corrected without touching themLinear ticket
LIT-3419
Not marked as auto-closing: the reported deployment's effective
MCP_TOOL_PREFIX_SEPARATORhas not been confirmed yet, and the dashboard renders the prefix with a hardcoded-(MCPToolsetTableColumns.tsx), so the reporter's screenshot cannot reveal it. This diff fixes the defect described in the ticket; whether it is the whole of what that deployment hit needs the env var plus the rawLiteLLM_MCPToolsetTablerow from the running container.Pre-Submission checklist
osv-scanis red, and it is red identically on every open PR checked (34586, 34588, 34589, 34590, 34591, 34592), so it is repo-wide and not this diffScreenshots / Proof of Fix
Live proxy on
127.0.0.1:4419against a real streamable-HTTP MCP upstream on a server prefixedgreyhound, exposing two native tools:inspect_eventsandgreyhound_inspect_events. The second name is what triggers the bug, since it begins with the server's own prefix.Steps 1 to 5 run with
MCP_TOOL_PREFIX_SEPARATOR=_, which is why the wire names below readgreyhound_greyhound_inspect_events. Under the default-the same row lists asgreyhound-greyhound_inspect_events; step 6 covers that separator._greyhound_inspect_events, as the dashboard writes itNote that the count and the displayed name are both correct here. Nothing on the listing surface indicates a problem, which is why this reads as working and is why the defect is an authorization one rather than a visibility one.
This row is unregressed on
-becausegreyhound_inspect_eventsdoes not start withgreyhound-, so the old reduction was already a no-op for it. The default separator is not immune in general:strip_known_server_prefixstrips{known_prefix}{separator}for any of the server's registered prefixes, so a native name such asdeepwiki-contentson a server aliaseddeepwikiwas reduced tocontentson stock defaults.This is acceptable because the dashboard picker reads the REST listing with
add_prefix=Falseand therefore only ever persists bare native names, so it cannot create such a row.Type
🐛 Bug Fix
Changes
resolve_toolset_tool_permissionsusestool_nameas stored instead of reducing it by the server's wire prefix, which also drops the per-row server lookup and thestrip_known_server_prefiximportserver_id, so the stored name is the tool's own name and the wire prefix is never treated as part of ittest_mcp_toolset_scope.pyaround the new contract: the stored name survives verbatim, a name that looks like its own server prefix still resolves end to end through the listing filter, and the unselected sibling is not reachableQA runbook
Point an MCP client at
/toolset/<name>/mcpwith a key granted that toolset. Add a tool through the dashboard whose native name begins with the server's alias followed by the configuredMCP_TOOL_PREFIX_SEPARATOR, and confirmtools/listoffers it,tools/callreaches the upstream function of that name, and a sibling tool that was not added is refused. Repeat with an ordinary tool name and confirm it is unchanged. Check the sibling explicitly rather than the listed count, since the pre-fix behavior returns the correct count under the correct name.