continue-custom/core/tools/mcpToolName.ts
Dallin Romney a7a5351b9c
feat: limited MCP App support (#10132)
* feat: MCP apps part 1

* feat: MCP app support part 3

* chore: cleanup PR

* chore: clean up mcp ui app types

* fix: address cubic feedback
2026-02-05 19:07:44 -08:00

18 lines
702 B
TypeScript

import { MCPServerStatus, MCPTool } from "..";
export function getMCPToolName(server: MCPServerStatus, tool: MCPTool) {
return getToolNameFromMCPServer(server.name, tool.name);
}
export function getToolNameFromMCPServer(serverName: string, toolName: string) {
// Replace any sequence of non-alphanumeric characters with a single underscore
const serverPrefix = serverName
.toLowerCase()
.replace(/[^a-z0-9]+/g, "_")
.replace(/^_+|_+$/g, "") // Remove leading/trailing underscores
.replace(/_+/g, "_"); // Replace multiple sequential underscores with single underscore
if (toolName.startsWith(serverPrefix)) {
return toolName;
}
return `${serverPrefix}_${toolName}`;
}