* Parse tool name into searchable parts. * Handles both MCP tools (mcp__server__action) and regular tools (CamelCase).
(name: string)
| 130 | * Handles both MCP tools (mcp__server__action) and regular tools (CamelCase). |
| 131 | */ |
| 132 | function parseToolName(name: string): { |
| 133 | parts: string[] |
| 134 | full: string |
| 135 | isMcp: boolean |
| 136 | } { |
| 137 | // Check if it's an MCP tool |
| 138 | if (name.startsWith('mcp__')) { |
| 139 | const withoutPrefix = name.replace(/^mcp__/, '').toLowerCase() |
| 140 | const parts = withoutPrefix.split('__').flatMap(p => p.split('_')) |
| 141 | return { |
| 142 | parts: parts.filter(Boolean), |
| 143 | full: withoutPrefix.replace(/__/g, ' ').replace(/_/g, ' '), |
| 144 | isMcp: true, |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | // Regular tool - split by CamelCase and underscores |
| 149 | const parts = name |
| 150 | .replace(/([a-z])([A-Z])/g, '$1 $2') // CamelCase to spaces |
| 151 | .replace(/_/g, ' ') |
| 152 | .toLowerCase() |
| 153 | .split(/\s+/) |
| 154 | .filter(Boolean) |
| 155 | |
| 156 | return { |
| 157 | parts, |
| 158 | full: parts.join(' '), |
| 159 | isMcp: false, |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | /** |
| 164 | * Pre-compile word-boundary regexes for all search terms. |
no outgoing calls
no test coverage detected