From e3ab9714302d5b991fa88eb4c458ef4304354a85 Mon Sep 17 00:00:00 2001 From: lyingbug Date: Fri, 20 Mar 2026 22:18:28 +0000 Subject: [PATCH] fix: use service name instead of UUID for MCP tool naming (#715) When an MCP server re-registers after long idle, a new UUID is generated, causing tool names to change and agent tool calls to fail. Switch from t.service.ID to t.service.Name so tool names remain stable across re-registrations. --- internal/agent/tools/mcp_tool.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/agent/tools/mcp_tool.go b/internal/agent/tools/mcp_tool.go index bc17b9ab..e307ce83 100644 --- a/internal/agent/tools/mcp_tool.go +++ b/internal/agent/tools/mcp_tool.go @@ -31,12 +31,12 @@ func NewMCPTool(service *types.MCPService, mcpTool *types.MCPTool, mcpManager *m } // Name returns the unique name for this tool. -// Format: mcp_{service_id}_{tool_name} to prevent tool name collision across MCP services -// (GHSA-67q9-58vj-32qx: a malicious server could otherwise register a tool that -// overwrites a legitimate one when using only service name + tool name). +// Format: mcp_{service_name}_{tool_name} to prevent tool name collision across MCP services. +// We use service.Name (human-readable, stable) instead of service.ID (UUID) so that tool +// names survive MCP server re-registrations that generate a new UUID (see #715). // Note: OpenAI API requires tool names to match ^[a-zA-Z0-9_-]+$ and max 64 chars. func (t *MCPTool) Name() string { - serviceID := sanitizeName(t.service.ID) + serviceID := sanitizeName(t.service.Name) toolName := sanitizeName(t.mcpTool.Name) name := fmt.Sprintf("mcp_%s_%s", serviceID, toolName)