@coolicons/mcp 5.0.0-beta.2 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # @coolicons/mcp
2
2
 
3
- An MCP server for [coolicons](https://coolicons.cool). Lets a coding agent search 1220 icons in five styles and three corner radii, read an icon's SVG and get the right import, without guessing names.
3
+ <a href="https://coolicons.cool"><img src="https://raw.githubusercontent.com/krystonschwarze/coolicons/main/.github/assets/banner.png" alt="coolicons: Every icon for your next project. Free, wherever you build." width="100%"></a>
4
+
5
+ An MCP server for [coolicons](https://coolicons.cool). Lets a coding agent search 1,258 icons in five styles and three corner radii, read an icon's SVG and get the right import, without guessing names.
4
6
 
5
7
  ## Install
6
8
 
package/dist/core.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { readFileSync } from "node:fs";
2
+ import { matchIcons } from "./search.js";
2
3
 
3
4
  export const STYLES = ["line", "duocolor", "duotone", "fill", "bulk"];
4
5
  export const RADII = ["sharp", "regular", "round"];
@@ -54,38 +55,8 @@ export function checkVariant(style = "line", radius = "regular") {
54
55
  return { style, radius };
55
56
  }
56
57
 
57
- function scoreIcon(icon, terms) {
58
- let total = 0;
59
- const tokens = icon.name.split("-");
60
- const groups = icon.category.toLowerCase().split(/[^a-z0-9]+/);
61
- for (const term of terms) {
62
- let best = 0;
63
- const exact = icon.keywords.indexOf(term);
64
- const prefix = icon.keywords.findIndex((word) => word.startsWith(term));
65
- if (icon.name === term) best = 100;
66
- else if (icon.name.startsWith(term)) best = 80;
67
- else if (tokens.includes(term)) best = 70;
68
- else if (tokens.some((token) => token.startsWith(term))) best = 55;
69
- else if ((term.length > 3 || term.includes("-")) && icon.name.includes(term)) best = 40;
70
- else if (exact >= 0) best = 35 - Math.min(exact, 9);
71
- else if (groups.includes(term)) best = 30;
72
- else if (prefix >= 0) best = 25 - Math.min(prefix, 9);
73
- else if (icon.category.toLowerCase().includes(term)) best = 15;
74
- if (!best) return 0;
75
- total += best;
76
- }
77
- return total;
78
- }
79
-
80
58
  export function search(query, limit = 10) {
81
- const terms = String(query).toLowerCase().trim().split(/\s+/).filter(Boolean);
82
- if (!terms.length) return [];
83
- return iconSet()
84
- .icons.map((icon) => ({ icon, rank: scoreIcon(icon, terms) }))
85
- .filter((entry) => entry.rank)
86
- .sort((a, b) => b.rank - a.rank || a.icon.name.length - b.icon.name.length || a.icon.name.localeCompare(b.icon.name))
87
- .slice(0, limit)
88
- .map((entry) => entry.icon);
59
+ return matchIcons(iconSet().icons, query).slice(0, limit);
89
60
  }
90
61
 
91
62
  function distance(a, b) {