@iconaut/mcp 0.0.0-stage → 1.7.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Iconaut
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,52 @@
1
- # Temporary Holding Version
1
+ # @iconaut/mcp
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ An [MCP](https://modelcontextprotocol.io) server for the 1,263 free Iconaut icons. It
4
+ lets a coding agent look an icon up instead of guessing its name, and hands back the exact SVG,
5
+ the `iconaut-react` import and the shadcn/ui command.
6
+
7
+ Everything runs locally from data bundled in the package: no network, no account, no API key.
8
+
9
+ ## Set up
10
+
11
+ Claude Code:
12
+
13
+ ```bash
14
+ claude mcp add iconaut -- npx -y @iconaut/mcp
15
+ ```
16
+
17
+ Cursor, Windsurf, Claude Desktop and other clients take the same command in their MCP config:
18
+
19
+ ```json
20
+ {
21
+ "mcpServers": {
22
+ "iconaut": { "command": "npx", "args": ["-y", "@iconaut/mcp"] }
23
+ }
24
+ }
25
+ ```
26
+
27
+ ## Tools
28
+
29
+ | Tool | What it does |
30
+ |---|---|
31
+ | `search_icons` | Search by name, keyword or meaning (`"settings"`, `"arrow left"`, `"delete"`). Filter by `category` or `style`. |
32
+ | `get_icon` | One icon by name: the SVG at 16, 20 or 24px in line, solid or duo, the React import, the shadcn command and the CDN URL. |
33
+ | `list_categories` | The 27 categories and how many icons each holds. |
34
+
35
+ ## A real drawing at every size
36
+
37
+ Sizes 16, 20 and 24 are separate drawings with their own stroke weight, not one drawing scaled,
38
+ so `get_icon` takes the size the icon will be shown at:
39
+
40
+ | size | drawing | stroke |
41
+ |---|---|---|
42
+ | 16 | compact | 1.25 |
43
+ | 20 | default | 1.5 |
44
+ | 24 | default | 1.75 |
45
+
46
+ ## What is in here
47
+
48
+ The free, MIT-licensed set only: the same icons as [`iconaut-react`](https://www.npmjs.com/package/iconaut-react)
49
+ and [github.com/iconaut-design/icons](https://github.com/iconaut-design/icons), at the same
50
+ version. The Pro packs live in the [Figma plugin](https://iconaut.design).
51
+
52
+ Browse the set at [iconaut.design/icons](https://iconaut.design/icons).
package/icons.json.br ADDED
Binary file
package/package.json CHANGED
@@ -1,6 +1,45 @@
1
1
  {
2
2
  "name": "@iconaut/mcp",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.7.2",
4
+ "description": "MCP server for the free Iconaut icons: search the set, get the SVG at its native size, get the React import and shadcn command.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "bin": {
8
+ "iconaut-mcp": "./server.js"
9
+ },
10
+ "main": "./server.js",
11
+ "files": [
12
+ "server.js",
13
+ "icons.json.br",
14
+ "README.md",
15
+ "LICENSE"
16
+ ],
17
+ "engines": {
18
+ "node": ">=18"
19
+ },
20
+ "publishConfig": {
21
+ "access": "public"
22
+ },
23
+ "keywords": [
24
+ "mcp",
25
+ "model-context-protocol",
26
+ "mcp-server",
27
+ "icons",
28
+ "svg-icons",
29
+ "icon-library",
30
+ "iconaut",
31
+ "react",
32
+ "shadcn",
33
+ "claude",
34
+ "cursor",
35
+ "ai"
36
+ ],
37
+ "homepage": "https://iconaut.design",
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "git+https://github.com/iconaut-design/icons.git"
41
+ },
42
+ "bugs": {
43
+ "url": "https://github.com/iconaut-design/icons/issues"
44
+ }
45
+ }
package/server.js ADDED
@@ -0,0 +1,304 @@
1
+ #!/usr/bin/env node
2
+ // @iconaut/mcp: an MCP server over the free Iconaut icons.
3
+ //
4
+ // Hand-written, unlike the rest of this package: scripts/gen-mcp.mjs writes package.json,
5
+ // README.md, LICENSE and icons.json.br next to it, and leaves this file alone.
6
+ //
7
+ // What it is for. A coding agent asked for "a settings icon" otherwise guesses: an icon name
8
+ // that does not exist, or a lucide import in a project that uses Iconaut. These tools let it
9
+ // look the icon up instead, and hand back the exact SVG, React import and shadcn command.
10
+ //
11
+ // No dependencies on purpose. The MCP stdio transport is newline-delimited JSON-RPC 2.0, and
12
+ // the four methods a tools-only server answers (initialize, ping, tools/list, tools/call) fit
13
+ // in this file. Nothing to install means nothing to audit and nothing to go stale under it.
14
+ //
15
+ // Free set only. icons.json.br holds the 1,263 MIT icons and nothing else; the Pro icons are
16
+ // not in this package in any form, names included. scripts/mcp-verify.mjs checks that.
17
+ import { readFileSync, realpathSync } from 'node:fs';
18
+ import { brotliDecompressSync } from 'node:zlib';
19
+ import { dirname, join } from 'node:path';
20
+ import { fileURLToPath } from 'node:url';
21
+ import { createInterface } from 'node:readline';
22
+
23
+ const HERE = dirname(fileURLToPath(import.meta.url));
24
+ const PKG = JSON.parse(readFileSync(join(HERE, 'package.json'), 'utf8'));
25
+ const SITE = 'https://iconaut.design';
26
+ const CDN = 'https://cdn.jsdelivr.net/gh/iconaut-design/icons/icons';
27
+ const REACT_PKG = 'iconaut-react';
28
+
29
+ // Newest first. A client asking for one of these gets it back; anything else gets the newest,
30
+ // which the spec lets the client accept or disconnect over.
31
+ const PROTOCOLS = ['2025-11-25', '2025-06-18', '2025-03-26', '2024-11-05'];
32
+
33
+ // ── The catalog ────────────────────────────────────────────────────────────────────────────
34
+ let DATA = null;
35
+ function data() {
36
+ if (DATA) return DATA;
37
+ const raw = JSON.parse(brotliDecompressSync(readFileSync(join(HERE, 'icons.json.br'))).toString('utf8'));
38
+ const byName = new Map();
39
+ for (const i of raw.icons) {
40
+ i.nameTokens = i.name.split('-');
41
+ i.kw = i.keywords.map((k) => k.toLowerCase());
42
+ i.kwTokens = [...new Set(i.kw.flatMap((k) => k.split(/[\s-]+/)))];
43
+ byName.set(i.name, i);
44
+ }
45
+ const labels = Object.fromEntries(raw.categories.map((c) => [c.id, c.label]));
46
+ return (DATA = { ...raw, byName, labels });
47
+ }
48
+
49
+ const pascal = (n) => n.split('-').map((p) => p[0].toUpperCase() + p.slice(1)).join('');
50
+ const SUFFIX = { line: '', solid: 'Solid', duo: 'Duo' };
51
+ const component = (name, style) => pascal(name) + SUFFIX[style];
52
+ const slug = (name, style) => name + (style === 'line' ? '' : '-' + style);
53
+ const nearestSize = (n, sizes) => sizes.reduce((a, b) => (Math.abs(b - n) < Math.abs(a - n) ? b : a));
54
+
55
+ // ── Search ─────────────────────────────────────────────────────────────────────────────────
56
+ // Ranked by where the words land: the name beats a keyword, a whole word beats a prefix. Every
57
+ // query word has to match something, so "arrow left" does not return every arrow; when nothing
58
+ // matches all of them, the best partial matches come back instead of nothing.
59
+ const tokenize = (q) => String(q || '').toLowerCase().trim().split(/[\s,_/-]+/).filter(Boolean);
60
+
61
+ function scoreIcon(icon, q, words) {
62
+ let score = 0, matched = 0;
63
+ const joined = words.join('-');
64
+ if (icon.name === joined) score += 100;
65
+ else if (icon.name.startsWith(joined)) score += 40;
66
+ // Keywords are written closest-synonym first, so an exact hit early in the list is worth more:
67
+ // "house" is home's first keyword and door's seventh.
68
+ const at = icon.kw.indexOf(q);
69
+ if (at >= 0) score += 30 - Math.min(at, 10) * 2;
70
+ for (const w of words) {
71
+ let best = 0;
72
+ if (icon.nameTokens.includes(w)) best = 12;
73
+ else if (icon.nameTokens.some((t) => t.startsWith(w))) best = 7;
74
+ if (icon.kwTokens.includes(w)) best = Math.max(best, 8);
75
+ else if (w.length >= 3 && icon.kwTokens.some((t) => t.startsWith(w))) best = Math.max(best, 4);
76
+ if (!best && icon.category === w) best = 2;
77
+ if (best) matched++;
78
+ score += best;
79
+ }
80
+ return { score, matched };
81
+ }
82
+
83
+ function search({ query = '', category, style, limit = 20 }) {
84
+ const d = data();
85
+ const words = tokenize(query);
86
+ const q = words.join(' ');
87
+ const max = Math.max(1, Math.min(100, Number(limit) || 20));
88
+ let pool = d.icons;
89
+ if (category) pool = pool.filter((i) => i.category === category);
90
+ if (style) pool = pool.filter((i) => i.styles.includes(style));
91
+ if (!words.length) return { results: pool.slice(0, max), total: pool.length, partial: false };
92
+ const scored = pool.map((i) => ({ i, ...scoreIcon(i, q, words) })).filter((r) => r.score > 0);
93
+ const full = scored.filter((r) => r.matched === words.length);
94
+ const use = full.length ? full : scored;
95
+ use.sort((a, b) => b.score - a.score || b.matched - a.matched || a.i.name.length - b.i.name.length || a.i.name.localeCompare(b.i.name));
96
+ return { results: use.slice(0, max).map((r) => r.i), total: use.length, partial: !full.length };
97
+ }
98
+
99
+ // Closest names for a lookup that missed: shared words first, then edit distance.
100
+ function suggest(name) {
101
+ const d = data();
102
+ const words = tokenize(name);
103
+ const found = search({ query: words.join(' '), limit: 5 });
104
+ if (found.results.length && !found.partial) return found.results.map((i) => i.name);
105
+ const dist = (a, b) => {
106
+ const m = Array.from({ length: b.length + 1 }, (_, j) => j);
107
+ for (let i = 1; i <= a.length; i++) {
108
+ let prev = m[0]; m[0] = i;
109
+ for (let j = 1; j <= b.length; j++) {
110
+ const t = m[j];
111
+ m[j] = Math.min(m[j] + 1, m[j - 1] + 1, prev + (a[i - 1] === b[j - 1] ? 0 : 1));
112
+ prev = t;
113
+ }
114
+ }
115
+ return m[b.length];
116
+ };
117
+ return d.icons.map((i) => [i.name, dist(name, i.name)]).sort((a, b) => a[1] - b[1]).slice(0, 5).map((x) => x[0]);
118
+ }
119
+
120
+ // ── Tools ──────────────────────────────────────────────────────────────────────────────────
121
+ const STYLE_ENUM = ['line', 'solid', 'duo'];
122
+ const TOOLS = [
123
+ {
124
+ name: 'search_icons',
125
+ title: 'Search Iconaut icons',
126
+ description:
127
+ 'Search the free Iconaut icon set (MIT) by name, keyword or meaning, e.g. "settings", ' +
128
+ '"arrow left", "delete", "notification". Returns icon names ranked by relevance, with ' +
129
+ 'their category, the styles each comes in (line, solid, duo) and the React component ' +
130
+ 'names. Call this before using an icon name you have not looked up: guessed names often ' +
131
+ 'do not exist. Leave query empty and pass a category to list that category.',
132
+ inputSchema: {
133
+ type: 'object',
134
+ properties: {
135
+ query: { type: 'string', description: 'Words to search for. Empty lists everything (narrow it with category).' },
136
+ category: { type: 'string', description: 'Only icons in this category id (see list_categories).' },
137
+ style: { type: 'string', enum: STYLE_ENUM, description: 'Only icons that come in this style. Marks like arrows and check have no duo.' },
138
+ limit: { type: 'integer', minimum: 1, maximum: 100, default: 20, description: 'How many results to return.' },
139
+ },
140
+ },
141
+ annotations: { readOnlyHint: true, openWorldHint: false },
142
+ },
143
+ {
144
+ name: 'get_icon',
145
+ title: 'Get an Iconaut icon',
146
+ description:
147
+ 'Get one Iconaut icon by its exact name: the SVG source at a native size, the iconaut-react ' +
148
+ 'import, the shadcn/ui registry command and the CDN URL. Sizes 16, 20 and 24 are separate ' +
149
+ 'drawings with their own stroke weight, so ask for the size the icon will be shown at. ' +
150
+ 'Colors come from currentColor.',
151
+ inputSchema: {
152
+ type: 'object',
153
+ properties: {
154
+ name: { type: 'string', description: 'Exact icon name, e.g. "settings" or "arrow-left". Find it with search_icons.' },
155
+ style: { type: 'string', enum: STYLE_ENUM, default: 'line', description: 'line (stroked), solid (filled) or duo (25% tint under the line).' },
156
+ size: { type: 'integer', default: 24, description: 'Pixel size. 16, 20 and 24 are native drawings; any other value returns the nearest one.' },
157
+ },
158
+ required: ['name'],
159
+ },
160
+ annotations: { readOnlyHint: true, openWorldHint: false },
161
+ },
162
+ {
163
+ name: 'list_categories',
164
+ title: 'List Iconaut categories',
165
+ description: 'List the categories of the free Iconaut icon set, with how many icons each holds.',
166
+ inputSchema: { type: 'object', properties: {} },
167
+ annotations: { readOnlyHint: true, openWorldHint: false },
168
+ },
169
+ ];
170
+
171
+ class ToolError extends Error {}
172
+
173
+ const line = (i) =>
174
+ `- ${i.name} (${i.category}; ${i.styles.join(', ')}) → ${i.styles.map((s) => component(i.name, s)).join(', ')}` +
175
+ (i.keywords.length ? `\n keywords: ${i.keywords.slice(0, 8).join(', ')}` : '');
176
+
177
+ const handlers = {
178
+ search_icons(args) {
179
+ const d = data();
180
+ if (args.style && !STYLE_ENUM.includes(args.style)) throw new ToolError(`style must be one of ${STYLE_ENUM.join(', ')}`);
181
+ if (args.category && !d.labels[args.category]) {
182
+ throw new ToolError(`No category "${args.category}". Categories: ${Object.keys(d.labels).join(', ')}`);
183
+ }
184
+ const { results, total, partial } = search(args);
185
+ if (!results.length) {
186
+ return `No Iconaut icon matches "${args.query || ''}". Try a broader or different word (e.g. "delete" instead of "remove-item"), or list_categories.`;
187
+ }
188
+ const head = partial
189
+ ? `No icon matches every word of "${args.query}"; the closest ${results.length} of ${total}:`
190
+ : `${results.length} of ${total} icon${total === 1 ? '' : 's'}${args.query ? ` for "${args.query}"` : ''}:`;
191
+ return `${head}\n${results.map(line).join('\n')}\n\nUse get_icon with a name for its SVG and import.`;
192
+ },
193
+
194
+ get_icon(args) {
195
+ const d = data();
196
+ const name = String(args.name || '').trim().toLowerCase();
197
+ if (!name) throw new ToolError('name is required.');
198
+ const icon = d.byName.get(name);
199
+ if (!icon) {
200
+ throw new ToolError(`No free Iconaut icon is named "${name}". Closest: ${suggest(name).join(', ')}.`);
201
+ }
202
+ const style = args.style || 'line';
203
+ if (!STYLE_ENUM.includes(style)) throw new ToolError(`style must be one of ${STYLE_ENUM.join(', ')}`);
204
+ if (!icon.styles.includes(style)) {
205
+ throw new ToolError(`"${name}" has no ${style} style; it comes in ${icon.styles.join(' and ')}.`);
206
+ }
207
+ const asked = args.size == null ? 24 : Number(args.size);
208
+ if (!Number.isFinite(asked) || asked <= 0) throw new ToolError('size must be a positive number.');
209
+ const size = d.sizes.includes(asked) ? asked : nearestSize(asked, d.sizes);
210
+ const svg = icon.svg[style][size].trimEnd();
211
+ const comp = component(name, style);
212
+ const tok = d.sizeTokens[size];
213
+ return [
214
+ `${name} · ${style} · ${size}px (${tok.tier} drawing, stroke ${tok.stroke}) · category ${icon.category}`,
215
+ asked !== size ? `${asked}px is not a native size; this is the ${size}px drawing. Render it at ${asked}px by changing width and height.` : null,
216
+ '',
217
+ 'SVG:',
218
+ svg,
219
+ '',
220
+ 'React (npm i iconaut-react):',
221
+ `import { ${comp} } from "${REACT_PKG}";`,
222
+ `<${comp} size={${asked}} />`,
223
+ `Per-icon import: import ${comp} from "${REACT_PKG}/${slug(name, style)}";`,
224
+ '',
225
+ 'shadcn/ui (copies the component into your project):',
226
+ `npx shadcn@latest add @iconaut/${slug(name, style)}`,
227
+ '',
228
+ `CDN: ${CDN}/${icon.category}/${name}/${size}/${style}.svg`,
229
+ `Page: ${SITE}/icon/${name}`,
230
+ style === 'duo' ? '\nDuo: the tint is the .secondary path (fill-opacity 0.25), the line is g.primary; style either with CSS.' : null,
231
+ ].filter((x) => x !== null).join('\n');
232
+ },
233
+
234
+ list_categories() {
235
+ const d = data();
236
+ const counts = {};
237
+ for (const i of d.icons) counts[i.category] = (counts[i.category] || 0) + 1;
238
+ return `${d.icons.length} free icons in ${d.categories.length} categories:\n` +
239
+ d.categories.map((c) => `- ${c.id} (${c.label}): ${counts[c.id] || 0}`).join('\n');
240
+ },
241
+ };
242
+
243
+ // ── JSON-RPC over stdio ────────────────────────────────────────────────────────────────────
244
+ const send = (msg) => process.stdout.write(JSON.stringify({ jsonrpc: '2.0', ...msg }) + '\n');
245
+ const reply = (id, result) => send({ id, result });
246
+ const fail = (id, code, message) => send({ id, error: { code, message } });
247
+
248
+ function handle(msg) {
249
+ if (!msg || typeof msg !== 'object' || msg.jsonrpc !== '2.0' || typeof msg.method !== 'string') {
250
+ if (msg && msg.id !== undefined && msg.method === undefined) return; // a response to us; we send no requests
251
+ return fail(msg && msg.id !== undefined ? msg.id : null, -32600, 'Invalid Request');
252
+ }
253
+ const { id, method, params = {} } = msg;
254
+ const isNotification = id === undefined;
255
+ if (isNotification) return; // notifications/initialized, notifications/cancelled: nothing to do
256
+
257
+ switch (method) {
258
+ case 'initialize': {
259
+ const v = PROTOCOLS.includes(params.protocolVersion) ? params.protocolVersion : PROTOCOLS[0];
260
+ return reply(id, {
261
+ protocolVersion: v,
262
+ capabilities: { tools: { listChanged: false } },
263
+ serverInfo: { name: 'iconaut', title: 'Iconaut icons', version: PKG.version },
264
+ instructions:
265
+ 'Iconaut is an icon set in line, solid and duotone on a 24px grid, with separate drawings at 16, 20 and 24px. ' +
266
+ 'This server covers the free MIT set. Look icons up with search_icons before naming one, then use get_icon ' +
267
+ 'for the SVG or the iconaut-react import. Do not invent icon names.',
268
+ });
269
+ }
270
+ case 'ping':
271
+ return reply(id, {});
272
+ case 'tools/list':
273
+ return reply(id, { tools: TOOLS });
274
+ case 'tools/call': {
275
+ const fn = handlers[params.name];
276
+ if (!fn) return fail(id, -32602, `Unknown tool: ${params.name}`);
277
+ try {
278
+ const text = fn(params.arguments || {});
279
+ return reply(id, { content: [{ type: 'text', text }] });
280
+ } catch (e) {
281
+ if (e instanceof ToolError) return reply(id, { content: [{ type: 'text', text: e.message }], isError: true });
282
+ process.stderr.write(`iconaut-mcp: ${e.stack || e}\n`);
283
+ return fail(id, -32603, 'Internal error');
284
+ }
285
+ }
286
+ default:
287
+ return fail(id, -32601, `Method not found: ${method}`);
288
+ }
289
+ }
290
+
291
+ export { handlers, search, TOOLS, PROTOCOLS };
292
+
293
+ // Run as a server unless imported (the verifier imports the handlers directly as well).
294
+ if (process.argv[1] && fileURLToPath(import.meta.url) === realpathSync(process.argv[1])) {
295
+ const rl = createInterface({ input: process.stdin, crlfDelay: Infinity });
296
+ rl.on('line', (l) => {
297
+ if (!l.trim()) return;
298
+ let msg;
299
+ try { msg = JSON.parse(l); } catch { return fail(null, -32700, 'Parse error'); }
300
+ if (Array.isArray(msg)) return fail(null, -32600, 'Batches are not supported');
301
+ handle(msg);
302
+ });
303
+ rl.on('close', () => process.exit(0));
304
+ }