@iconpik/mcp-server 0.0.0-stage → 0.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/LICENSE +21 -0
- package/LICENSING.md +184 -0
- package/NOTICE.md +7 -0
- package/README.md +268 -3
- package/THIRD_PARTY_NOTICES.md +81 -0
- package/dist/flag-hint.d.ts +4 -0
- package/dist/flag-hint.d.ts.map +1 -0
- package/dist/flag-hint.js +22 -0
- package/dist/flag-hint.js.map +1 -0
- package/dist/icons.json +161034 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +391 -0
- package/dist/index.js.map +1 -0
- package/dist/ui-tools.d.ts +14 -0
- package/dist/ui-tools.d.ts.map +1 -0
- package/dist/ui-tools.js +108 -0
- package/dist/ui-tools.js.map +1 -0
- package/dist/ui.d.ts +36 -0
- package/dist/ui.d.ts.map +1 -0
- package/dist/ui.js +104 -0
- package/dist/ui.js.map +1 -0
- package/package.json +63 -3
package/dist/ui.js
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// UI icon data layer. Separate from the bundled brand index: the UI index is
|
|
2
|
+
// fetched lazily and cached, and a failure only ever surfaces to UI requests.
|
|
3
|
+
import Fuse from "fuse.js";
|
|
4
|
+
// UI data is not part of the pinned brand release, so it reads from main.
|
|
5
|
+
export const UI_CDN_BASE = "https://www.iconpik.com";
|
|
6
|
+
// The per-icon SVG files are build artifacts served by the site, not committed, so links point there.
|
|
7
|
+
export const UI_SITE_BASE = "https://www.iconpik.com";
|
|
8
|
+
export const UI_INDEX_URL = `${UI_CDN_BASE}/ui/manifest.json`;
|
|
9
|
+
export const DEFAULT_LOOK = "outline";
|
|
10
|
+
const FETCH_TIMEOUT_MS = 10_000;
|
|
11
|
+
export class UiUnavailableError extends Error {
|
|
12
|
+
constructor(detail) {
|
|
13
|
+
super(`UI icons are unavailable right now (${detail}). Brand icons are not affected.`);
|
|
14
|
+
this.name = "UiUnavailableError";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function isUiIndex(value) {
|
|
18
|
+
if (typeof value !== "object" || value === null)
|
|
19
|
+
return false;
|
|
20
|
+
const v = value;
|
|
21
|
+
return (Array.isArray(v["looks"]) &&
|
|
22
|
+
v["looks"].every((l) => typeof l === "string") &&
|
|
23
|
+
Array.isArray(v["icons"]) &&
|
|
24
|
+
v["icons"].every((i) => {
|
|
25
|
+
if (typeof i !== "object" || i === null)
|
|
26
|
+
return false;
|
|
27
|
+
const r = i;
|
|
28
|
+
return (typeof r["slug"] === "string" &&
|
|
29
|
+
typeof r["title"] === "string" &&
|
|
30
|
+
typeof r["category"] === "string" &&
|
|
31
|
+
Array.isArray(r["tags"]));
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
let indexCache = null;
|
|
35
|
+
let fuseCache = null;
|
|
36
|
+
/** Test-only: drop cached UI state. */
|
|
37
|
+
export function resetUiCacheForTests() {
|
|
38
|
+
indexCache = null;
|
|
39
|
+
fuseCache = null;
|
|
40
|
+
}
|
|
41
|
+
/** Fetches the UI index once and caches it. Throws UiUnavailableError on any failure. */
|
|
42
|
+
export async function loadUiIndex() {
|
|
43
|
+
if (indexCache)
|
|
44
|
+
return indexCache;
|
|
45
|
+
let res;
|
|
46
|
+
try {
|
|
47
|
+
res = await fetch(UI_INDEX_URL, {
|
|
48
|
+
signal: AbortSignal.timeout(FETCH_TIMEOUT_MS),
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
throw new UiUnavailableError(err instanceof Error ? err.message : String(err));
|
|
53
|
+
}
|
|
54
|
+
if (!res.ok)
|
|
55
|
+
throw new UiUnavailableError(`HTTP ${res.status}`);
|
|
56
|
+
let json;
|
|
57
|
+
try {
|
|
58
|
+
json = await res.json();
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
throw new UiUnavailableError("invalid JSON");
|
|
62
|
+
}
|
|
63
|
+
if (!isUiIndex(json))
|
|
64
|
+
throw new UiUnavailableError("unexpected index shape");
|
|
65
|
+
indexCache = json;
|
|
66
|
+
return json;
|
|
67
|
+
}
|
|
68
|
+
export function buildUiUrl(slug, look) {
|
|
69
|
+
return `${UI_SITE_BASE}/ui/${encodeURIComponent(slug)}/${encodeURIComponent(look)}.svg`;
|
|
70
|
+
}
|
|
71
|
+
export async function searchUiIcons(query, limit = 20) {
|
|
72
|
+
const index = await loadUiIndex();
|
|
73
|
+
if (!fuseCache) {
|
|
74
|
+
fuseCache = new Fuse(index.icons, {
|
|
75
|
+
keys: [
|
|
76
|
+
{ name: "slug", weight: 0.4 },
|
|
77
|
+
{ name: "title", weight: 0.3 },
|
|
78
|
+
{ name: "tags", weight: 0.2 },
|
|
79
|
+
{ name: "category", weight: 0.1 },
|
|
80
|
+
],
|
|
81
|
+
threshold: 0.35,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return fuseCache.search(query, { limit }).map((r) => r.item);
|
|
85
|
+
}
|
|
86
|
+
export async function findUiIcon(slug) {
|
|
87
|
+
return (await loadUiIndex()).icons.find((i) => i.slug === slug);
|
|
88
|
+
}
|
|
89
|
+
export async function listUiCategories() {
|
|
90
|
+
const counts = new Map();
|
|
91
|
+
for (const icon of (await loadUiIndex()).icons) {
|
|
92
|
+
counts.set(icon.category, (counts.get(icon.category) ?? 0) + 1);
|
|
93
|
+
}
|
|
94
|
+
// ⚡ Bolt: Use Array.from with mapping function instead of Array.from(counts.entries()).map()
|
|
95
|
+
return Array.from(counts, ([name, count]) => ({ name, count }))
|
|
96
|
+
.sort((a, b) => b.count - a.count);
|
|
97
|
+
}
|
|
98
|
+
/** Returns an error message when the look is unknown, otherwise null. */
|
|
99
|
+
export function checkLook(index, look) {
|
|
100
|
+
return index.looks.includes(look)
|
|
101
|
+
? null
|
|
102
|
+
: `Unknown look "${look}". Valid looks: ${index.looks.join(", ")}.`;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=ui.js.map
|
package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AAK,UAAU,gBAAgB;IACpC,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;IACzC,KAAK,MAAM,IAAI,IAAI,CAAC,MAAM,WAAW,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;QAC/C,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAClE,CAAC;IACD,6FAA6F;IAC7F,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;SAC5D,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;AACvC,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,SAAS,CAAC,KAAc,EAAE,IAAY;IACpD,OAAO,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;QAC/B,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,iBAAiB,IAAI,mBAAmB,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;AACxE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,66 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iconpik/mcp-server",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "MCP server for searching and fetching 6,500+ brand SVGs from iconpik.com",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "iconPik contributors",
|
|
8
|
+
"homepage": "https://www.iconpik.com",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/mrdoing/iconpik.git",
|
|
12
|
+
"directory": "packages/mcp"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/mrdoing/iconpik/issues"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"mcp",
|
|
19
|
+
"model-context-protocol",
|
|
20
|
+
"svg",
|
|
21
|
+
"icons",
|
|
22
|
+
"brand",
|
|
23
|
+
"logos",
|
|
24
|
+
"ai",
|
|
25
|
+
"claude"
|
|
26
|
+
],
|
|
27
|
+
"bin": {
|
|
28
|
+
"iconpik-mcp": "./dist/index.js"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"README.md",
|
|
33
|
+
"LICENSE",
|
|
34
|
+
"NOTICE.md",
|
|
35
|
+
"LICENSING.md",
|
|
36
|
+
"THIRD_PARTY_NOTICES.md"
|
|
37
|
+
],
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
40
|
+
"fuse.js": "^7.5.0",
|
|
41
|
+
"zod": "^4.6.7"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/node": "^26.6.6",
|
|
45
|
+
"typescript": "^6.0.3"
|
|
46
|
+
},
|
|
47
|
+
"engines": {
|
|
48
|
+
"node": ">=18"
|
|
49
|
+
},
|
|
50
|
+
"publishConfig": {
|
|
51
|
+
"access": "public",
|
|
52
|
+
"registry": "https://registry.npmjs.org/",
|
|
53
|
+
"provenance": false
|
|
54
|
+
},
|
|
55
|
+
"contributors": [
|
|
56
|
+
"thesvg.org (upstream)"
|
|
57
|
+
],
|
|
58
|
+
"scripts": {
|
|
59
|
+
"prebuild": "node -e \"require('fs').copyFileSync('../../src/data/icons.json','./src/icons.json')\"",
|
|
60
|
+
"build": "tsc",
|
|
61
|
+
"postbuild": "node -e \"require('fs').copyFileSync('./src/icons.json','./dist/icons.json')\"",
|
|
62
|
+
"start": "node dist/index.js",
|
|
63
|
+
"dev": "tsc --watch",
|
|
64
|
+
"test": "node --test tests/ui.test.mjs tests/flag-hint.test.mjs"
|
|
65
|
+
}
|
|
6
66
|
}
|