feat: friendly display for MCP tool names in frontend (#715)

- Format MCP tool names from "mcp_my_server_search_docs" to
  "My Server Search Docs" in the agent stream UI
- Apply same formatting in sanitizeForDisplay for inline text
- Update tool-icons.ts getToolDisplayName with MCP support
This commit is contained in:
lyingbug
2026-03-20 22:35:11 +00:00
committed by lyingbug
parent da9f7b43b6
commit 28b3f1b9dd
2 changed files with 47 additions and 2 deletions
+9 -1
View File
@@ -69,6 +69,14 @@ const toolDisplayNameKeys: Record<string, string> = {
// Get tool display name (user-friendly, localized)
export function getToolDisplayName(toolName: string): string {
const key = toolDisplayNameKeys[toolName];
return key ? t(key) : toolName;
if (key) return t(key);
// Format MCP tool names: "mcp_service_tool" → "Service Tool"
if (toolName.startsWith('mcp_')) {
const parts = toolName.slice(4).split('_');
return parts.map(p => p.charAt(0).toUpperCase() + p.slice(1)).join(' ');
}
return toolName;
}