Elffuss BraidHub

kikocis/continue public

main · 563 BRawPermalink
1import { MCPServerStatus, MCPTool } from "..";
2export function getMCPToolName(server: MCPServerStatus, tool: MCPTool) {
3 // Replace any sequence of non-alphanumeric characters with a single underscore
4 const serverPrefix = server.name
5 .toLowerCase()
6 .replace(/[^a-z0-9]+/g, "_")
7 .replace(/^_+|_+$/g, "") // Remove leading/trailing underscores
8 .replace(/_+/g, "_"); // Replace multiple sequential underscores with single underscore
9
10 if (tool.name.startsWith(serverPrefix)) {
11 return tool.name;
12 }
13 return `${serverPrefix}_${tool.name}`;
14}