@nysds/mcp-server 1.0.0 → 1.14.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.
Files changed (43) hide show
  1. package/dist/index.d.ts +9 -0
  2. package/dist/index.d.ts.map +1 -0
  3. package/dist/index.js +16 -0
  4. package/dist/lib/cem-parser.d.ts +96 -0
  5. package/dist/lib/cem-parser.d.ts.map +1 -0
  6. package/dist/lib/cem-parser.js +82 -0
  7. package/dist/lib/search.d.ts +20 -0
  8. package/dist/lib/search.d.ts.map +1 -0
  9. package/dist/lib/search.js +87 -0
  10. package/dist/lib/token-parser.d.ts +140 -0
  11. package/dist/lib/token-parser.d.ts.map +1 -0
  12. package/dist/lib/token-parser.js +458 -0
  13. package/dist/prompts/nysds-mode.d.ts +8 -0
  14. package/dist/prompts/nysds-mode.d.ts.map +1 -0
  15. package/dist/prompts/nysds-mode.js +51 -0
  16. package/dist/resources/components.d.ts +12 -0
  17. package/dist/resources/components.d.ts.map +1 -0
  18. package/dist/resources/components.js +62 -0
  19. package/dist/resources/guides.d.ts +11 -0
  20. package/dist/resources/guides.d.ts.map +1 -0
  21. package/dist/resources/guides.js +80 -0
  22. package/dist/resources/index.d.ts +8 -0
  23. package/dist/resources/index.d.ts.map +1 -0
  24. package/dist/resources/index.js +13 -0
  25. package/dist/resources/tokens.d.ts +17 -0
  26. package/dist/resources/tokens.d.ts.map +1 -0
  27. package/dist/resources/tokens.js +312 -0
  28. package/dist/server.d.ts +11 -0
  29. package/dist/server.d.ts.map +1 -0
  30. package/dist/server.js +30 -0
  31. package/dist/tools/component-tools.d.ts +14 -0
  32. package/dist/tools/component-tools.d.ts.map +1 -0
  33. package/dist/tools/component-tools.js +127 -0
  34. package/dist/tools/index.d.ts +8 -0
  35. package/dist/tools/index.d.ts.map +1 -0
  36. package/dist/tools/index.js +13 -0
  37. package/dist/tools/token-tools.d.ts +17 -0
  38. package/dist/tools/token-tools.d.ts.map +1 -0
  39. package/dist/tools/token-tools.js +504 -0
  40. package/dist/tools/validation-tools.d.ts +12 -0
  41. package/dist/tools/validation-tools.d.ts.map +1 -0
  42. package/dist/tools/validation-tools.js +222 -0
  43. package/package.json +1 -1
