(userFacingName: string)
| 86 | * @returns The display name without server prefix and (MCP) suffix |
| 87 | */ |
| 88 | export function extractMcpToolDisplayName(userFacingName: string): string { |
| 89 | // This is really ugly but our current Tool type doesn't make it easy to have different display names for different purposes. |
| 90 | |
| 91 | // First, remove the (MCP) suffix if present |
| 92 | let withoutSuffix = userFacingName.replace(/\s*\(MCP\)\s*$/, '') |
| 93 | |
| 94 | // Trim the result |
| 95 | withoutSuffix = withoutSuffix.trim() |
| 96 | |
| 97 | // Then, remove the server prefix (everything before " - ") |
| 98 | const dashIndex = withoutSuffix.indexOf(' - ') |
| 99 | if (dashIndex !== -1) { |
| 100 | const displayName = withoutSuffix.substring(dashIndex + 3).trim() |
| 101 | return displayName |
| 102 | } |
| 103 | |
| 104 | // If no dash found, return the string without (MCP) |
| 105 | return withoutSuffix |
| 106 | } |
| 107 |
no outgoing calls
no test coverage detected