| 58 | }, |
| 59 | |
| 60 | resolve(input: string): ToolResolution { |
| 61 | const normalized = input.toLowerCase().trim(); |
| 62 | |
| 63 | // Try exact CLI name match first |
| 64 | const exact = byCliName.get(normalized); |
| 65 | if (exact) { |
| 66 | return { tool: exact }; |
| 67 | } |
| 68 | |
| 69 | // Try kebab-case of MCP name (alias) |
| 70 | const mcpKebab = toKebabCase(normalized); |
| 71 | const aliasMatches = byMcpKebab.get(mcpKebab); |
| 72 | if (aliasMatches && aliasMatches.length === 1) { |
| 73 | return { tool: aliasMatches[0] }; |
| 74 | } |
| 75 | if (aliasMatches && aliasMatches.length > 1) { |
| 76 | return { ambiguous: aliasMatches.map((t) => t.cliName) }; |
| 77 | } |
| 78 | |
| 79 | // Try matching by MCP name directly (for underscore-style names) |
| 80 | const byMcpDirect = tools.find((t) => t.mcpName.toLowerCase() === normalized); |
| 81 | if (byMcpDirect) { |
| 82 | return { tool: byMcpDirect }; |
| 83 | } |
| 84 | |
| 85 | return { notFound: true }; |
| 86 | }, |
| 87 | }; |
| 88 | } |
| 89 | |