@cobwds/mcp-server 1.19.3
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/README.md +235 -0
- package/data/cem/custom-elements.json +15923 -0
- package/data/guides/.gitkeep +0 -0
- package/data/guides/fonts.md +56 -0
- package/data/guides/form-validation.md +169 -0
- package/data/guides/frameworks/angular.md +71 -0
- package/data/guides/frameworks/dotnet.md +42 -0
- package/data/guides/frameworks/drupal.md +39 -0
- package/data/guides/frameworks/react.md +115 -0
- package/data/guides/frameworks/vanilla.md +45 -0
- package/data/guides/installation.md +73 -0
- package/data/guides/page-structure.md +161 -0
- package/data/guides/styles.md +48 -0
- package/data/guides/themes.md +61 -0
- package/data/tokens/tokens.css +479 -0
- package/data/tokens/tokens.json +1553 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/lib/cem-parser.d.ts +102 -0
- package/dist/lib/cem-parser.d.ts.map +1 -0
- package/dist/lib/cem-parser.js +92 -0
- package/dist/lib/search.d.ts +20 -0
- package/dist/lib/search.d.ts.map +1 -0
- package/dist/lib/search.js +87 -0
- package/dist/lib/token-parser.d.ts +128 -0
- package/dist/lib/token-parser.d.ts.map +1 -0
- package/dist/lib/token-parser.js +431 -0
- package/dist/prompts/cobwds-mode.d.ts +8 -0
- package/dist/prompts/cobwds-mode.d.ts.map +1 -0
- package/dist/prompts/cobwds-mode.js +60 -0
- package/dist/resources/components.d.ts +12 -0
- package/dist/resources/components.d.ts.map +1 -0
- package/dist/resources/components.js +62 -0
- package/dist/resources/guides.d.ts +11 -0
- package/dist/resources/guides.d.ts.map +1 -0
- package/dist/resources/guides.js +76 -0
- package/dist/resources/index.d.ts +8 -0
- package/dist/resources/index.d.ts.map +1 -0
- package/dist/resources/index.js +13 -0
- package/dist/resources/tokens.d.ts +17 -0
- package/dist/resources/tokens.d.ts.map +1 -0
- package/dist/resources/tokens.js +312 -0
- package/dist/server.d.ts +11 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +30 -0
- package/dist/tools/component-tools.d.ts +12 -0
- package/dist/tools/component-tools.d.ts.map +1 -0
- package/dist/tools/component-tools.js +95 -0
- package/dist/tools/guide-tools.d.ts +9 -0
- package/dist/tools/guide-tools.d.ts.map +1 -0
- package/dist/tools/guide-tools.js +80 -0
- package/dist/tools/index.d.ts +8 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +17 -0
- package/dist/tools/token-tools.d.ts +13 -0
- package/dist/tools/token-tools.d.ts.map +1 -0
- package/dist/tools/token-tools.js +207 -0
- package/dist/tools/utility-tools.d.ts +8 -0
- package/dist/tools/utility-tools.d.ts.map +1 -0
- package/dist/tools/utility-tools.js +293 -0
- package/dist/tools/validation-tools.d.ts +11 -0
- package/dist/tools/validation-tools.d.ts.map +1 -0
- package/dist/tools/validation-tools.js +60 -0
- package/package.json +54 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Resources Registration
|
|
3
|
+
*
|
|
4
|
+
* Registers all COBWDS resources with the MCP server.
|
|
5
|
+
*/
|
|
6
|
+
import { registerComponentResources } from "./components.js";
|
|
7
|
+
import { registerTokenResources } from "./tokens.js";
|
|
8
|
+
import { registerGuideResources } from "./guides.js";
|
|
9
|
+
export function registerResources(server) {
|
|
10
|
+
registerComponentResources(server);
|
|
11
|
+
registerTokenResources(server);
|
|
12
|
+
registerGuideResources(server);
|
|
13
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token Resources
|
|
3
|
+
*
|
|
4
|
+
* MCP resources for COBWDS design tokens.
|
|
5
|
+
*
|
|
6
|
+
* Resources:
|
|
7
|
+
* - cobwds://tokens - All tokens in CSS-centric format
|
|
8
|
+
* - cobwds://tokens/css - Raw tokens.css file content
|
|
9
|
+
* - cobwds://tokens/graph - Token dependency graph with stats
|
|
10
|
+
* - cobwds://tokens/color - Color tokens only
|
|
11
|
+
* - cobwds://tokens/font - Typography tokens
|
|
12
|
+
* - cobwds://tokens/space - Spacing tokens
|
|
13
|
+
* - cobwds://tokens/size - Size tokens
|
|
14
|
+
*/
|
|
15
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
16
|
+
export declare function registerTokenResources(server: McpServer): void;
|
|
17
|
+
//# sourceMappingURL=tokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../src/resources/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AASzE,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAiZ9D"}
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token Resources
|
|
3
|
+
*
|
|
4
|
+
* MCP resources for COBWDS design tokens.
|
|
5
|
+
*
|
|
6
|
+
* Resources:
|
|
7
|
+
* - cobwds://tokens - All tokens in CSS-centric format
|
|
8
|
+
* - cobwds://tokens/css - Raw tokens.css file content
|
|
9
|
+
* - cobwds://tokens/graph - Token dependency graph with stats
|
|
10
|
+
* - cobwds://tokens/color - Color tokens only
|
|
11
|
+
* - cobwds://tokens/font - Typography tokens
|
|
12
|
+
* - cobwds://tokens/space - Spacing tokens
|
|
13
|
+
* - cobwds://tokens/size - Size tokens
|
|
14
|
+
*/
|
|
15
|
+
import { getCSSTokens, getCSSTokensByCategory, getCSSTokenCategories, buildTokenGraph, getTokensCSS, } from "../lib/token-parser.js";
|
|
16
|
+
export function registerTokenResources(server) {
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
// cobwds://tokens - All design tokens in CSS-centric format
|
|
19
|
+
// ---------------------------------------------------------------------------
|
|
20
|
+
server.resource("tokens", "cobwds://tokens", {
|
|
21
|
+
description: "All COBWDS design tokens with CSS variable names, values, and descriptions",
|
|
22
|
+
mimeType: "application/json",
|
|
23
|
+
}, async () => {
|
|
24
|
+
const tokens = getCSSTokens();
|
|
25
|
+
const categories = getCSSTokenCategories();
|
|
26
|
+
const formatted = tokens.map((t) => ({
|
|
27
|
+
cssVariable: t.cssVariable,
|
|
28
|
+
cssValue: t.cssValue,
|
|
29
|
+
referencesVariable: t.referencesVariable,
|
|
30
|
+
resolvedValue: t.resolvedValue,
|
|
31
|
+
description: t.description,
|
|
32
|
+
category: t.category,
|
|
33
|
+
layer: t.layer,
|
|
34
|
+
}));
|
|
35
|
+
return {
|
|
36
|
+
contents: [
|
|
37
|
+
{
|
|
38
|
+
uri: "cobwds://tokens",
|
|
39
|
+
mimeType: "application/json",
|
|
40
|
+
text: JSON.stringify({
|
|
41
|
+
totalTokens: tokens.length,
|
|
42
|
+
categories: categories.map((c) => c.category),
|
|
43
|
+
tokens: formatted,
|
|
44
|
+
}, null, 2),
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
// ---------------------------------------------------------------------------
|
|
50
|
+
// cobwds://tokens/css - Raw tokens.css file content
|
|
51
|
+
// ---------------------------------------------------------------------------
|
|
52
|
+
server.resource("tokens-css", "cobwds://tokens/css", {
|
|
53
|
+
description: "Raw tokens.css file content for direct CSS usage",
|
|
54
|
+
mimeType: "text/css",
|
|
55
|
+
}, async () => {
|
|
56
|
+
const css = getTokensCSS();
|
|
57
|
+
if (!css) {
|
|
58
|
+
return {
|
|
59
|
+
contents: [
|
|
60
|
+
{
|
|
61
|
+
uri: "cobwds://tokens/css",
|
|
62
|
+
mimeType: "text/plain",
|
|
63
|
+
text: "/* tokens.css not found. Run 'npm run build -w packages/tokens' to generate. */",
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
contents: [
|
|
70
|
+
{
|
|
71
|
+
uri: "cobwds://tokens/css",
|
|
72
|
+
mimeType: "text/css",
|
|
73
|
+
text: css,
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
// ---------------------------------------------------------------------------
|
|
79
|
+
// cobwds://tokens/graph - Token dependency graph with stats
|
|
80
|
+
// ---------------------------------------------------------------------------
|
|
81
|
+
server.resource("tokens-graph", "cobwds://tokens/graph", {
|
|
82
|
+
description: "Token dependency graph showing which tokens reference which and usage statistics",
|
|
83
|
+
mimeType: "application/json",
|
|
84
|
+
}, async () => {
|
|
85
|
+
const graph = buildTokenGraph();
|
|
86
|
+
const nodes = Array.from(graph.values());
|
|
87
|
+
// Calculate statistics
|
|
88
|
+
const aliasTokens = nodes.filter((n) => n.referencesVariable);
|
|
89
|
+
const primitiveTokens = nodes.filter((n) => !n.referencesVariable);
|
|
90
|
+
const usedTokens = nodes.filter((n) => n.usedBy.length > 0);
|
|
91
|
+
// Find most referenced tokens
|
|
92
|
+
const mostReferenced = [...usedTokens]
|
|
93
|
+
.sort((a, b) => b.usedBy.length - a.usedBy.length)
|
|
94
|
+
.slice(0, 10)
|
|
95
|
+
.map((n) => ({
|
|
96
|
+
cssVariable: n.cssVariable,
|
|
97
|
+
usedByCount: n.usedBy.length,
|
|
98
|
+
usedBy: n.usedBy.slice(0, 5),
|
|
99
|
+
}));
|
|
100
|
+
// Build a simplified graph representation
|
|
101
|
+
const graphData = nodes
|
|
102
|
+
.filter((n) => n.referencesVariable || n.usedBy.length > 0)
|
|
103
|
+
.map((n) => ({
|
|
104
|
+
cssVariable: n.cssVariable,
|
|
105
|
+
referencesVariable: n.referencesVariable,
|
|
106
|
+
usedBy: n.usedBy.length > 0 ? n.usedBy : undefined,
|
|
107
|
+
}));
|
|
108
|
+
return {
|
|
109
|
+
contents: [
|
|
110
|
+
{
|
|
111
|
+
uri: "cobwds://tokens/graph",
|
|
112
|
+
mimeType: "application/json",
|
|
113
|
+
text: JSON.stringify({
|
|
114
|
+
stats: {
|
|
115
|
+
totalTokens: nodes.length,
|
|
116
|
+
aliasTokens: aliasTokens.length,
|
|
117
|
+
primitiveTokens: primitiveTokens.length,
|
|
118
|
+
tokensWithDependents: usedTokens.length,
|
|
119
|
+
},
|
|
120
|
+
mostReferenced,
|
|
121
|
+
graph: graphData,
|
|
122
|
+
}, null, 2),
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
};
|
|
126
|
+
});
|
|
127
|
+
// ---------------------------------------------------------------------------
|
|
128
|
+
// cobwds://tokens/color - Color tokens only
|
|
129
|
+
// ---------------------------------------------------------------------------
|
|
130
|
+
server.resource("tokens-color", "cobwds://tokens/color", {
|
|
131
|
+
description: "All COBWDS color tokens including primitives, semantic colors, and theme colors",
|
|
132
|
+
mimeType: "application/json",
|
|
133
|
+
}, async () => {
|
|
134
|
+
const tokens = getCSSTokensByCategory("color");
|
|
135
|
+
// Group by layer for better organization
|
|
136
|
+
const primitive = tokens.filter((t) => t.layer === "primitive");
|
|
137
|
+
const applied = tokens.filter((t) => t.layer === "applied");
|
|
138
|
+
const base = tokens.filter((t) => t.layer === "base" || t.layer === "color");
|
|
139
|
+
const formatToken = (t) => ({
|
|
140
|
+
cssVariable: t.cssVariable,
|
|
141
|
+
cssValue: t.cssValue,
|
|
142
|
+
referencesVariable: t.referencesVariable,
|
|
143
|
+
resolvedValue: t.resolvedValue,
|
|
144
|
+
description: t.description,
|
|
145
|
+
});
|
|
146
|
+
return {
|
|
147
|
+
contents: [
|
|
148
|
+
{
|
|
149
|
+
uri: "cobwds://tokens/color",
|
|
150
|
+
mimeType: "application/json",
|
|
151
|
+
text: JSON.stringify({
|
|
152
|
+
totalColors: tokens.length,
|
|
153
|
+
layers: {
|
|
154
|
+
primitive: {
|
|
155
|
+
count: primitive.length,
|
|
156
|
+
description: "Raw color values - reference these via applied tokens",
|
|
157
|
+
tokens: primitive.map(formatToken),
|
|
158
|
+
},
|
|
159
|
+
applied: {
|
|
160
|
+
count: applied.length,
|
|
161
|
+
description: "Semantic color tokens - use these in code",
|
|
162
|
+
tokens: applied.map(formatToken),
|
|
163
|
+
},
|
|
164
|
+
theme: {
|
|
165
|
+
count: base.length,
|
|
166
|
+
description: "Theme-aware colors that change per agency",
|
|
167
|
+
tokens: base.map(formatToken),
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
}, null, 2),
|
|
171
|
+
},
|
|
172
|
+
],
|
|
173
|
+
};
|
|
174
|
+
});
|
|
175
|
+
// ---------------------------------------------------------------------------
|
|
176
|
+
// cobwds://tokens/font - Typography tokens
|
|
177
|
+
// ---------------------------------------------------------------------------
|
|
178
|
+
server.resource("tokens-font", "cobwds://tokens/font", {
|
|
179
|
+
description: "All COBWDS typography tokens including font families, sizes, weights, and line heights",
|
|
180
|
+
mimeType: "application/json",
|
|
181
|
+
}, async () => {
|
|
182
|
+
const tokens = getCSSTokensByCategory("font");
|
|
183
|
+
// Group by subcategory based on CSS variable name
|
|
184
|
+
const families = tokens.filter((t) => t.cssVariable.includes("-font-family-"));
|
|
185
|
+
const sizes = tokens.filter((t) => t.cssVariable.includes("-font-size-"));
|
|
186
|
+
const weights = tokens.filter((t) => t.cssVariable.includes("-font-weight-"));
|
|
187
|
+
const lineHeights = tokens.filter((t) => t.cssVariable.includes("-font-lineheight-"));
|
|
188
|
+
const letterSpacing = tokens.filter((t) => t.cssVariable.includes("-font-letterspacing-"));
|
|
189
|
+
const formatToken = (t) => ({
|
|
190
|
+
cssVariable: t.cssVariable,
|
|
191
|
+
cssValue: t.cssValue,
|
|
192
|
+
resolvedValue: t.resolvedValue,
|
|
193
|
+
description: t.description,
|
|
194
|
+
});
|
|
195
|
+
return {
|
|
196
|
+
contents: [
|
|
197
|
+
{
|
|
198
|
+
uri: "cobwds://tokens/font",
|
|
199
|
+
mimeType: "application/json",
|
|
200
|
+
text: JSON.stringify({
|
|
201
|
+
totalTypography: tokens.length,
|
|
202
|
+
groups: {
|
|
203
|
+
families: {
|
|
204
|
+
count: families.length,
|
|
205
|
+
description: "Font family stacks",
|
|
206
|
+
tokens: families.map(formatToken),
|
|
207
|
+
},
|
|
208
|
+
sizes: {
|
|
209
|
+
count: sizes.length,
|
|
210
|
+
description: "Font sizes for different contexts",
|
|
211
|
+
tokens: sizes.map(formatToken),
|
|
212
|
+
},
|
|
213
|
+
weights: {
|
|
214
|
+
count: weights.length,
|
|
215
|
+
description: "Font weight values",
|
|
216
|
+
tokens: weights.map(formatToken),
|
|
217
|
+
},
|
|
218
|
+
lineHeights: {
|
|
219
|
+
count: lineHeights.length,
|
|
220
|
+
description: "Line height values",
|
|
221
|
+
tokens: lineHeights.map(formatToken),
|
|
222
|
+
},
|
|
223
|
+
letterSpacing: {
|
|
224
|
+
count: letterSpacing.length,
|
|
225
|
+
description: "Letter spacing adjustments",
|
|
226
|
+
tokens: letterSpacing.map(formatToken),
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
}, null, 2),
|
|
230
|
+
},
|
|
231
|
+
],
|
|
232
|
+
};
|
|
233
|
+
});
|
|
234
|
+
// ---------------------------------------------------------------------------
|
|
235
|
+
// cobwds://tokens/space - Spacing tokens
|
|
236
|
+
// ---------------------------------------------------------------------------
|
|
237
|
+
server.resource("tokens-space", "cobwds://tokens/space", {
|
|
238
|
+
description: "All COBWDS spacing tokens for margins, padding, and gaps. Based on an 8px grid.",
|
|
239
|
+
mimeType: "application/json",
|
|
240
|
+
}, async () => {
|
|
241
|
+
const tokens = getCSSTokensByCategory("space");
|
|
242
|
+
const formatToken = (t) => ({
|
|
243
|
+
cssVariable: t.cssVariable,
|
|
244
|
+
cssValue: t.cssValue,
|
|
245
|
+
resolvedValue: t.resolvedValue,
|
|
246
|
+
description: t.description,
|
|
247
|
+
});
|
|
248
|
+
// Sort by numeric value if possible
|
|
249
|
+
const sorted = [...tokens].sort((a, b) => {
|
|
250
|
+
const aNum = parseFloat(a.resolvedValue || "0");
|
|
251
|
+
const bNum = parseFloat(b.resolvedValue || "0");
|
|
252
|
+
return aNum - bNum;
|
|
253
|
+
});
|
|
254
|
+
return {
|
|
255
|
+
contents: [
|
|
256
|
+
{
|
|
257
|
+
uri: "cobwds://tokens/space",
|
|
258
|
+
mimeType: "application/json",
|
|
259
|
+
text: JSON.stringify({
|
|
260
|
+
totalSpacing: tokens.length,
|
|
261
|
+
description: "Spacing scale based on 8px base unit. Use for margins, padding, and gaps.",
|
|
262
|
+
tokens: sorted.map(formatToken),
|
|
263
|
+
usage: {
|
|
264
|
+
padding: "padding: var(--cob-space-200);",
|
|
265
|
+
margin: "margin-block: var(--cob-space-400);",
|
|
266
|
+
gap: "gap: var(--cob-space-100);",
|
|
267
|
+
},
|
|
268
|
+
}, null, 2),
|
|
269
|
+
},
|
|
270
|
+
],
|
|
271
|
+
};
|
|
272
|
+
});
|
|
273
|
+
// ---------------------------------------------------------------------------
|
|
274
|
+
// cobwds://tokens/size - Size tokens
|
|
275
|
+
// ---------------------------------------------------------------------------
|
|
276
|
+
server.resource("tokens-size", "cobwds://tokens/size", {
|
|
277
|
+
description: "All COBWDS size tokens for widths, heights, and component dimensions",
|
|
278
|
+
mimeType: "application/json",
|
|
279
|
+
}, async () => {
|
|
280
|
+
const tokens = getCSSTokensByCategory("size");
|
|
281
|
+
const formatToken = (t) => ({
|
|
282
|
+
cssVariable: t.cssVariable,
|
|
283
|
+
cssValue: t.cssValue,
|
|
284
|
+
resolvedValue: t.resolvedValue,
|
|
285
|
+
description: t.description,
|
|
286
|
+
});
|
|
287
|
+
// Sort by numeric value if possible
|
|
288
|
+
const sorted = [...tokens].sort((a, b) => {
|
|
289
|
+
const aNum = parseFloat(a.resolvedValue || "0");
|
|
290
|
+
const bNum = parseFloat(b.resolvedValue || "0");
|
|
291
|
+
return aNum - bNum;
|
|
292
|
+
});
|
|
293
|
+
return {
|
|
294
|
+
contents: [
|
|
295
|
+
{
|
|
296
|
+
uri: "cobwds://tokens/size",
|
|
297
|
+
mimeType: "application/json",
|
|
298
|
+
text: JSON.stringify({
|
|
299
|
+
totalSizes: tokens.length,
|
|
300
|
+
description: "Size tokens for component dimensions, icon sizes, and fixed widths/heights.",
|
|
301
|
+
tokens: sorted.map(formatToken),
|
|
302
|
+
usage: {
|
|
303
|
+
iconSize: "width: var(--cob-size-200); height: var(--cob-size-200);",
|
|
304
|
+
minHeight: "min-height: var(--cob-size-400);",
|
|
305
|
+
componentSize: "inline-size: var(--cob-size-600);",
|
|
306
|
+
},
|
|
307
|
+
}, null, 2),
|
|
308
|
+
},
|
|
309
|
+
],
|
|
310
|
+
};
|
|
311
|
+
});
|
|
312
|
+
}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* COBWDS MCP Server Setup
|
|
3
|
+
*
|
|
4
|
+
* Configures the MCP server with tools, resources, and prompts
|
|
5
|
+
* for the City of Boston Web Design System.
|
|
6
|
+
*/
|
|
7
|
+
export interface CobwdsMcpServer {
|
|
8
|
+
start(): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
export declare function createServer(): Promise<CobwdsMcpServer>;
|
|
11
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAWH,MAAM,WAAW,eAAe;IAC9B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED,wBAAsB,YAAY,IAAI,OAAO,CAAC,eAAe,CAAC,CAkB7D"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* COBWDS MCP Server Setup
|
|
3
|
+
*
|
|
4
|
+
* Configures the MCP server with tools, resources, and prompts
|
|
5
|
+
* for the City of Boston Web Design System.
|
|
6
|
+
*/
|
|
7
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
8
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
9
|
+
import { registerTools } from "./tools/index.js";
|
|
10
|
+
import { registerResources } from "./resources/index.js";
|
|
11
|
+
import { registerPrompts } from "./prompts/cobwds-mode.js";
|
|
12
|
+
const SERVER_NAME = "cobwds-mcp";
|
|
13
|
+
const SERVER_VERSION = "1.0.0";
|
|
14
|
+
export async function createServer() {
|
|
15
|
+
const server = new McpServer({
|
|
16
|
+
name: SERVER_NAME,
|
|
17
|
+
version: SERVER_VERSION,
|
|
18
|
+
});
|
|
19
|
+
// Register all capabilities
|
|
20
|
+
registerTools(server);
|
|
21
|
+
registerResources(server);
|
|
22
|
+
registerPrompts(server);
|
|
23
|
+
return {
|
|
24
|
+
async start() {
|
|
25
|
+
const transport = new StdioServerTransport();
|
|
26
|
+
await server.connect(transport);
|
|
27
|
+
console.error(`${SERVER_NAME} v${SERVER_VERSION} started`);
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component Tools
|
|
3
|
+
*
|
|
4
|
+
* MCP tools for working with COBWDS components.
|
|
5
|
+
*
|
|
6
|
+
* Tools:
|
|
7
|
+
* - find_components: Search or list all components
|
|
8
|
+
* - get_component: Full documentation for a specific component
|
|
9
|
+
*/
|
|
10
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
11
|
+
export declare function registerComponentTools(server: McpServer): void;
|
|
12
|
+
//# sourceMappingURL=component-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-tools.d.ts","sourceRoot":"","sources":["../../src/tools/component-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAIzE,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CA+G9D"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component Tools
|
|
3
|
+
*
|
|
4
|
+
* MCP tools for working with COBWDS components.
|
|
5
|
+
*
|
|
6
|
+
* Tools:
|
|
7
|
+
* - find_components: Search or list all components
|
|
8
|
+
* - get_component: Full documentation for a specific component
|
|
9
|
+
*/
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
import { getComponent, getAllComponents } from "../lib/cem-parser.js";
|
|
12
|
+
import { searchComponents } from "../lib/search.js";
|
|
13
|
+
export function registerComponentTools(server) {
|
|
14
|
+
// find_components - Search or list all components
|
|
15
|
+
server.tool("find_components", "Search for COBWDS components by name or description. Omit query to list all components.", {
|
|
16
|
+
query: z
|
|
17
|
+
.string()
|
|
18
|
+
.optional()
|
|
19
|
+
.describe("Search query to match against component names and descriptions. Omit to list all components."),
|
|
20
|
+
}, async ({ query }) => {
|
|
21
|
+
// If no query, return all components
|
|
22
|
+
if (!query || query.trim() === "") {
|
|
23
|
+
const components = getAllComponents();
|
|
24
|
+
const list = components.map((c) => ({
|
|
25
|
+
tagName: c.tagName,
|
|
26
|
+
name: c.name,
|
|
27
|
+
summary: c.summary || c.description?.split("\n")[0] || "No description",
|
|
28
|
+
resourceUri: `cobwds://component/${c.tagName}`,
|
|
29
|
+
}));
|
|
30
|
+
return {
|
|
31
|
+
content: [
|
|
32
|
+
{
|
|
33
|
+
type: "text",
|
|
34
|
+
text: JSON.stringify(list, null, 2),
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
// Otherwise search
|
|
40
|
+
const results = searchComponents(query).map((r) => ({
|
|
41
|
+
...r,
|
|
42
|
+
resourceUri: `cobwds://component/${r.tagName}`,
|
|
43
|
+
}));
|
|
44
|
+
return {
|
|
45
|
+
content: [
|
|
46
|
+
{
|
|
47
|
+
type: "text",
|
|
48
|
+
text: JSON.stringify(results, null, 2),
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
// get_component - Full documentation for a specific component
|
|
54
|
+
server.tool("get_component", "Get full documentation for a specific COBWDS component including properties, events, slots, and CSS custom properties", {
|
|
55
|
+
tagName: z
|
|
56
|
+
.string()
|
|
57
|
+
.describe("The tag name of the component (e.g., 'cob-button')"),
|
|
58
|
+
includeExamples: z
|
|
59
|
+
.boolean()
|
|
60
|
+
.default(false)
|
|
61
|
+
.describe("Include HTML code examples from component JSDoc. Set to true when you need usage patterns."),
|
|
62
|
+
}, async ({ tagName, includeExamples }) => {
|
|
63
|
+
const component = getComponent(tagName);
|
|
64
|
+
if (!component) {
|
|
65
|
+
return {
|
|
66
|
+
content: [
|
|
67
|
+
{
|
|
68
|
+
type: "text",
|
|
69
|
+
text: `Component "${tagName}" not found. Use find_components to see available components.`,
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
isError: true,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
// Remove members array to avoid duplication with attributes
|
|
76
|
+
// Attributes contains the HTML API, members duplicates this plus private methods
|
|
77
|
+
const {
|
|
78
|
+
// members: _members,
|
|
79
|
+
examples, ...componentWithoutMembers } = component;
|
|
80
|
+
return {
|
|
81
|
+
content: [
|
|
82
|
+
{
|
|
83
|
+
type: "text",
|
|
84
|
+
text: JSON.stringify({
|
|
85
|
+
...componentWithoutMembers,
|
|
86
|
+
examples: includeExamples && examples && examples.length > 0
|
|
87
|
+
? examples
|
|
88
|
+
: undefined,
|
|
89
|
+
resourceUri: `cobwds://component/${tagName}`,
|
|
90
|
+
}, null, 2),
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
};
|
|
94
|
+
});
|
|
95
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Guide Tools
|
|
3
|
+
*
|
|
4
|
+
* Consolidated MCP tool for COBWDS guides and documentation.
|
|
5
|
+
* Loads guide content from data/guides/ markdown files.
|
|
6
|
+
*/
|
|
7
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
8
|
+
export declare function registerGuideTools(server: McpServer): void;
|
|
9
|
+
//# sourceMappingURL=guide-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guide-tools.d.ts","sourceRoot":"","sources":["../../src/tools/guide-tools.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AA8CzE,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CA0C1D"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Guide Tools
|
|
3
|
+
*
|
|
4
|
+
* Consolidated MCP tool for COBWDS guides and documentation.
|
|
5
|
+
* Loads guide content from data/guides/ markdown files.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
import { readFileSync } from "fs";
|
|
9
|
+
import { join, dirname } from "path";
|
|
10
|
+
import { fileURLToPath } from "url";
|
|
11
|
+
// ESM-compatible __dirname
|
|
12
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
+
const __dirname = dirname(__filename);
|
|
14
|
+
// Path to guides directory (relative to dist/tools/)
|
|
15
|
+
const GUIDES_DIR = join(__dirname, "../../data/guides");
|
|
16
|
+
/**
|
|
17
|
+
* Load a guide markdown file
|
|
18
|
+
*/
|
|
19
|
+
function loadGuide(filename) {
|
|
20
|
+
try {
|
|
21
|
+
return readFileSync(join(GUIDES_DIR, filename), "utf-8");
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return `Guide not found: ${filename}`;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Load a framework-specific guide
|
|
29
|
+
*/
|
|
30
|
+
function loadFrameworkGuide(framework) {
|
|
31
|
+
try {
|
|
32
|
+
return readFileSync(join(GUIDES_DIR, "frameworks", `${framework}.md`), "utf-8");
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return `Framework guide not found: ${framework}`;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const TOPIC_TO_FILE = {
|
|
39
|
+
installation: "installation.md",
|
|
40
|
+
"form-validation": "form-validation.md",
|
|
41
|
+
styles: "styles.md",
|
|
42
|
+
fonts: "fonts.md",
|
|
43
|
+
"page-structure": "page-structure.md",
|
|
44
|
+
themes: "themes.md",
|
|
45
|
+
};
|
|
46
|
+
export function registerGuideTools(server) {
|
|
47
|
+
server.tool("get_guide", "Get COBWDS guides for installation, forms, styles, fonts, page structure, themes, or framework setup", {
|
|
48
|
+
topic: z
|
|
49
|
+
.enum([
|
|
50
|
+
"installation",
|
|
51
|
+
"form-validation",
|
|
52
|
+
"styles",
|
|
53
|
+
"fonts",
|
|
54
|
+
"page-structure",
|
|
55
|
+
"themes",
|
|
56
|
+
])
|
|
57
|
+
.describe("The guide topic to retrieve"),
|
|
58
|
+
framework: z
|
|
59
|
+
.enum(["angular", "react", "dotnet", "drupal", "vanilla"])
|
|
60
|
+
.optional()
|
|
61
|
+
.describe("When provided, returns framework-specific setup guide instead of the topic guide. Use with topic 'installation' to get framework install instructions."),
|
|
62
|
+
}, async ({ topic, framework }) => {
|
|
63
|
+
let content;
|
|
64
|
+
if (framework) {
|
|
65
|
+
content = loadFrameworkGuide(framework);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
const filename = TOPIC_TO_FILE[topic];
|
|
69
|
+
content = filename ? loadGuide(filename) : `Unknown topic: ${topic}`;
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
content: [
|
|
73
|
+
{
|
|
74
|
+
type: "text",
|
|
75
|
+
text: content,
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
};
|
|
79
|
+
});
|
|
80
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Tools Registration
|
|
3
|
+
*
|
|
4
|
+
* Registers all COBWDS tools with the MCP server.
|
|
5
|
+
*/
|
|
6
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
7
|
+
export declare function registerTools(server: McpServer): void;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAOzE,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAMrD"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Tools Registration
|
|
3
|
+
*
|
|
4
|
+
* Registers all COBWDS tools with the MCP server.
|
|
5
|
+
*/
|
|
6
|
+
import { registerComponentTools } from "./component-tools.js";
|
|
7
|
+
import { registerTokenTools } from "./token-tools.js";
|
|
8
|
+
import { registerValidationTools } from "./validation-tools.js";
|
|
9
|
+
import { registerUtilityTools } from "./utility-tools.js";
|
|
10
|
+
import { registerGuideTools } from "./guide-tools.js";
|
|
11
|
+
export function registerTools(server) {
|
|
12
|
+
registerComponentTools(server);
|
|
13
|
+
registerTokenTools(server);
|
|
14
|
+
registerValidationTools(server);
|
|
15
|
+
registerUtilityTools(server);
|
|
16
|
+
registerGuideTools(server);
|
|
17
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token Tools
|
|
3
|
+
*
|
|
4
|
+
* MCP tools for working with COBWDS design tokens.
|
|
5
|
+
*
|
|
6
|
+
* Tools:
|
|
7
|
+
* - find_tokens: Search or browse tokens (discovery)
|
|
8
|
+
* - get_token: Get full details for a specific token (deep dive)
|
|
9
|
+
* - get_token_graph: Get token dependency graph
|
|
10
|
+
*/
|
|
11
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
12
|
+
export declare function registerTokenTools(server: McpServer): void;
|
|
13
|
+
//# sourceMappingURL=token-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-tools.d.ts","sourceRoot":"","sources":["../../src/tools/token-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAuCzE,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CA6N1D"}
|