@lineandstone/icons-mcp 0.0.0-stage → 0.2.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/LICENSE ADDED
@@ -0,0 +1,32 @@
1
+ This package contains two kinds of material under two licences.
2
+
3
+ 1. Code (bin/, scripts/, test/): MIT License
4
+
5
+ Copyright (c) 2026 LINE & STONE (Pin Huang)
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in all
15
+ copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ SOFTWARE.
24
+
25
+ 2. Icons and icon data (data/): NOT MIT.
26
+ - The 100 free icons in data/free.json are licensed under LICENSE-ICONS-FREE.txt
27
+ (free for personal and commercial projects, credit required, no resale or
28
+ redistribution as icons, no logos, no AI training).
29
+ - data/index.json lists names, categories and keywords of the full set so
30
+ your assistant can find icons; it contains no paid icon artwork.
31
+ - Paid icons are never included in this package. When you point LS_ICONS_DIR
32
+ at your own LINE & STONE download, they stay under the licence you bought.
@@ -0,0 +1,43 @@
1
+ LINE & STONE Icons - Free License
2
+ Version 1.0 - effective 2026-11-28
3
+
4
+ This license is between you and Pin Huang, an independent designer based in Shanghai, China,
5
+ trading as LINE & STONE ("we"). It covers the 100 icons in this free download ("the Icons").
6
+ By downloading or using the Icons you accept these terms.
7
+
8
+ 1. What you can do
9
+ - Use the Icons in unlimited personal and commercial projects: websites, apps, software,
10
+ presentations, documents, print, video and merchandise, as long as the Icons are not the
11
+ main design of the product.
12
+ - Modify, recolor, resize and combine them, and use them in work you make for clients.
13
+ - Ship them inside your compiled or bundled software, and include the specific icons your
14
+ project uses in its public source code.
15
+
16
+ 2. Attribution (required)
17
+ Credit LINE & STONE where your project lists credits, or in its about page, footer, README or
18
+ documentation: "Icons by LINE & STONE - lineandstoneco.com". A link is appreciated.
19
+ Buying any paid LINE & STONE Icons license removes this requirement.
20
+
21
+ 3. What you cannot do
22
+ - Resell, share, sublicense or redistribute the Icons as icons, on their own or as part of an
23
+ icon pack, icon font, component library, design system or asset collection, free or paid,
24
+ original or modified. Link to lineandstoneco.com instead.
25
+ - Use the Icons, or anything made mainly from them, in a logo, trademark or brand mark.
26
+ - Use the Icons to train, fine-tune or evaluate machine-learning models, or include them in
27
+ datasets. (Using an AI assistant to build your own project is not training.)
28
+ - Remove this license from the download.
29
+
30
+ 4. Ownership
31
+ We keep all rights in the Icons. You receive a license to use them, not ownership.
32
+
33
+ 5. Ending the license
34
+ If you break these terms, the license ends automatically and you must stop using the Icons
35
+ in new work. Work you finished while you followed these terms may stay in use.
36
+
37
+ 6. No warranty
38
+ The Icons are provided "as is", without warranties of any kind. To the extent the law allows,
39
+ we are not liable for any loss arising from their use. Nothing here limits rights you have
40
+ under the consumer law that applies to you.
41
+
42
+ 7. Contact
43
+ lineandstoneco@gmail.com - https://lineandstoneco.com/license/
package/README.md CHANGED
@@ -1,3 +1,67 @@
1
- # Temporary Holding Version
1
+ # LINE & STONE Icons — MCP server
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
+ Let your AI coding assistant find the right icon by meaning and insert a real one — no hand-drawn SVG, no guessing names.
4
+
5
+ Ask *"add a pause button to each agent card"* and your assistant searches LINE & STONE, picks `agent-pause`, and pastes the SVG (or `<LsAgentPause />` if you use our React / Vue package).
6
+
7
+ - **Line icons on one 24 px grid**, round caps and joins, in **1, 1.25 and 1.5 px** strokes.
8
+ - **Search by meaning**: names, natural English titles and keywords for every icon.
9
+ - **100 free icons** work right away, no account, no API key.
10
+ - **The full set** (1,877 icons in 17 categories, including AI & Agents and Oriental Living) unlocks automatically from the download you already bought — locally, offline.
11
+ - Works with Cursor, Claude Code, Claude Desktop, VS Code (Copilot agent mode), Windsurf and any MCP client.
12
+
13
+ ## Install (one click)
14
+
15
+ | App | How |
16
+ |---|---|
17
+ | **Claude Desktop** | Download [lineandstone-icons.mcpb](https://github.com/lineandstone/icons-mcp/releases/latest/download/lineandstone-icons.mcpb) and double-click it. Nothing else to install. |
18
+ | **Cursor** | [Add to Cursor](cursor://anysphere.cursor-deeplink/mcp/install?name=lineandstone-icons&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBsaW5lYW5kc3RvbmUvaWNvbnMtbWNwIl19) |
19
+ | **VS Code** (Copilot agent mode) | [Install in VS Code](https://vscode.dev/redirect?url=vscode%3Amcp%2Finstall%3F%257B%2522name%2522%253A%2522lineandstone-icons%2522%252C%2522command%2522%253A%2522npx%2522%252C%2522args%2522%253A%255B%2522-y%2522%252C%2522%2540lineandstone%252Ficons-mcp%2522%255D%257D) |
20
+ | **Claude Code** | `claude mcp add lineandstone-icons -- npx -y @lineandstone/icons-mcp` |
21
+ | **Every app at once** | In a terminal: `npx -y @lineandstone/icons-mcp setup` — adds the tool to Cursor, Claude Code, Claude Desktop, Windsurf and VS Code, whichever you have. |
22
+
23
+ Cursor, VS Code, Claude Code and `setup` need [Node.js](https://nodejs.org) 18 or later. Claude Desktop does not.
24
+
25
+ Or just tell your assistant: *"Install the LINE & STONE icons MCP server: run `npx -y @lineandstone/icons-mcp setup`."*
26
+
27
+ <details><summary>Manual config</summary>
28
+
29
+ ```json
30
+ {
31
+ "mcpServers": {
32
+ "lineandstone-icons": { "command": "npx", "args": ["-y", "@lineandstone/icons-mcp"] }
33
+ }
34
+ }
35
+ ```
36
+ Cursor: `~/.cursor/mcp.json` · Claude Desktop: `claude_desktop_config.json` · Windsurf: `~/.codeium/windsurf/mcp_config.json`. VS Code uses `"servers"` instead of `"mcpServers"` and adds `"type": "stdio"`.
37
+ </details>
38
+
39
+ ## Unlock the full set (buyers): nothing to set up
40
+
41
+ Keep your LINE & STONE download in **Downloads** (or on the Desktop) — the `.zip` as it arrived, or the unzipped folder, any tier. The tool finds it the first time your assistant asks for an icon. When you download a newer version, it switches to the newest one.
42
+
43
+ Keep it somewhere else? Run `npx -y @lineandstone/icons-mcp setup /path/to/download`, choose the folder in Claude Desktop's extension settings, or set `LS_ICONS_DIR` yourself.
44
+
45
+ Not unlocking? Ask your assistant *"why are LINE & STONE icons locked?"* — the tool tells it where it looked and what to do. Or run `npx -y @lineandstone/icons-mcp --check`.
46
+
47
+ Icons are read from your own disk. Nothing is uploaded, and the tool never contacts our servers. On macOS your app may ask once for access to Downloads; allow it so the tool can see your download.
48
+
49
+ **Team / Dev:** if `@lineandstone/icons-react` or `@lineandstone/icons-vue` is in your project's `package.json`, the tool returns component code (`<LsAgentPause size={20} strokeWidth={1} />`) instead of inline SVG.
50
+
51
+ ## What your assistant can do
52
+
53
+ | Tool | What it does |
54
+ |---|---|
55
+ | `search_icons` | Find icons by meaning ("checkout basket", "low battery", "stop the agent"); shows whether each is free, licensed or locked |
56
+ | `get_icon` | Return one icon as SVG (1 / 1.25 / 1.5 px, any size) or React / Vue usage |
57
+ | `list_categories` | List categories and how many icons you can use |
58
+
59
+ Locked icons return a preview and a link instead of artwork, so your assistant won't fake one.
60
+
61
+ ## Licences
62
+
63
+ - **Code**: MIT (see `LICENSE`).
64
+ - **Free icons**: free for personal and commercial projects, **credit required** — add `Icons by LINE & STONE - lineandstoneco.com` to your README or credits. No resale or redistribution as icons, no logos, no AI training. Full terms: `LICENSE-ICONS-FREE.txt`.
65
+ - **Paid icons**: never shipped in this package; they stay under the licence you bought. Get the full set at [lineandstoneco.com](https://lineandstoneco.com/pricing/?utm_source=github&utm_medium=readme&utm_campaign=icons-mcp).
66
+
67
+ LINE & STONE — From stone to work. · lineandstoneco@gmail.com
package/bin/locate.js ADDED
@@ -0,0 +1,120 @@
1
+ // Finds the buyer's own LINE & STONE download on this computer, unzipped folder or the .zip itself.
2
+ // Everything stays local: we only list folder names and read SVG files; nothing is uploaded.
3
+ import { readdirSync, statSync, openSync, readSync, fstatSync, readFileSync } from 'node:fs';
4
+ import { join, resolve, basename } from 'node:path';
5
+ import { homedir } from 'node:os';
6
+ import { inflateRawSync } from 'node:zlib';
7
+
8
+ const HOME = homedir();
9
+ const KIT = /^line-?(and|&)?-?stone[-_ ]?icons[-_ ]?(basic|pro|team)/i; // lineandstone-icons-pro-v1.1.0[.zip], "… 2", "(1)"
10
+ const BRAND = /line.?(and|&).?stone/i;
11
+ const SVG = /(^|\/)svg\/1px\/([^/]+)\/([^/]+)\.svg$/;
12
+
13
+ // Where browsers put downloads. On macOS each folder may ask the user for permission once,
14
+ // so the background scan stays in Downloads and Desktop; `setup` (run by the user) looks further.
15
+ export function searchDirs(wide = false) {
16
+ const d = [join(HOME, 'Downloads'), join(HOME, 'Desktop')];
17
+ if (wide || process.platform !== 'darwin') d.push(join(HOME, 'Documents'));
18
+ if (process.platform === 'win32') for (const x of ['Downloads', 'Desktop', 'Documents']) d.push(join(HOME, 'OneDrive', x));
19
+ d.push(join(HOME, '.lineandstone'), process.cwd());
20
+ return [...new Set(d)];
21
+ }
22
+
23
+ // ---------- tiny zip reader (stored / deflate, no zip64; our kits are < 100 MB) ----------
24
+ function openZip(file) {
25
+ const fd = openSync(file, 'r'), size = fstatSync(fd).size;
26
+ const tl = Math.min(size, 65557), tail = Buffer.alloc(tl);
27
+ readSync(fd, tail, 0, tl, size - tl);
28
+ let e = -1;
29
+ for (let i = tl - 22; i >= 0; i--) if (tail.readUInt32LE(i) === 0x06054b50) { e = i; break; }
30
+ if (e < 0) throw new Error('not a zip');
31
+ const n = tail.readUInt16LE(e + 10), cs = tail.readUInt32LE(e + 12), co = tail.readUInt32LE(e + 16);
32
+ const cd = Buffer.alloc(cs); readSync(fd, cd, 0, cs, co);
33
+ const entries = new Map();
34
+ for (let k = 0, p = 0; k < n && cd.readUInt32LE(p) === 0x02014b50; k++) {
35
+ const nl = cd.readUInt16LE(p + 28), xl = cd.readUInt16LE(p + 30), cl = cd.readUInt16LE(p + 32);
36
+ entries.set(cd.toString('utf8', p + 46, p + 46 + nl), { m: cd.readUInt16LE(p + 10), cs: cd.readUInt32LE(p + 20), off: cd.readUInt32LE(p + 42) });
37
+ p += 46 + nl + xl + cl;
38
+ }
39
+ const read = (name) => {
40
+ const en = entries.get(name); if (!en) return null;
41
+ const h = Buffer.alloc(30); readSync(fd, h, 0, 30, en.off);
42
+ const d = Buffer.alloc(en.cs); readSync(fd, d, 0, en.cs, en.off + 30 + h.readUInt16LE(26) + h.readUInt16LE(28));
43
+ return (en.m === 8 ? inflateRawSync(d) : d).toString('utf8');
44
+ };
45
+ return { entries, read };
46
+ }
47
+
48
+ // A source maps icon name -> category and can read one SVG at a given stroke weight.
49
+ function fromZip(file) {
50
+ const z = openZip(file), owned = new Map(); let prefix = null;
51
+ for (const name of z.entries.keys()) {
52
+ const m = name.match(SVG); if (!m) continue;
53
+ const pre = name.slice(0, name.length - m[0].length + m[1].length);
54
+ if (prefix === null) prefix = pre; else if (pre !== prefix) continue;
55
+ owned.set(m[3], m[2]);
56
+ }
57
+ if (!owned.size) return null;
58
+ return { kind: 'zip', path: file, owned, read: (n, w) => z.read(`${prefix}svg/${w}px/${owned.get(n)}/${n}.svg`) };
59
+ }
60
+ function fromDir(dir) {
61
+ const cands = [dir, join(dir, '..')];
62
+ try { for (const x of readdirSync(dir)) cands.push(join(dir, x)); } catch { return null; }
63
+ for (const c of cands) {
64
+ const root = join(c, 'svg');
65
+ try { if (!statSync(join(root, '1px')).isDirectory()) continue; } catch { continue; }
66
+ const owned = new Map();
67
+ for (const cat of readdirSync(join(root, '1px'))) {
68
+ let files = []; try { files = readdirSync(join(root, '1px', cat)); } catch { continue; }
69
+ for (const f of files) if (f.endsWith('.svg')) owned.set(f.slice(0, -4), cat);
70
+ }
71
+ if (owned.size) return { kind: 'folder', path: resolve(c), owned, read: (n, w) => readFileSync(join(root, w + 'px', owned.get(n), n + '.svg'), 'utf8') };
72
+ }
73
+ return null;
74
+ }
75
+ export function openSource(p) {
76
+ try {
77
+ const st = statSync(p);
78
+ return st.isDirectory() ? fromDir(p) : /\.zip$/i.test(p) ? fromZip(p) : null;
79
+ } catch { return null; }
80
+ }
81
+
82
+ const ver = (s) => (s.match(/v?(\d+)\.(\d+)\.(\d+)/) || [0, 0, 0, 0]).slice(1).map(Number);
83
+ const cmpVer = (a, b) => { for (let i = 0; i < 3; i++) if (a[i] !== b[i]) return b[i] - a[i]; return 0; };
84
+ const TIER = { team: 3, pro: 2, basic: 1 };
85
+
86
+ // Every LINE & STONE kit we can see in the given folders (one level deep, or two inside a "LINE & STONE" folder).
87
+ export function findKits(dirs) {
88
+ const out = [];
89
+ const look = (dir, depth) => {
90
+ let names = []; try { names = readdirSync(dir); } catch { return; }
91
+ for (const name of names) {
92
+ const p = join(dir, name);
93
+ if (KIT.test(name)) { let m = 0; try { m = statSync(p).mtimeMs; } catch {} out.push({ path: p, name, v: ver(name), zip: /\.zip$/i.test(name), tier: TIER[(name.match(/basic|pro|team/i) || [''])[0].toLowerCase()] || 0, m }); }
94
+ else if (depth === 0 && BRAND.test(name)) look(p, 1);
95
+ }
96
+ };
97
+ for (const d of dirs) look(d, 0);
98
+ // newest version first, then unzipped folder before zip, then Team > Pro > Basic, then most recent
99
+ return out.sort((a, b) => cmpVer(a.v, b.v) || a.zip - b.zip || b.tier - a.tier || b.m - a.m);
100
+ }
101
+
102
+ // Resolve what this computer has. env = LS_ICONS_DIR (folder or .zip); empty means "look for it".
103
+ export function locate(env, { wide = false } = {}) {
104
+ const tried = []; let envBad = false;
105
+ if (env && env.trim()) {
106
+ const p = resolve(env.trim().replace(/^~(?=$|[\\/])/, HOME));
107
+ const s = openSource(p);
108
+ if (s) return { source: s, via: 'LS_ICONS_DIR', tried };
109
+ tried.push(p); envBad = true;
110
+ // fall through: the path may be stale (e.g. a newer download sits in Downloads)
111
+ }
112
+ const dirs = searchDirs(wide);
113
+ for (const k of findKits(dirs)) {
114
+ const s = openSource(k.path);
115
+ if (s) return { source: s, via: 'auto', tried, envBad };
116
+ tried.push(k.path);
117
+ }
118
+ return { source: null, tried, dirs, envBad };
119
+ }
120
+ export const kitName = (p) => basename(p);
package/bin/server.js ADDED
@@ -0,0 +1,186 @@
1
+ #!/usr/bin/env node
2
+ // LINE & STONE Icons — MCP server (stdio). No dependencies.
3
+ // Free: the 100 free icons in 1 / 1.25 / 1.5 px. Full set: point LS_ICONS_DIR at your unzipped LINE & STONE download.
4
+ // Code: MIT. Icons: free icons under LICENSE-ICONS-FREE.txt; paid icons under your own purchase licence.
5
+ import { readFileSync } from 'node:fs';
6
+ import { join, dirname } from 'node:path';
7
+ import { fileURLToPath } from 'node:url';
8
+ import { locate } from './locate.js';
9
+
10
+ const HERE = dirname(fileURLToPath(import.meta.url));
11
+ const PKG = JSON.parse(readFileSync(join(HERE, '..', 'package.json'), 'utf8'));
12
+ const INDEX = JSON.parse(readFileSync(join(HERE, '..', 'data', 'index.json'), 'utf8'));
13
+ const FREE = JSON.parse(readFileSync(join(HERE, '..', 'data', 'free.json'), 'utf8'));
14
+ const SITE = 'https://lineandstoneco.com';
15
+ const UTM = 'utm_source=mcp&utm_medium=tool&utm_campaign=icons-mcp';
16
+ const WEIGHTS = ['1', '1.25', '1.5'];
17
+ const CREDIT = 'Icons by LINE & STONE - lineandstoneco.com';
18
+ const CATS = Object.fromEntries(INDEX.categories.map((c) => [c.id, c.name]));
19
+ const ICONS = INDEX.icons.slice();
20
+ const BY = new Map(ICONS.map((i) => [i.n, i]));
21
+
22
+ // ---------- full set from the buyer's own download ----------
23
+ // Looked up on the first tool call (not at start-up), then cached. LS_ICONS_DIR is optional:
24
+ // without it we look for the download (folder or .zip) in Downloads / Desktop.
25
+ let LOC = null;
26
+ const OWNED = new Map(); // name -> category folder
27
+ function load() {
28
+ if (LOC) return LOC;
29
+ LOC = locate(process.env.LS_ICONS_DIR);
30
+ if (LOC.source) for (const [n, cat] of LOC.source.owned) {
31
+ OWNED.set(n, cat);
32
+ if (!BY.has(n)) { const cap = (w) => w[0].toUpperCase() + w.slice(1); const i = { n, t: n.split('-').map(cap).join(' '), c: cat, k: [], comp: 'Ls' + n.split('-').map(cap).join(''), f: false }; ICONS.push(i); BY.set(n, i); }
33
+ }
34
+ return LOC;
35
+ }
36
+ const HOW = 'Put your LINE & STONE download (the .zip or the unzipped folder) in Downloads, then ask again. Or run `npx -y @lineandstone/icons-mcp setup` once.';
37
+ function unlockInfo() {
38
+ const L = load();
39
+ if (L.source) return { unlocked: true, icons: OWNED.size, from: L.source.path, kind: L.source.kind, ...(L.envBad ? { warning: `LS_ICONS_DIR (${process.env.LS_ICONS_DIR}) has no icons; using the download found in ${L.source.path} instead.` } : {}) };
40
+ return { unlocked: false, lookedIn: L.dirs, ...(L.envBad ? { problem: `LS_ICONS_DIR is set to ${process.env.LS_ICONS_DIR}, but there is no svg/1px folder or LINE & STONE .zip there.` } : {}), howToUnlock: HOW };
41
+ }
42
+ const status = (i) => (i.f ? 'free' : OWNED.has(i.n) ? 'licensed' : 'locked');
43
+
44
+ // Team / Dev component packages installed in the current project?
45
+ function componentPkg() {
46
+ try {
47
+ const p = JSON.parse(readFileSync(join(process.cwd(), 'package.json'), 'utf8'));
48
+ const deps = { ...p.dependencies, ...p.devDependencies };
49
+ if (deps['@lineandstone/icons-react']) return 'react';
50
+ if (deps['@lineandstone/icons-vue']) return 'vue';
51
+ } catch {}
52
+ return null;
53
+ }
54
+
55
+ // ---------- search ----------
56
+ const STOP = new Set(['a', 'an', 'the', 'for', 'of', 'to', 'in', 'on', 'and', 'or', 'with', 'icon', 'icons', 'button', 'my', 'our', 'that', 'this', 'add', 'use', 'show']);
57
+ const stem = (w) => w.replace(/(ing|ers|er|es|ed|s)$/, '') || w;
58
+ const toks = (s) => String(s || '').toLowerCase().replace(/[^a-z0-9\s-]/g, ' ').split(/[\s-]+/).filter(Boolean);
59
+ function score(i, q, qt) {
60
+ if (i.n === q.replace(/\s+/g, '-')) return 1000;
61
+ const name = toks(i.n), title = toks(i.t), kws = i.k.map((k) => k.toLowerCase());
62
+ const kwt = kws.flatMap(toks), all = new Set([...name, ...title, ...kwt].map(stem));
63
+ let s = 0;
64
+ if (kws.includes(q)) s += 60;
65
+ if (i.t.toLowerCase() === q) s += 80;
66
+ for (const t of qt) {
67
+ const st = stem(t);
68
+ if (name.includes(t)) s += 12; else if (name.map(stem).includes(st)) s += 10;
69
+ if (title.map(stem).includes(st)) s += 6;
70
+ if (all.has(st)) s += 6; else if ([...all].some((w) => w.length > 3 && (w.startsWith(st) || st.startsWith(w)))) s += 2;
71
+ if (toks(CATS[i.c] || i.c).includes(t)) s += 1;
72
+ }
73
+ const hit = qt.filter((t) => all.has(stem(t))).length;
74
+ if (qt.length > 1 && hit === qt.length) s += 15;
75
+ return s;
76
+ }
77
+ function search({ query = '', category, limit = 10 }) {
78
+ load();
79
+ const q = String(query).toLowerCase().trim();
80
+ const qt = toks(q).filter((t) => !STOP.has(t));
81
+ const lim = Math.max(1, Math.min(50, Number(limit) || 10));
82
+ let pool = ICONS;
83
+ if (category) { const c = String(category).toLowerCase(); pool = pool.filter((i) => i.c === c || (CATS[i.c] || '').toLowerCase() === c); }
84
+ const res = (qt.length ? pool.map((i) => [score(i, q, qt), i]).filter((x) => x[0] > 0) : pool.map((i) => [0, i]))
85
+ .sort((a, b) => b[0] - a[0] || (status(a[1]) === 'locked') - (status(b[1]) === 'locked') || a[1].n.localeCompare(b[1].n))
86
+ .slice(0, lim);
87
+ return { query, count: res.length,
88
+ note: LOC.source ? `Full set unlocked from ${LOC.source.path}.` : 'Free icons can be inserted now. "locked" icons are part of the paid LINE & STONE set; prefer a free icon, or tell the user how to unlock (see get_icon).',
89
+ results: res.map(([, i]) => ({ name: i.n, title: i.t, category: CATS[i.c] || i.c, keywords: i.k.slice(0, 8), status: status(i), component: i.comp })) };
90
+ }
91
+
92
+ // ---------- get icon ----------
93
+ function readSvg(i, w) {
94
+ if (i.f && FREE[i.n]) return FREE[i.n][w];
95
+ if (!OWNED.has(i.n)) return null;
96
+ try { return (LOC.source.read(i.n, w) || '').trim() || null; } catch { return null; }
97
+ }
98
+ const sized = (svg, size) => svg.replace(/<svg\b([^>]*)>/, (m, a) => '<svg' + a.replace(/\s(width|height)="[^"]*"/g, '') + ` width="${size}" height="${size}">`);
99
+ function getIcon({ name, strokeWidth = 1, format, size = 24 }) {
100
+ load();
101
+ const n = String(name || '').trim().toLowerCase().replace(/\s+/g, '-');
102
+ const i = BY.get(n);
103
+ if (!i) {
104
+ const alt = search({ query: name, limit: 5 }).results.map((r) => r.name);
105
+ return { error: `No icon named "${name}".`, suggestions: alt, hint: 'Use search_icons to find the right name.' };
106
+ }
107
+ const w = String(strokeWidth === 'auto' ? 1 : strokeWidth);
108
+ if (!WEIGHTS.includes(w)) return { error: 'strokeWidth must be 1, 1.25 or 1.5.' };
109
+ const st = status(i);
110
+ const page = `${SITE}/icons/${i.c}/${i.n}/?${UTM}`;
111
+ if (st === 'locked') return { name: i.n, title: i.t, status: 'locked', message: `"${i.t}" is part of the LINE & STONE paid set, so it can't be inserted yet. Do not draw a substitute; use a free icon or ask the user.`, preview: page, buy: `${SITE}/pricing/?${UTM}`, unlock: unlockInfo() };
112
+ const comp = format === 'react' || format === 'vue' ? format : format === 'svg' ? null : componentPkg();
113
+ const out = { name: i.n, title: i.t, category: CATS[i.c] || i.c, status: st, strokeWidth: Number(w) };
114
+ if (comp) {
115
+ out.format = comp;
116
+ out.import = `import { ${i.comp} } from '@lineandstone/icons-${comp}'`;
117
+ out.usage = comp === 'react' ? `<${i.comp} size={${size}} strokeWidth={${w}} />` : `<${i.comp} :size="${size}" :stroke-width="${w}" />`;
118
+ out.note = 'Requires the LINE & STONE Team / Dev package installed in this project. For an icon-only button, add an aria-label.';
119
+ } else {
120
+ const svg = readSvg(i, w);
121
+ if (!svg) return { error: `Could not read "${i.n}" from ${LOC.source ? LOC.source.path : 'the download'}. The file may have been moved; ask again after putting the download back in Downloads.` };
122
+ out.format = 'svg'; out.svg = sized(svg, size);
123
+ out.note = 'Inline as-is; color follows currentColor. Keep one stroke weight per screen. For an icon-only button, add an aria-label.';
124
+ }
125
+ if (st === 'free') out.credit = `Free icon. Credit required, e.g. in your README or credits: "${CREDIT}". License: ${SITE}/license/#free`;
126
+ return out;
127
+ }
128
+
129
+ // ---------- MCP plumbing (JSON-RPC 2.0 over stdio, one message per line) ----------
130
+ const TOOLS = [
131
+ { name: 'search_icons', description: 'Search LINE & STONE line icons by meaning (e.g. "pause the agent", "checkout basket", "low battery"). Returns names, titles, categories and whether each icon is free, licensed or locked. Always search before inserting an icon; never draw your own SVG.',
132
+ inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'What the icon is for, in plain words' }, category: { type: 'string', description: 'Optional category id or name, e.g. ai-and-agents' }, limit: { type: 'number', description: '1–50, default 10' } }, required: ['query'] } },
133
+ { name: 'get_icon', description: 'Get one LINE & STONE icon ready to paste: inline SVG, or a React / Vue component usage if the Team / Dev package is installed. Locked icons return a preview and buy link instead; do not substitute a hand-drawn icon.',
134
+ inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Icon name from search_icons, e.g. agent-pause' }, strokeWidth: { type: 'number', enum: [1, 1.25, 1.5], description: 'Default 1. Keep one weight per screen.' }, format: { type: 'string', enum: ['svg', 'react', 'vue'], description: 'Default: component if @lineandstone/icons-react or -vue is in package.json, else svg' }, size: { type: 'number', description: 'Pixel size, default 24' } }, required: ['name'] } },
135
+ { name: 'list_categories', description: 'List the LINE & STONE icon categories with counts, how many icons are usable right now, and whether (and from where) the full set is unlocked. Use it when the user asks why paid icons are locked.', inputSchema: { type: 'object', properties: {} } },
136
+ ];
137
+ const INSTRUCTIONS = 'LINE & STONE line icons (24 px grid; 1, 1.25 and 1.5 px strokes; round caps). When the UI needs an icon: call search_icons with what the icon is for, then get_icon. Use only icons this tool returns; never draw or invent SVG icons. Keep one stroke weight per screen. Add aria-label to icon-only buttons. Free icons need a credit line in the project README.';
138
+ const SUPPORTED = ['2025-06-18', '2025-03-26', '2024-11-05'];
139
+
140
+ function call(name, args = {}) {
141
+ if (name === 'search_icons') return search(args);
142
+ if (name === 'get_icon') return getIcon(args);
143
+ if (name === 'list_categories') return { version: INDEX.version, unlock: unlockInfo(), categories: INDEX.categories.map((c) => ({ id: c.id, name: c.name, count: c.count, usable: ICONS.filter((i) => i.c === c.id && status(i) !== 'locked').length })) };
144
+ throw Object.assign(new Error('Unknown tool: ' + name), { code: -32602 });
145
+ }
146
+ function handle(msg) {
147
+ const { id, method, params = {} } = msg;
148
+ if (id === undefined || id === null) return null; // notification
149
+ try {
150
+ if (method === 'initialize') {
151
+ const v = SUPPORTED.includes(params.protocolVersion) ? params.protocolVersion : SUPPORTED[0];
152
+ return { jsonrpc: '2.0', id, result: { protocolVersion: v, capabilities: { tools: { listChanged: false } }, serverInfo: { name: 'lineandstone-icons', title: 'LINE & STONE Icons', version: PKG.version }, instructions: INSTRUCTIONS } };
153
+ }
154
+ if (method === 'ping') return { jsonrpc: '2.0', id, result: {} };
155
+ if (method === 'tools/list') return { jsonrpc: '2.0', id, result: { tools: TOOLS } };
156
+ if (method === 'tools/call') {
157
+ const r = call(params.name, params.arguments || {});
158
+ return { jsonrpc: '2.0', id, result: { content: [{ type: 'text', text: JSON.stringify(r, null, 2) }], structuredContent: r, isError: !!r.error } };
159
+ }
160
+ return { jsonrpc: '2.0', id, error: { code: -32601, message: 'Method not found: ' + method } };
161
+ } catch (e) { return { jsonrpc: '2.0', id, error: { code: e.code || -32603, message: e.message } }; }
162
+ }
163
+
164
+ if (process.argv.includes('--version')) { console.log(PKG.version); process.exit(0); }
165
+ if (process.argv[2] === 'setup') { const { setup } = await import('./setup.js'); await setup(process.argv[3]); process.exit(0); }
166
+ if (process.argv.includes('--check')) { // quick self-check for the install guide
167
+ const u = unlockInfo();
168
+ console.log(`LINE & STONE Icons MCP ${PKG.version} · data ${INDEX.version} · ${INDEX.icons.length} icons · free ${Object.keys(FREE).length}`);
169
+ console.log(u.unlocked ? `Full set unlocked: ${u.icons} icons from ${u.from}` : `Free mode. Looked in: ${u.lookedIn.join(', ')}`);
170
+ if (u.warning || u.problem) console.log(u.warning || u.problem);
171
+ if (!u.unlocked) console.log('Bought the full set? ' + u.howToUnlock);
172
+ process.exit(0);
173
+ }
174
+ let buf = '';
175
+ process.stdin.setEncoding('utf8');
176
+ process.stdin.on('data', (chunk) => {
177
+ buf += chunk; let nl;
178
+ while ((nl = buf.indexOf('\n')) >= 0) {
179
+ const line = buf.slice(0, nl).trim(); buf = buf.slice(nl + 1);
180
+ if (!line) continue;
181
+ let msg; try { msg = JSON.parse(line); } catch { process.stdout.write(JSON.stringify({ jsonrpc: '2.0', id: null, error: { code: -32700, message: 'Parse error' } }) + '\n'); continue; }
182
+ const out = Array.isArray(msg) ? msg.map(handle).filter(Boolean) : handle(msg);
183
+ if (out && (!Array.isArray(out) || out.length)) process.stdout.write(JSON.stringify(out) + '\n');
184
+ }
185
+ });
186
+ process.stdin.on('end', () => process.exit(0));
package/bin/setup.js ADDED
@@ -0,0 +1,68 @@
1
+ // `npx -y @lineandstone/icons-mcp setup [path]`
2
+ // Adds the server to every AI app found on this computer and connects the user's download if there is one.
3
+ // Only touches the MCP config files of apps that are installed; keeps a .bak copy of each file it changes.
4
+ import { readFileSync, writeFileSync, existsSync, mkdirSync, copyFileSync } from 'node:fs';
5
+ import { join, dirname, resolve } from 'node:path';
6
+ import { homedir } from 'node:os';
7
+ import { execFileSync } from 'node:child_process';
8
+ import { locate, openSource, searchDirs } from './locate.js';
9
+
10
+ const HOME = homedir(), WIN = process.platform === 'win32', MAC = process.platform === 'darwin';
11
+ const APPDATA = process.env.APPDATA || join(HOME, 'AppData', 'Roaming');
12
+ const NAME = 'lineandstone-icons', PKG = '@lineandstone/icons-mcp';
13
+ const appSupport = (...p) => (MAC ? join(HOME, 'Library', 'Application Support', ...p) : WIN ? join(APPDATA, ...p) : join(HOME, '.config', ...p));
14
+
15
+ function writeJson(file, mutate) {
16
+ let data = {};
17
+ if (existsSync(file)) {
18
+ const raw = readFileSync(file, 'utf8');
19
+ if (raw.trim()) { try { data = JSON.parse(raw); } catch { return `skipped: ${file} is not plain JSON (comments?). Add the server by hand.`; } }
20
+ copyFileSync(file, file + '.bak');
21
+ } else mkdirSync(dirname(file), { recursive: true });
22
+ mutate(data);
23
+ writeFileSync(file, JSON.stringify(data, null, 2) + '\n');
24
+ return 'added';
25
+ }
26
+
27
+ export async function setup(arg) {
28
+ console.log('LINE & STONE Icons · setup\n');
29
+ // 1. the download
30
+ let src = null, via = '';
31
+ if (arg) { src = openSource(resolve(arg.replace(/^~(?=$|[\\/])/, HOME))); via = 'path'; if (!src) console.log(`No LINE & STONE icons found in ${arg}. Point to the .zip or the unzipped folder.\n`); }
32
+ if (!src) { const L = locate('', { wide: true }); src = L.source; via = 'auto'; }
33
+ // Downloads/Desktop are searched automatically, so newer downloads there are picked up without a fixed path.
34
+ const auto = src && searchDirs(false).some((d) => src.path.startsWith(d + (WIN ? '\\' : '/')));
35
+ const env = src && !auto ? { LS_ICONS_DIR: src.path } : undefined;
36
+ console.log(src ? `✓ Full set: ${src.owned.size} icons from ${src.path}` : '· No LINE & STONE download found yet, so the 100 free icons will be used.\n Bought the full set? Put the download (.zip or folder) in Downloads; it unlocks automatically.');
37
+ console.log('');
38
+
39
+ // 2. the apps
40
+ const base = { command: 'npx', args: ['-y', PKG], ...(env ? { env } : {}) };
41
+ const winWrap = { command: 'cmd', args: ['/c', 'npx', '-y', PKG], ...(env ? { env } : {}) };
42
+ const apps = [
43
+ { name: 'Cursor', dir: join(HOME, '.cursor'), file: join(HOME, '.cursor', 'mcp.json'), set: (d) => { (d.mcpServers ||= {})[NAME] = base; } },
44
+ { name: 'Claude Desktop', dir: appSupport('Claude'), file: appSupport('Claude', 'claude_desktop_config.json'), set: (d) => { (d.mcpServers ||= {})[NAME] = WIN ? winWrap : base; } },
45
+ { name: 'Windsurf', dir: join(HOME, '.codeium', 'windsurf'), file: join(HOME, '.codeium', 'windsurf', 'mcp_config.json'), set: (d) => { (d.mcpServers ||= {})[NAME] = base; } },
46
+ { name: 'VS Code', dir: appSupport('Code', 'User'), file: appSupport('Code', 'User', 'mcp.json'), set: (d) => { (d.servers ||= {})[NAME] = { type: 'stdio', ...base }; } },
47
+ ];
48
+ const done = [];
49
+ for (const a of apps) {
50
+ if (!existsSync(a.dir)) continue;
51
+ const r = writeJson(a.file, a.set);
52
+ console.log(r === 'added' ? `✓ ${a.name}` : `· ${a.name}: ${r}`);
53
+ if (r === 'added') done.push(a.name);
54
+ }
55
+ // Claude Code has its own command
56
+ try {
57
+ const sh = { stdio: 'ignore', shell: WIN };
58
+ execFileSync('claude', ['--version'], sh);
59
+ try { execFileSync('claude', ['mcp', 'remove', '-s', 'user', NAME], sh); } catch {}
60
+ execFileSync('claude', ['mcp', 'add', '-s', 'user', NAME, ...(env ? ['-e', `LS_ICONS_DIR=${env.LS_ICONS_DIR}`] : []), '--', 'npx', '-y', PKG], sh);
61
+ console.log('✓ Claude Code'); done.push('Claude Code');
62
+ } catch {}
63
+
64
+ console.log('');
65
+ if (done.length) console.log(`Done. Restart ${done.join(', ')}, then ask your assistant for an icon, e.g. "add a pause button to each agent card".`);
66
+ else console.log('No AI app found on this computer (Cursor, Claude Code, Claude Desktop, Windsurf, VS Code).\nSee https://lineandstoneco.com/tools/mcp/ for other apps.');
67
+ console.log('Icons by LINE & STONE · https://lineandstoneco.com');
68
+ }