@@ -0,0 +1,222 @@
1
+ /**
2
+ * Validation Tools
3
+ *
4
+ * MCP tools for validating NYSDS component usage.
5
+ *
6
+ * P1 Tools:
7
+ * - validate_component_api: Validate prop/attribute usage
8
+ * - setup_framework: Framework-specific guides
9
+ */
10
+ import { z } from "zod";
11
+ import { getComponent } from "../lib/cem-parser.js";
12
+ export function registerValidationTools(server) {
13
+ // validate_component_api - Validate prop/attribute usage
14
+ server.tool("validate_component_api", "Validate that the provided attributes/properties are valid for a given NYSDS component", {
15
+ tagName: z
16
+ .string()
17
+ .describe("The tag name of the component (e.g., 'nys-button')"),
18
+ attributes: z
19
+ .record(z.string())
20
+ .describe("Object of attribute names and values to validate"),
21
+ }, async ({ tagName, attributes }) => {
22
+ const component = getComponent(tagName);
23
+ if (!component) {
24
+ return {
25
+ content: [
26
+ {
27
+ type: "text",
28
+ text: `Component "${tagName}" not found.`,
29
+ },
30
+ ],
31
+ isError: true,
32
+ };
33
+ }
34
+ const validAttributes = new Set(component.attributes?.map((a) => a.name) || []);
35
+ const validProperties = new Set(component.members
36
+ ?.filter((m) => m.kind === "field")
37
+ .map((m) => m.name) || []);
38
+ const errors = [];
39
+ const warnings = [];
40
+ for (const attr of Object.keys(attributes)) {
41
+ if (!validAttributes.has(attr) && !validProperties.has(attr)) {
42
+ errors.push(`Unknown attribute/property: "${attr}"`);
43
+ }
44
+ }
45
+ const result = {
46
+ valid: errors.length === 0,
47
+ errors,
48
+ warnings,
49
+ validAttributes: Array.from(validAttributes),
50
+ validProperties: Array.from(validProperties),
51
+ };
52
+ return {
53
+ content: [
54
+ {
55
+ type: "text",
56
+ text: JSON.stringify(result, null, 2),
57
+ },
58
+ ],
59
+ };
60
+ });
61
+ // setup_framework - Framework-specific guides
62
+ server.tool("setup_framework", "Get framework-specific setup guide for using NYSDS components", {
63
+ framework: z
64
+ .enum(["angular", "react", "vue", "dotnet", "drupal", "vanilla"])
65
+ .describe("The framework to get setup instructions for"),
66
+ }, async ({ framework }) => {
67
+ // TODO: Load from data/guides/ directory
68
+ const guides = {
69
+ vanilla: `# NYSDS with Vanilla JavaScript
70
+
71
+ ## Installation
72
+
73
+ \`\`\`bash
74
+ npm install @nysds/components
75
+ \`\`\`
76
+
77
+ ## Usage
78
+
79
+ \`\`\`html
80
+ <script type="module">
81
+ import '@nysds/components';
82
+ </script>
83
+
84
+ <nys-button label="Click me"></nys-button>
85
+ \`\`\`
86
+ `,
87
+ react: `# NYSDS with React
88
+
89
+ ## Installation
90
+
91
+ \`\`\`bash
92
+ npm install @nysds/components
93
+ \`\`\`
94
+
95
+ ## Usage
96
+
97
+ \`\`\`jsx
98
+ import '@nysds/components/nys-button';
99
+
100
+ function App() {
101
+ return <nys-button label="Click me" />;
102
+ }
103
+ \`\`\`
104
+
105
+ Note: Web components work in React but require property binding for complex types.
106
+ `,
107
+ angular: `# NYSDS with Angular
108
+
109
+ ## Installation
110
+
111
+ \`\`\`bash
112
+ npm install @nysds/components
113
+ \`\`\`
114
+
115
+ ## Configuration
116
+
117
+ Add CUSTOM_ELEMENTS_SCHEMA to your module:
118
+
119
+ \`\`\`typescript
120
+ import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
121
+
122
+ @NgModule({
123
+ schemas: [CUSTOM_ELEMENTS_SCHEMA]
124
+ })
125
+ export class AppModule {}
126
+ \`\`\`
127
+
128
+ ## Usage
129
+
130
+ \`\`\`typescript
131
+ import '@nysds/components/nys-button';
132
+ \`\`\`
133
+
134
+ \`\`\`html
135
+ <nys-button label="Click me"></nys-button>
136
+ \`\`\`
137
+ `,
138
+ vue: `# NYSDS with Vue
139
+
140
+ ## Installation
141
+
142
+ \`\`\`bash
143
+ npm install @nysds/components
144
+ \`\`\`
145
+
146
+ ## Configuration
147
+
148
+ Configure Vue to recognize custom elements:
149
+
150
+ \`\`\`javascript
151
+ // vite.config.js
152
+ export default {
153
+ plugins: [
154
+ vue({
155
+ template: {
156
+ compilerOptions: {
157
+ isCustomElement: (tag) => tag.startsWith('nys-')
158
+ }
159
+ }
160
+ })
161
+ ]
162
+ }
163
+ \`\`\`
164
+
165
+ ## Usage
166
+
167
+ \`\`\`vue
168
+ <script setup>
169
+ import '@nysds/components/nys-button';
170
+ </script>
171
+
172
+ <template>
173
+ <nys-button label="Click me" />
174
+ </template>
175
+ \`\`\`
176
+ `,
177
+ dotnet: `# NYSDS with .NET / Blazor
178
+
179
+ ## Installation
180
+
181
+ Add the package via npm or include from CDN:
182
+
183
+ \`\`\`html
184
+ <script type="module" src="https://cdn.jsdelivr.net/npm/@nysds/components"></script>
185
+ \`\`\`
186
+
187
+ ## Usage in Razor
188
+
189
+ \`\`\`razor
190
+ <nys-button label="Click me"></nys-button>
191
+ \`\`\`
192
+ `,
193
+ drupal: `# NYSDS with Drupal
194
+
195
+ ## Installation
196
+
197
+ Add the library to your theme's libraries.yml:
198
+
199
+ \`\`\`yaml
200
+ nysds:
201
+ js:
202
+ https://cdn.jsdelivr.net/npm/@nysds/components: { type: external, minified: true }
203
+ \`\`\`
204
+
205
+ ## Usage in Twig
206
+
207
+ \`\`\`twig
208
+ <nys-button label="{{ 'Click me'|t }}"></nys-button>
209
+ \`\`\`
210
+ `,
211
+ };
212
+ const guide = guides[framework] || `No guide available for ${framework}`;
213
+ return {
214
+ content: [
215
+ {
216
+ type: "text",
217
+ text: guide,
218
+ },
219
+ ],
220
+ };
221
+ });
222
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nysds/mcp-server",
3
- "version": "1.0.0",
3
+ "version": "1.14.0",
4
4
  "description": "MCP server for the New York State Design System. Exposes components, tokens, and documentation to AI assistants.",
5
5
  "type": "module",
6
6
  "bin": {