@mdui/mcp 2.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/README.md +29 -0
- package/data/components.d.ts +43 -0
- package/data/components.js +6078 -0
- package/data/cssClasses.d.ts +8 -0
- package/data/cssClasses.js +33 -0
- package/data/cssVariables.d.ts +7 -0
- package/data/cssVariables.js +1088 -0
- package/data/documents.d.ts +9 -0
- package/data/documents.js +523 -0
- package/data/icons.d.ts +1 -0
- package/data/icons.js +2126 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +36 -0
- package/server.d.ts +2 -0
- package/server.js +34 -0
- package/stdio.d.ts +2 -0
- package/stdio.js +12 -0
- package/tools/getComponentMetadata.d.ts +6 -0
- package/tools/getComponentMetadata.js +124 -0
- package/tools/getDocument.d.ts +7 -0
- package/tools/getDocument.js +97 -0
- package/tools/listComponents.d.ts +6 -0
- package/tools/listComponents.js +50 -0
- package/tools/listCssClasses.d.ts +6 -0
- package/tools/listCssClasses.js +43 -0
- package/tools/listCssVariables.d.ts +6 -0
- package/tools/listCssVariables.js +40 -0
- package/tools/listDocuments.d.ts +6 -0
- package/tools/listDocuments.js +43 -0
- package/tools/listIconCodes.d.ts +6 -0
- package/tools/listIconCodes.js +72 -0
- package/tools/listIconComponents.d.ts +7 -0
- package/tools/listIconComponents.js +79 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { icons } from '../data/icons.js';
|
|
3
|
+
/**
|
|
4
|
+
* 列出指定变体的所有图标组件信息
|
|
5
|
+
* 返回 { name, tagName, import } 数组
|
|
6
|
+
* @param server
|
|
7
|
+
*/
|
|
8
|
+
export function registerListIconComponents(server) {
|
|
9
|
+
const variantSchema = z.enum([
|
|
10
|
+
'filled',
|
|
11
|
+
'outlined',
|
|
12
|
+
'rounded',
|
|
13
|
+
'sharp',
|
|
14
|
+
'two-tone',
|
|
15
|
+
]);
|
|
16
|
+
const inputSchema = {
|
|
17
|
+
variant: variantSchema
|
|
18
|
+
.optional()
|
|
19
|
+
.describe("Icon variant to list. One of: 'filled' (default), 'outlined', 'rounded', 'sharp', 'two-tone'."),
|
|
20
|
+
query: z
|
|
21
|
+
.preprocess((v) => (typeof v === 'string' ? v.trim() : v), z.string().min(1).optional())
|
|
22
|
+
.describe('Case-insensitive substring to filter by human-readable name or tagName.'),
|
|
23
|
+
limit: z
|
|
24
|
+
.number()
|
|
25
|
+
.int()
|
|
26
|
+
.min(1)
|
|
27
|
+
.max(5000)
|
|
28
|
+
.optional()
|
|
29
|
+
.describe('Maximum number of results to return (default: all).'),
|
|
30
|
+
};
|
|
31
|
+
const outputSchema = {
|
|
32
|
+
icons: z
|
|
33
|
+
.array(z.object({
|
|
34
|
+
name: z.string().describe('Human-readable icon label'),
|
|
35
|
+
tagName: z
|
|
36
|
+
.string()
|
|
37
|
+
.describe('Custom element tag for the icon component.'),
|
|
38
|
+
import: z
|
|
39
|
+
.string()
|
|
40
|
+
.describe("ESM import statement to register the icon element, e.g., import '@mdui/icons/search.js' or import '@mdui/icons/search--outlined.js';"),
|
|
41
|
+
}))
|
|
42
|
+
.describe("List of stand‑alone icon Web Components for the requested variant (default: 'filled'). Each item includes a display name, the custom element tag, and the ESM import statement."),
|
|
43
|
+
};
|
|
44
|
+
const toTitleCase = (s) => s
|
|
45
|
+
.split(' ')
|
|
46
|
+
.map((part) => (part ? part[0].toUpperCase() + part.slice(1) : part))
|
|
47
|
+
.join(' ');
|
|
48
|
+
server.registerTool('list_icon_components', {
|
|
49
|
+
title: 'List Icon Components',
|
|
50
|
+
description: "List stand‑alone icon Web Components for a single variant from the local index (read-only, offline, deterministic). These are custom elements you can import and use directly. Examples:\nimport '@mdui/icons/search.js'\nimport '@mdui/icons/search--outlined.js'\n<mdui-icon-search></mdui-icon-search>\n<mdui-icon-search--outlined></mdui-icon-search--outlined>\n\nOutput: array of { name, tagName, import }.\n- name: human-readable label.\n- tagName: custom element tag.\n- import: ESM statement to register the element.\n\nDiffers from list_icon_codes: this returns component tags/import statements, not attribute codes.\n\nInput: optional 'variant' — one of 'filled' (default), 'outlined', 'rounded', 'sharp', 'two-tone'; optional 'query' — case-insensitive substring filter applied to the human-readable name or the tagName; and 'limit' — maximum number of results to return (1–5000, default: all).",
|
|
51
|
+
inputSchema,
|
|
52
|
+
outputSchema,
|
|
53
|
+
}, async ({ variant, query, limit, }) => {
|
|
54
|
+
const v = variant ?? 'filled';
|
|
55
|
+
const q = query?.toLowerCase();
|
|
56
|
+
let list = icons.map((n) => {
|
|
57
|
+
const display = toTitleCase(n.replace(/_/g, ' '));
|
|
58
|
+
const base = n.replace(/_/g, '-');
|
|
59
|
+
const suffix = v === 'filled' ? '' : `--${v}`;
|
|
60
|
+
const tagName = `mdui-icon-${base}${suffix}`;
|
|
61
|
+
const importStmt = `import '@mdui/icons/${base}${suffix}.js';`;
|
|
62
|
+
return { name: display, tagName, import: importStmt };
|
|
63
|
+
});
|
|
64
|
+
if (q) {
|
|
65
|
+
list = list.filter((it) => it.name.toLowerCase().includes(q) ||
|
|
66
|
+
it.tagName.toLowerCase().includes(q));
|
|
67
|
+
}
|
|
68
|
+
if (typeof limit === 'number') {
|
|
69
|
+
list = list.slice(0, limit);
|
|
70
|
+
}
|
|
71
|
+
const result = { icons: list };
|
|
72
|
+
return {
|
|
73
|
+
structuredContent: result,
|
|
74
|
+
content: [
|
|
75
|
+
{ type: 'text', text: JSON.stringify(result, null, 2) },
|
|
76
|
+
],
|
|
77
|
+
};
|
|
78
|
+
});
|
|
79
|
+
}
|