feat(nimbus-mcp): add search_icons tool#1230
Conversation
Two-pass search (substring then Fuse.js fuzzy) against icon names and keywords from the icon catalog. Returns up to 20 matching icons with import paths from @commercetools/nimbus-icons. CRAFT-2136 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ntry type Remove duplicate IconResult type declarations from search-icons tool and tests, using the existing IconCatalogEntry from types.ts instead. Also removes the now-unnecessary toResult mapper. CRAFT-2136 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Avoids confusion with an upcoming tool that uses the same variable name. CRAFT-2136 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Reduce token usage by returning 5 icons per page instead of all 20 at once. Adds optional offset param and structured response metadata (totalIcons, totalResults, hasMore, hint) so LLMs can paginate when needed. Also lowers max search results from 20 to 10 since tail matches are low-signal. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…rch quality Update tests to validate paginated response shape (totalIcons, totalResults, offset, pageSize, hasMore, hint) and pagination behavior across pages. Also fix two pre-existing search quality issues exposed by the lower result cap: - Skip single-char keywords in substring matching to prevent false positives - Rank name matches above keyword matches so exact name hits aren't pushed out Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
| */ | ||
| async function searchIcons(query: string): Promise<IconCatalogEntry[]> { | ||
| const catalog = await getCatalog(); | ||
| const needle = query.toLowerCase(); |
There was a problem hiding this comment.
im sure needle means something im not familiar with yet. yes, i can see that nameLower is used further down.
There was a problem hiding this comment.
Refers to the figurative 'haystack'
There was a problem hiding this comment.
it was so random that i suspected as much. TIL
| const MIN_KEYWORD_LENGTH = 2; | ||
|
|
||
| /** Cached catalog + Fuse instance (created on first call). */ | ||
| let cachedCatalog: IconCatalog | undefined; |
There was a problem hiding this comment.
this caught my eyeball. just one.
is there a reason why someone (naming names not necessary) didn't memoize getIconCatalog() using lazyJson in the data-loader file so you wouldn't have to clean up her mess here?
valoriecarli
left a comment
There was a problem hiding this comment.
had some questions, but nothing we can get to as we continue to build this out and keep learning how to do this effectively.
Summary
search_iconsMCP tool with two-pass search (substring then Fuse.js fuzzy) against icon names and keywords@commercetools/nimbus-icons, paginated at 5 per page with anoffsetparameterIconResulttype into sharedIconCatalogEntryfromtypes.tsCloses CRAFT-2136
Test plan
pnpm test packages/nimbus-mcp/— all tests passsearch_icons("checkmark")returns CheckCircle, Check, Done with correct import pathsoffset: 5returns the next page of results🤖 Generated with Claude Code