Commit f059ca1
LiryLee
fix: prevent MCP tool name collision by prefixing with server name
When multiple MCP servers expose tools with the same name (e.g.,
`read_memory`), selecting one would inadvertently select the other
because both backend registration and the frontend-facing API used
the raw tool name without any server identifier.
Changes:
- Added `clean_tool_name()` helper: sanitizes server/tool names
to [a-zA-Z0-9_-], uses __ as separator, truncates to 64 chars max
- MCPTool.__init__: uses clean_tool_name() for tool registration
- ToolsService.get_mcp_servers: uses clean_tool_name() for API return
The actual MCP call still uses the original tool name
(self.mcp_tool.name), so server communication is unaffected.1 parent 372b9f5 commit f059ca1
2 files changed
Lines changed: 30 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
679 | 679 | | |
680 | 680 | | |
681 | 681 | | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
682 | 706 | | |
683 | 707 | | |
684 | 708 | | |
685 | 709 | | |
686 | 710 | | |
687 | 711 | | |
688 | 712 | | |
689 | | - | |
| 713 | + | |
690 | 714 | | |
691 | 715 | | |
692 | 716 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
83 | 86 | | |
84 | 87 | | |
85 | 88 | | |
| |||
0 commit comments