@vezham/icons-mcp 1.0.1

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.
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@vezham/icons-mcp",
3
+ "version": "1.0.1",
4
+ "type": "module",
5
+ "description": "MCP server and CLI for browsing and applying Reicon icons.",
6
+ "bin": {
7
+ "reicon-mcp": "bin/run.cjs"
8
+ },
9
+ "main": "./server/index.js",
10
+ "types": "./server/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "import": "./server/index.js",
14
+ "types": "./server/index.d.ts"
15
+ }
16
+ },
17
+ "files": [
18
+ "bin",
19
+ "cli",
20
+ "server",
21
+ "core",
22
+ "data",
23
+ "README.md",
24
+ "LICENSE"
25
+ ],
26
+ "scripts": {
27
+ "build": "node scripts/build.cjs"
28
+ },
29
+ "keywords": [
30
+ "icons",
31
+ "mcp",
32
+ "model-context-protocol",
33
+ "svg"
34
+ ],
35
+ "author": "Dev Chauhan",
36
+ "license": "MIT",
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "https://github.com/vezham/reicon",
40
+ "directory": "packages/icons-mcp"
41
+ },
42
+ "homepage": "https://vezham.com",
43
+ "bugs": {
44
+ "url": "https://github.com/vezham/reicon/issues"
45
+ },
46
+ "dependencies": {
47
+ "@modelcontextprotocol/sdk": "^1.12.0",
48
+ "zod": "^3.24.0"
49
+ },
50
+ "engines": {
51
+ "node": ">=18"
52
+ }
53
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,101 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
3
+ import { z } from 'zod';
4
+ import { handleApplyIcon } from './tools/apply-icon.js';
5
+ import { handleListCategories } from './tools/list-categories.js';
6
+ import { handleSearchIcons } from './tools/search-icons.js';
7
+ import { handleViewIcon } from './tools/view-icon.js';
8
+ const server = new McpServer({
9
+ name: 'reicon-mcp',
10
+ version: '1.1.0',
11
+ });
12
+ server.tool('search_icons', [
13
+ 'Search 2,700+ Reicon icons by any keyword, phrase, or description.',
14
+ 'Understands synonyms ("round" → circle, "del" → delete/trash), misspellings ("calender" → calendar),',
15
+ 'multi-word queries ("user circle", "credit card", "volume up"), and name parts ("up" → arrow-up).',
16
+ 'Returns ranked matches. Short specific terms work best but full phrases also work.',
17
+ 'After getting results, pick the highest-scoring match and call apply_icon directly.',
18
+ 'Only call view_icon first if you need to inspect the raw SVG before generating code.',
19
+ ].join(' '), {
20
+ query: z.string().describe('Keyword(s) or phrase — e.g. "cart", "user circle", "volume up", "credit card", "go back", "delete". Handles synonyms, misspellings, and multi-word queries.'),
21
+ weight: z
22
+ .enum(['Outline', 'Filled'])
23
+ .optional()
24
+ .describe('Filter by weight. Omit to search both.'),
25
+ limit: z
26
+ .number()
27
+ .int()
28
+ .min(1)
29
+ .max(20)
30
+ .optional()
31
+ .describe('Max results to return. Defaults to 8.'),
32
+ }, async (args) => {
33
+ const result = handleSearchIcons(args);
34
+ return {
35
+ content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
36
+ };
37
+ });
38
+ server.tool('view_icon', [
39
+ 'Fetch raw SVG markup and metadata for a specific Reicon icon.',
40
+ 'Use this to inspect the SVG before applying, or when you only need the raw markup.',
41
+ 'For generating import/docs code, prefer apply_icon instead.',
42
+ ].join(' '), {
43
+ name: z.string().describe('Icon kebab-case name, e.g. "heart", "arrow-right", "user-circle"'),
44
+ weight: z.enum(['Outline', 'Filled']).describe('Which weight variant to fetch'),
45
+ }, async (args) => {
46
+ const result = handleViewIcon(args);
47
+ return {
48
+ content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
49
+ };
50
+ });
51
+ server.tool('apply_icon', [
52
+ 'Generate ready-to-paste import and docs code for a Reicon icon.',
53
+ 'Returns importStatement and docsSnippet for the chosen framework.',
54
+ 'Supported frameworks: react, react-native, vue, svelte, html (CDN custom element), svg (raw markup).',
55
+ 'Insert importStatement at the top of the file and docsSnippet where the icon should appear.',
56
+ 'Always call search_icons first to confirm the icon name and weight exist.',
57
+ ].join(' '), {
58
+ name: z.string().describe('Icon kebab-case name, e.g. "heart"'),
59
+ weight: z.enum(['Outline', 'Filled']).describe('Icon weight variant'),
60
+ framework: z
61
+ .enum(['react', 'react-native', 'vue', 'svelte', 'html', 'svg'])
62
+ .describe('Target framework or output format'),
63
+ size: z
64
+ .number()
65
+ .int()
66
+ .min(8)
67
+ .max(256)
68
+ .optional()
69
+ .describe('Icon size in pixels. Defaults to 24.'),
70
+ color: z
71
+ .string()
72
+ .optional()
73
+ .describe('CSS color value, e.g. "#ef4444" or "currentColor". Defaults to currentColor.'),
74
+ componentName: z
75
+ .string()
76
+ .optional()
77
+ .describe('Override the component name. Defaults to the PascalCase icon name.'),
78
+ }, async (args) => {
79
+ const result = handleApplyIcon(args);
80
+ return {
81
+ content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
82
+ };
83
+ });
84
+ server.tool('list_categories', [
85
+ 'List all icon categories available in the Reicon dataset.',
86
+ 'Use this to explore what types of icons exist before searching.',
87
+ 'Each category can be used as a search keyword with search_icons.',
88
+ ].join(' '), {}, async () => {
89
+ const result = handleListCategories();
90
+ return {
91
+ content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
92
+ };
93
+ });
94
+ async function main() {
95
+ const transport = new StdioServerTransport();
96
+ await server.connect(transport);
97
+ }
98
+ main().catch((err) => {
99
+ console.error(err);
100
+ process.exit(1);
101
+ });
@@ -0,0 +1,18 @@
1
+ import type { ApplyIconInput } from '../../core/types.js';
2
+ export declare function handleApplyIcon(args: ApplyIconInput): {
3
+ error: string;
4
+ } | {
5
+ error: string;
6
+ suggestion: string;
7
+ } | {
8
+ meta: {
9
+ name: string;
10
+ weight: import("../../core/types.js").IconWeight;
11
+ framework: import("../../core/types.js").Framework;
12
+ size: number;
13
+ };
14
+ importStatement: string;
15
+ docsSnippet: string;
16
+ error?: undefined;
17
+ suggestion?: undefined;
18
+ };
@@ -0,0 +1,35 @@
1
+ import { generateCode } from '../../core/codegen.js';
2
+ import { loadIndex } from '../../core/load-index.js';
3
+ import { findIcon } from '../../core/search.js';
4
+ export function handleApplyIcon(args) {
5
+ const index = loadIndex();
6
+ const icon = findIcon(index, args.name);
7
+ if (!icon) {
8
+ // Soft-match: try normalized kebab-case
9
+ const lower = args.name.toLowerCase().replace(/\s+/g, '-');
10
+ const match = index.icons.find((i) => i.name.toLowerCase() === lower ||
11
+ i.pascal.toLowerCase() === lower.replace(/-/g, ''));
12
+ if (match) {
13
+ return {
14
+ error: `Icon "${args.name}" not found. Did you mean "${match.name}"? Call apply_icon again with name="${match.name}".`,
15
+ suggestion: match.name,
16
+ };
17
+ }
18
+ return {
19
+ error: `Icon "${args.name}" not found. Use search_icons to find the correct name.`,
20
+ };
21
+ }
22
+ const result = generateCode(icon, args);
23
+ if ('error' in result)
24
+ return result;
25
+ return {
26
+ ...result,
27
+ // Echo back key info so the agent can confirm what was applied
28
+ meta: {
29
+ name: icon.name,
30
+ weight: args.weight,
31
+ framework: args.framework,
32
+ size: args.size ?? 24,
33
+ },
34
+ };
35
+ }
@@ -0,0 +1,3 @@
1
+ export declare function handleListCategories(): {
2
+ categories: string[];
3
+ };
@@ -0,0 +1,6 @@
1
+ import { loadIndex } from '../../core/load-index.js';
2
+ import { listCategories } from '../../core/search.js';
3
+ export function handleListCategories() {
4
+ const index = loadIndex();
5
+ return { categories: listCategories(index) };
6
+ }
@@ -0,0 +1,11 @@
1
+ import type { IconWeight } from '../../core/types.js';
2
+ export declare function handleSearchIcons(args: {
3
+ query: string;
4
+ weight?: IconWeight;
5
+ limit?: number;
6
+ }): {
7
+ results: import("../../core/types.js").SearchResult[];
8
+ instruction: string;
9
+ } | {
10
+ error: string;
11
+ };
@@ -0,0 +1,9 @@
1
+ import { loadIndex } from '../../core/load-index.js';
2
+ import { searchIcons } from '../../core/search.js';
3
+ export function handleSearchIcons(args) {
4
+ const index = loadIndex();
5
+ return searchIcons(index, args.query, {
6
+ weight: args.weight,
7
+ limit: args.limit,
8
+ });
9
+ }
@@ -0,0 +1,29 @@
1
+ import type { IconWeight } from '../../core/types.js';
2
+ export declare function handleViewIcon(args: {
3
+ name: string;
4
+ weight: IconWeight;
5
+ }): {
6
+ error: string;
7
+ } | {
8
+ error: string;
9
+ suggestion: string;
10
+ name?: undefined;
11
+ weight?: undefined;
12
+ availableWeights?: undefined;
13
+ category?: undefined;
14
+ tags?: undefined;
15
+ viewBox?: undefined;
16
+ svg?: undefined;
17
+ hint?: undefined;
18
+ } | {
19
+ name: string;
20
+ weight: IconWeight;
21
+ availableWeights: IconWeight[];
22
+ category: string;
23
+ tags: string[];
24
+ viewBox: string;
25
+ svg: string;
26
+ hint: string;
27
+ error?: undefined;
28
+ suggestion?: undefined;
29
+ };
@@ -0,0 +1,35 @@
1
+ import { buildSvgMarkup } from '../../core/codegen.js';
2
+ import { loadIndex } from '../../core/load-index.js';
3
+ import { findIcon } from '../../core/search.js';
4
+ export function handleViewIcon(args) {
5
+ const index = loadIndex();
6
+ const icon = findIcon(index, args.name);
7
+ if (!icon) {
8
+ // Try a soft match in case casing or dashes differ
9
+ const lower = args.name.toLowerCase().replace(/\s+/g, '-');
10
+ const match = index.icons.find((i) => i.name.toLowerCase() === lower || i.pascal.toLowerCase() === lower.replace(/-/g, ''));
11
+ if (match) {
12
+ return {
13
+ error: `Icon "${args.name}" not found. Did you mean "${match.name}"?`,
14
+ suggestion: match.name,
15
+ };
16
+ }
17
+ return { error: `Icon "${args.name}" not found. Use search_icons to find the correct name.` };
18
+ }
19
+ const svg = buildSvgMarkup(icon, args.weight);
20
+ if (typeof svg !== 'string') {
21
+ return svg;
22
+ }
23
+ const weightData = icon.weights[args.weight];
24
+ const availableWeights = Object.keys(icon.weights);
25
+ return {
26
+ name: icon.name,
27
+ weight: args.weight,
28
+ availableWeights,
29
+ category: icon.category,
30
+ tags: icon.tags,
31
+ viewBox: weightData.viewBox,
32
+ svg,
33
+ hint: 'Call apply_icon with this name and weight to generate framework-specific code.',
34
+ };
35
+ }
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@vezham/icons-mcp",
3
+ "version": "1.0.1",
4
+ "type": "module",
5
+ "description": "MCP server and CLI for browsing and applying Reicon icons.",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/vezham/reicon",
9
+ "directory": "packages/icons-mcp"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/vezham/reicon/issues"
13
+ },
14
+ "homepage": "https://vezham.com",
15
+ "bin": {
16
+ "reicon-mcp": "./dist/bin/run.cjs"
17
+ },
18
+ "dependencies": {
19
+ "@modelcontextprotocol/sdk": "^1.12.0",
20
+ "zod": "^3.24.0"
21
+ },
22
+ "engines": {
23
+ "node": ">=18"
24
+ },
25
+ "license": "MIT",
26
+ "main": "./dist/server/index.js",
27
+ "types": "./dist/server/index.d.ts",
28
+ "exports": {
29
+ ".": {
30
+ "import": "./dist/server/index.js",
31
+ "types": "./dist/server/index.d.ts"
32
+ }
33
+ },
34
+ "files": [
35
+ "dist"
36
+ ],
37
+ "keywords": [
38
+ "icons",
39
+ "mcp",
40
+ "model-context-protocol",
41
+ "svg"
42
+ ],
43
+ "author": "Dev Chauhan",
44
+ "scripts": {
45
+ "build": "node scripts/build.cjs"
46
+ }
47
+ }