Repository navigation
Commit 2ba04cf
committed
fix(tools): compare stored tool names in tool name conflict checks
The tool conflict checks compared raw names. The set_custom_name_and_slug
listener stores the slug of the custom name in DbTool.name, with the
gateway prefix for a gateway tool. A name that differs from its own slug
never matched its stored row. The checks accepted duplicates in one
visibility scope. register_tool() also had no private-scope check.
Compute the stored name the same way as the listener, with slugify() or
build_gateway_tool_invocation_name(). Check it against public tools, team
tools of the same team, and private tools of the same owner.
_tool_name_scope() is the one definition of these scopes.
- register_tool() uses LIMIT 1, so legacy duplicate rows raise
ToolNameConflictError (HTTP 409) and not MultipleResultsFound
(HTTP 400).
- update_tool() checks the final stored name on a rename, a custom_name
change, or a visibility change. One helper covers tools with and
without a gateway.
- _process_tool_chunk() matches each incoming tool by its position. It
applies the conflict strategy to existing rows and to earlier tools
of the same chunk.
- _load_authorized_tool_conflicts() and _existing_tools_query() look up
stored names. The import ownership check and the late-collision check
therefore cover slug-equivalent names.
PR #6534 fixes the federation gap of the issue. A database-level unique
constraint per visibility scope needs a migration and a maintainer
decision. This change does not include it. gRPC reflection sync does not
use these checks.
Refs #6189
Signed-off-by: Waleed Khalid <wak327@gmail.com>1 parent a211ab7 commit 2ba04cf
5 files changed
Lines changed: 554 additions & 177 deletions
File tree
- mcpgateway/services
- tests
- live_gateway/e2e
- unit/mcpgateway/services
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
37 | 39 | | |
38 | 40 | | |
39 | 41 | | |
| |||
0 commit comments