@keystoneui/mcp 0.2.0-beta.5 → 0.2.0-beta.7
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 +10 -10
- package/dist/chunk-NRQEEI2I.js +1373 -0
- package/dist/index.js +142 -90
- package/dist/{server-7ZU3YJ7K.js → server-PR27VI6G.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-TAXPGE7O.js +0 -612
package/dist/index.js
CHANGED
|
@@ -3,14 +3,26 @@ import {
|
|
|
3
3
|
auditChecklistTool,
|
|
4
4
|
detectProjectContext,
|
|
5
5
|
displayUrl,
|
|
6
|
+
escapedError,
|
|
6
7
|
getExamplesTool,
|
|
8
|
+
isCommandSafe,
|
|
7
9
|
listComponentsTool,
|
|
8
10
|
loadProjectConfig,
|
|
11
|
+
lookupManifest,
|
|
12
|
+
nameRefusal,
|
|
13
|
+
parseThemeCode,
|
|
14
|
+
parseThemeParts,
|
|
9
15
|
readPackageVersion,
|
|
10
16
|
redactUrlInError,
|
|
17
|
+
registryCatalogueUrl,
|
|
18
|
+
resolveDocs,
|
|
11
19
|
searchComponentsTool,
|
|
20
|
+
shown,
|
|
21
|
+
themeBuilderUrl,
|
|
22
|
+
themeInstallCommand,
|
|
23
|
+
themeInstallUrl,
|
|
12
24
|
viewComponentTool
|
|
13
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-NRQEEI2I.js";
|
|
14
26
|
|
|
15
27
|
// src/cli.ts
|
|
16
28
|
import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
|
|
@@ -93,7 +105,7 @@ function collect() {
|
|
|
93
105
|
installedPackages: detectInstalledPackages(cwd),
|
|
94
106
|
links: {
|
|
95
107
|
docs: displayUrl(docsUrl),
|
|
96
|
-
registry: displayUrl(
|
|
108
|
+
registry: displayUrl(registryCatalogueUrl(config.registry)),
|
|
97
109
|
llms: displayUrl(`${docsUrl}/llms.txt`)
|
|
98
110
|
}
|
|
99
111
|
};
|
|
@@ -104,6 +116,9 @@ function pad(label, width = 18) {
|
|
|
104
116
|
}
|
|
105
117
|
return label.padEnd(width, " ");
|
|
106
118
|
}
|
|
119
|
+
function shownOr(value) {
|
|
120
|
+
return value === null || value === void 0 ? "(unknown)" : shown(value);
|
|
121
|
+
}
|
|
107
122
|
function printText(data) {
|
|
108
123
|
const lines = [];
|
|
109
124
|
lines.push(`${data.package.name} v${data.package.version}`);
|
|
@@ -111,20 +126,20 @@ function printText(data) {
|
|
|
111
126
|
const p = data.project;
|
|
112
127
|
lines.push("Project");
|
|
113
128
|
lines.push(` ${pad("Install mode")}${p.installMode}`);
|
|
114
|
-
lines.push(` ${pad("UI alias")}${p.aliases?.ui
|
|
115
|
-
lines.push(` ${pad("Theme CSS")}${p.tailwindCssFile
|
|
116
|
-
lines.push(` ${pad("Icon library")}${p.iconLibrary
|
|
129
|
+
lines.push(` ${pad("UI alias")}${shownOr(p.aliases?.ui)}`);
|
|
130
|
+
lines.push(` ${pad("Theme CSS")}${shownOr(p.tailwindCssFile)}`);
|
|
131
|
+
lines.push(` ${pad("Icon library")}${shownOr(p.iconLibrary)}`);
|
|
117
132
|
lines.push(
|
|
118
133
|
` ${pad("RSC")}${p.isRSC === null ? "(unknown)" : String(p.isRSC)}`
|
|
119
134
|
);
|
|
120
|
-
lines.push(` ${pad("Package manager")}${p.packageManager
|
|
135
|
+
lines.push(` ${pad("Package manager")}${shownOr(p.packageManager)}`);
|
|
121
136
|
lines.push("");
|
|
122
137
|
lines.push("Environment");
|
|
123
|
-
lines.push(` ${pad("Node")}${data.environment.node}`);
|
|
124
|
-
lines.push(` ${pad("Platform")}${data.environment.platform}`);
|
|
125
|
-
lines.push(` ${pad("Project root")}${data.environment.cwd}`);
|
|
126
|
-
lines.push(` ${pad("Registry URL")}${data.environment.registryUrl}`);
|
|
127
|
-
lines.push(` ${pad("Docs URL")}${data.environment.docsUrl}`);
|
|
138
|
+
lines.push(` ${pad("Node")}${shown(data.environment.node)}`);
|
|
139
|
+
lines.push(` ${pad("Platform")}${shown(data.environment.platform)}`);
|
|
140
|
+
lines.push(` ${pad("Project root")}${shown(data.environment.cwd)}`);
|
|
141
|
+
lines.push(` ${pad("Registry URL")}${shown(data.environment.registryUrl)}`);
|
|
142
|
+
lines.push(` ${pad("Docs URL")}${shown(data.environment.docsUrl)}`);
|
|
128
143
|
lines.push("");
|
|
129
144
|
lines.push("MCP clients");
|
|
130
145
|
const configured = data.mcpClients.filter((c) => c.configured);
|
|
@@ -132,7 +147,7 @@ function printText(data) {
|
|
|
132
147
|
lines.push(" (none configured for keystoneui)");
|
|
133
148
|
} else {
|
|
134
149
|
for (const client of configured) {
|
|
135
|
-
lines.push(` ${pad(client.name)}${client.configPath}`);
|
|
150
|
+
lines.push(` ${pad(client.name)}${shown(client.configPath)}`);
|
|
136
151
|
}
|
|
137
152
|
}
|
|
138
153
|
lines.push("");
|
|
@@ -141,14 +156,14 @@ function printText(data) {
|
|
|
141
156
|
lines.push(" (none detected in this project)");
|
|
142
157
|
} else {
|
|
143
158
|
for (const pkg of data.installedPackages) {
|
|
144
|
-
lines.push(` ${pad(pkg.name, 28)}v${pkg.version}`);
|
|
159
|
+
lines.push(` ${pad(shown(pkg.name), 28)}v${shown(pkg.version)}`);
|
|
145
160
|
}
|
|
146
161
|
}
|
|
147
162
|
lines.push("");
|
|
148
163
|
lines.push("Links");
|
|
149
|
-
lines.push(` ${pad("Docs")}${data.links.docs}`);
|
|
150
|
-
lines.push(` ${pad("Registry")}${data.links.registry}`);
|
|
151
|
-
lines.push(` ${pad("llms.txt")}${data.links.llms}`);
|
|
164
|
+
lines.push(` ${pad("Docs")}${shown(data.links.docs)}`);
|
|
165
|
+
lines.push(` ${pad("Registry")}${shown(data.links.registry)}`);
|
|
166
|
+
lines.push(` ${pad("llms.txt")}${shown(data.links.llms)}`);
|
|
152
167
|
console.log(lines.join("\n"));
|
|
153
168
|
}
|
|
154
169
|
function runInfo(args) {
|
|
@@ -233,7 +248,11 @@ function mergeJsonConfig(existing, client) {
|
|
|
233
248
|
function writeJsonClient(client) {
|
|
234
249
|
const targetPath = resolve2(process.cwd(), client.configPath);
|
|
235
250
|
const dir = dirname(targetPath);
|
|
236
|
-
|
|
251
|
+
try {
|
|
252
|
+
mkdirSync(dir, { recursive: true });
|
|
253
|
+
} catch (error) {
|
|
254
|
+
throw escapedError(error);
|
|
255
|
+
}
|
|
237
256
|
let existing = {};
|
|
238
257
|
if (existsSync2(targetPath)) {
|
|
239
258
|
try {
|
|
@@ -242,8 +261,12 @@ function writeJsonClient(client) {
|
|
|
242
261
|
}
|
|
243
262
|
}
|
|
244
263
|
const merged = mergeJsonConfig(existing, client);
|
|
245
|
-
|
|
264
|
+
try {
|
|
265
|
+
writeFileSync(targetPath, `${JSON.stringify(merged, null, 2)}
|
|
246
266
|
`);
|
|
267
|
+
} catch (error) {
|
|
268
|
+
throw escapedError(error);
|
|
269
|
+
}
|
|
247
270
|
console.log(`Created ${client.configPath}`);
|
|
248
271
|
console.log(`Keystone UI MCP server configured for ${client.name}.`);
|
|
249
272
|
console.log(TRUST_POINTER);
|
|
@@ -280,7 +303,7 @@ function init() {
|
|
|
280
303
|
}
|
|
281
304
|
const client = CLIENTS.find((c) => c.name === clientName);
|
|
282
305
|
if (!client) {
|
|
283
|
-
console.error(`Unknown client: "${clientName}"`);
|
|
306
|
+
console.error(`Unknown client: "${shown(clientName)}"`);
|
|
284
307
|
console.error("");
|
|
285
308
|
printUsage();
|
|
286
309
|
process.exitCode = 1;
|
|
@@ -293,43 +316,6 @@ function init() {
|
|
|
293
316
|
writeJsonClient(client);
|
|
294
317
|
}
|
|
295
318
|
|
|
296
|
-
// src/theme.ts
|
|
297
|
-
var THEME_CODE_RE = /^k1_([a-z]+)_(\d+(?:\.\d+)?)_(\d+(?:\.\d+)?)_(\d+(?:\.\d+)?)_([a-z]+)_([a-z-]+)$/;
|
|
298
|
-
function parseThemeCode(code) {
|
|
299
|
-
const match = THEME_CODE_RE.exec(code);
|
|
300
|
-
if (!match) {
|
|
301
|
-
return null;
|
|
302
|
-
}
|
|
303
|
-
const [, base, l, c, h, radius, font] = match;
|
|
304
|
-
return { base, font, primary: `oklch(${l} ${c} ${h})`, radius };
|
|
305
|
-
}
|
|
306
|
-
function themeInstallCommand(code, siteUrl, only = []) {
|
|
307
|
-
const query = only.length > 0 ? `?only=${only.join(",")}` : "";
|
|
308
|
-
return `npx shadcn@latest add ${siteUrl}/r/theme/${code}.json${query}`;
|
|
309
|
-
}
|
|
310
|
-
function themeBuilderUrl(code, siteUrl) {
|
|
311
|
-
const match = THEME_CODE_RE.exec(code);
|
|
312
|
-
if (!match) {
|
|
313
|
-
return null;
|
|
314
|
-
}
|
|
315
|
-
const [, base, primaryL, primaryC, primaryH, radius, font] = match;
|
|
316
|
-
const params = new URLSearchParams({
|
|
317
|
-
base,
|
|
318
|
-
primaryL,
|
|
319
|
-
primaryC,
|
|
320
|
-
primaryH,
|
|
321
|
-
radius,
|
|
322
|
-
font
|
|
323
|
-
});
|
|
324
|
-
return `${siteUrl}/theme-builder?${params}`;
|
|
325
|
-
}
|
|
326
|
-
function parseThemeParts(value) {
|
|
327
|
-
if (!value) {
|
|
328
|
-
return [];
|
|
329
|
-
}
|
|
330
|
-
return value.split(",").map((part) => part.trim()).filter((part) => part === "theme" || part === "font");
|
|
331
|
-
}
|
|
332
|
-
|
|
333
319
|
// src/theme-audit.ts
|
|
334
320
|
var TEXT_PAIRS = [
|
|
335
321
|
["foreground", "background"],
|
|
@@ -342,8 +328,14 @@ var TEXT_PAIRS = [
|
|
|
342
328
|
["destructive-foreground", "destructive"],
|
|
343
329
|
["success-foreground", "success"],
|
|
344
330
|
["warning-foreground", "warning"],
|
|
345
|
-
["info-foreground", "info"]
|
|
331
|
+
["info-foreground", "info"],
|
|
332
|
+
["success-text", "background"],
|
|
333
|
+
["warning-text", "background"]
|
|
346
334
|
];
|
|
335
|
+
var TEXT_FALLBACKS = {
|
|
336
|
+
"success-text": "success",
|
|
337
|
+
"warning-text": "warning"
|
|
338
|
+
};
|
|
347
339
|
var AA_TEXT = 4.5;
|
|
348
340
|
var DECLARATION_RE = /--([\w-]+)\s*:\s*([^;]+);/g;
|
|
349
341
|
var OKLCH_RE = /^oklch\(\s*([\d.]+)(%?)\s+([\d.]+)\s+([\d.]+)(?:deg)?\s*\)$/i;
|
|
@@ -457,13 +449,15 @@ function auditTheme(tokens) {
|
|
|
457
449
|
const results = [];
|
|
458
450
|
for (const mode of ["light", "dark"]) {
|
|
459
451
|
for (const [fg, bg] of TEXT_PAIRS) {
|
|
460
|
-
const
|
|
452
|
+
const fallback = tokens[mode][fg] === void 0 ? TEXT_FALLBACKS[fg] : void 0;
|
|
453
|
+
const fgValue = tokens[mode][fallback ?? fg];
|
|
461
454
|
const bgValue = tokens[mode][bg];
|
|
462
455
|
if (!(fgValue && bgValue)) {
|
|
463
456
|
continue;
|
|
464
457
|
}
|
|
465
458
|
const ratio = contrastRatio(fgValue, bgValue);
|
|
466
459
|
results.push({
|
|
460
|
+
...fallback && { fallback },
|
|
467
461
|
mode,
|
|
468
462
|
pair: `${fg} on ${bg}`,
|
|
469
463
|
ratio,
|
|
@@ -475,16 +469,17 @@ function auditTheme(tokens) {
|
|
|
475
469
|
}
|
|
476
470
|
function formatAudit(file, results) {
|
|
477
471
|
if (results.length === 0) {
|
|
478
|
-
return `No keystone token pairs found in ${file}. Pass the CSS file that holds :root and .dark.`;
|
|
472
|
+
return `No keystone token pairs found in ${shown(file)}. Pass the CSS file that holds :root and .dark.`;
|
|
479
473
|
}
|
|
480
474
|
const lines = results.map((r) => {
|
|
481
475
|
const mark = { fail: "\u2716", pass: "\u2714", skip: "\u2013" }[r.status];
|
|
482
476
|
const ratio = r.ratio === null ? "needs a browser" : `${r.ratio.toFixed(2)}:1`;
|
|
483
|
-
|
|
477
|
+
const note = r.fallback ? ` (not declared; measured --${r.fallback}, which paints instead)` : "";
|
|
478
|
+
return `${mark} ${r.mode.padEnd(5)} ${r.pair.padEnd(42)} ${ratio}${note}`;
|
|
484
479
|
});
|
|
485
480
|
const failed = results.filter((r) => r.status === "fail").length;
|
|
486
481
|
return [
|
|
487
|
-
`Theme contrast \u2014 ${file} (WCAG AA for text: ${AA_TEXT}:1)`,
|
|
482
|
+
`Theme contrast \u2014 ${shown(file)} (WCAG AA for text: ${AA_TEXT}:1)`,
|
|
488
483
|
"",
|
|
489
484
|
...lines,
|
|
490
485
|
"",
|
|
@@ -529,24 +524,46 @@ function parseArgs2(args) {
|
|
|
529
524
|
}
|
|
530
525
|
return { flags, positional };
|
|
531
526
|
}
|
|
527
|
+
var TYPES = [
|
|
528
|
+
"ui",
|
|
529
|
+
"block",
|
|
530
|
+
"example",
|
|
531
|
+
"kit",
|
|
532
|
+
"style",
|
|
533
|
+
"theme",
|
|
534
|
+
"item"
|
|
535
|
+
];
|
|
532
536
|
function parseType(value) {
|
|
533
537
|
if (value === void 0) {
|
|
534
538
|
return;
|
|
535
539
|
}
|
|
536
|
-
if (value
|
|
540
|
+
if (TYPES.includes(value)) {
|
|
537
541
|
return value;
|
|
538
542
|
}
|
|
539
543
|
throw new Error(
|
|
540
|
-
`Invalid --type value "${value}". Expected one of:
|
|
544
|
+
`Invalid --type value "${shown(value)}". Expected one of: ${TYPES.join(", ")}.`
|
|
541
545
|
);
|
|
542
546
|
}
|
|
547
|
+
function refuseInvalid(names) {
|
|
548
|
+
const valid = [];
|
|
549
|
+
for (const name of names) {
|
|
550
|
+
const refusal = nameRefusal(name);
|
|
551
|
+
if (refusal) {
|
|
552
|
+
console.error(refusal);
|
|
553
|
+
process.exitCode = 1;
|
|
554
|
+
} else {
|
|
555
|
+
valid.push(name);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
return valid;
|
|
559
|
+
}
|
|
543
560
|
function parseInt10(value, fallback) {
|
|
544
561
|
if (value === void 0) {
|
|
545
562
|
return fallback;
|
|
546
563
|
}
|
|
547
564
|
const n = Number.parseInt(value, 10);
|
|
548
565
|
if (Number.isNaN(n)) {
|
|
549
|
-
throw new Error(`Expected an integer, got "${value}".`);
|
|
566
|
+
throw new Error(`Expected an integer, got "${shown(value)}".`);
|
|
550
567
|
}
|
|
551
568
|
return n;
|
|
552
569
|
}
|
|
@@ -560,24 +577,26 @@ function printUsage2() {
|
|
|
560
577
|
);
|
|
561
578
|
console.log(" search <query> [--type T] [--category C] [--limit N]");
|
|
562
579
|
console.log(
|
|
563
|
-
" Fuzzy search components, blocks, examples"
|
|
580
|
+
" Fuzzy search components, blocks, kits, examples"
|
|
564
581
|
);
|
|
565
582
|
console.log(" list [--type T] [--category C] [--limit N] [--offset N]");
|
|
566
583
|
console.log(
|
|
567
|
-
" List items (T = ui|block|example)"
|
|
584
|
+
" List items (T = ui|block|example|kit|style|theme|item)"
|
|
585
|
+
);
|
|
586
|
+
console.log(
|
|
587
|
+
" view <name> [<name>...] Show source of components, blocks, kits"
|
|
568
588
|
);
|
|
569
|
-
console.log(" view <name> [<name>...] Show component source");
|
|
570
589
|
console.log(
|
|
571
590
|
" examples <name> Show all demos for a component/block"
|
|
572
591
|
);
|
|
573
592
|
console.log(
|
|
574
|
-
" docs <name>
|
|
593
|
+
" docs <name> [--type component|block] Fetch /llms.mdx/docs/{components|blocks}/<name>"
|
|
575
594
|
);
|
|
576
595
|
console.log(
|
|
577
596
|
" audit [--theme [css]] [--strict] Post-install checklist, or measure your theme's contrast"
|
|
578
597
|
);
|
|
579
598
|
console.log(
|
|
580
|
-
" blocks [<filter>] [--category C] List or filter full-page blocks"
|
|
599
|
+
" blocks [<filter>] [--category C] List or filter full-page blocks; an exact block name views it (kits: list --type kit)"
|
|
581
600
|
);
|
|
582
601
|
console.log(
|
|
583
602
|
" theme <code> [--only theme,font] Install a theme-builder code via shadcn"
|
|
@@ -589,7 +608,7 @@ async function runSearch(args) {
|
|
|
589
608
|
const { flags, positional } = parseArgs2(args);
|
|
590
609
|
if (positional.length === 0) {
|
|
591
610
|
console.error(
|
|
592
|
-
"Usage: keystoneui search <query> [--type ui|block|example] [--category C] [--limit N]"
|
|
611
|
+
"Usage: keystoneui search <query> [--type ui|block|example|kit|style|theme|item] [--category C] [--limit N]"
|
|
593
612
|
);
|
|
594
613
|
process.exitCode = 1;
|
|
595
614
|
return;
|
|
@@ -629,8 +648,12 @@ async function runView(args) {
|
|
|
629
648
|
process.exitCode = 1;
|
|
630
649
|
return;
|
|
631
650
|
}
|
|
651
|
+
const names = refuseInvalid(positional);
|
|
652
|
+
if (names.length === 0) {
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
632
655
|
const config = loadProjectConfig();
|
|
633
|
-
const text = await viewComponentTool(config, { names
|
|
656
|
+
const text = await viewComponentTool(config, { names });
|
|
634
657
|
console.log(text);
|
|
635
658
|
}
|
|
636
659
|
async function runExamples(args) {
|
|
@@ -640,36 +663,39 @@ async function runExamples(args) {
|
|
|
640
663
|
process.exitCode = 1;
|
|
641
664
|
return;
|
|
642
665
|
}
|
|
666
|
+
if (refuseInvalid([positional[0]]).length === 0) {
|
|
667
|
+
return;
|
|
668
|
+
}
|
|
643
669
|
const config = loadProjectConfig();
|
|
644
670
|
const text = await getExamplesTool(config, { name: positional[0] });
|
|
645
671
|
console.log(text);
|
|
646
672
|
}
|
|
647
673
|
async function runDocs(args) {
|
|
648
|
-
const { positional } = parseArgs2(args);
|
|
674
|
+
const { flags, positional } = parseArgs2(args);
|
|
649
675
|
if (positional.length === 0) {
|
|
650
|
-
console.error("Usage: keystoneui docs <name>");
|
|
676
|
+
console.error("Usage: keystoneui docs <name> [--type component|block]");
|
|
651
677
|
process.exitCode = 1;
|
|
652
678
|
return;
|
|
653
679
|
}
|
|
654
680
|
const name = positional[0];
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
throw redactUrlInError(error, url);
|
|
681
|
+
if (refuseInvalid([name]).length === 0) {
|
|
682
|
+
return;
|
|
683
|
+
}
|
|
684
|
+
const section = flags.type === "block" ? "blocks" : "components";
|
|
685
|
+
const result = await resolveDocs(loadProjectConfig(), name, section, () => ({
|
|
686
|
+
headers: { "User-Agent": "keystoneui-cli/0.1" }
|
|
687
|
+
}));
|
|
688
|
+
if (result.kind === "unreachable") {
|
|
689
|
+
throw escapedError(redactUrlInError(result.error, result.url));
|
|
664
690
|
}
|
|
665
|
-
if (
|
|
691
|
+
if (result.kind === "status") {
|
|
666
692
|
console.error(
|
|
667
|
-
`Failed to fetch ${displayUrl(url)}: ${
|
|
693
|
+
`Failed to fetch ${shown(displayUrl(result.url))}: ${result.status} ${shown(result.statusText)}`
|
|
668
694
|
);
|
|
669
695
|
process.exitCode = 1;
|
|
670
696
|
return;
|
|
671
697
|
}
|
|
672
|
-
console.log(
|
|
698
|
+
console.log(result.text);
|
|
673
699
|
}
|
|
674
700
|
function runAudit(args) {
|
|
675
701
|
const { flags } = parseArgs2(args);
|
|
@@ -685,7 +711,13 @@ function runAudit(args) {
|
|
|
685
711
|
process.exitCode = 1;
|
|
686
712
|
return;
|
|
687
713
|
}
|
|
688
|
-
|
|
714
|
+
let css;
|
|
715
|
+
try {
|
|
716
|
+
css = readFileSync3(file, "utf-8");
|
|
717
|
+
} catch (error) {
|
|
718
|
+
throw escapedError(error);
|
|
719
|
+
}
|
|
720
|
+
const results = auditTheme(readThemeTokens(css));
|
|
689
721
|
console.log(formatAudit(file, results));
|
|
690
722
|
if (flags.strict === "true" && results.some((r) => r.status === "fail")) {
|
|
691
723
|
process.exitCode = 1;
|
|
@@ -711,6 +743,14 @@ async function runBlocks(args) {
|
|
|
711
743
|
console.log(text2);
|
|
712
744
|
return;
|
|
713
745
|
}
|
|
746
|
+
if (positional.length === 1 && await isBlockName(config, filter)) {
|
|
747
|
+
if (refuseInvalid([filter]).length === 0) {
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
const text2 = await viewComponentTool(config, { names: [filter] });
|
|
751
|
+
console.log(text2);
|
|
752
|
+
return;
|
|
753
|
+
}
|
|
714
754
|
const text = await searchComponentsTool(config, {
|
|
715
755
|
query: filter,
|
|
716
756
|
limit: 20,
|
|
@@ -719,6 +759,16 @@ async function runBlocks(args) {
|
|
|
719
759
|
});
|
|
720
760
|
console.log(text);
|
|
721
761
|
}
|
|
762
|
+
async function isBlockName(config, name) {
|
|
763
|
+
try {
|
|
764
|
+
const { items } = await lookupManifest(config.registry);
|
|
765
|
+
return items.some(
|
|
766
|
+
(item) => item.name === name && item.type === "registry:block"
|
|
767
|
+
);
|
|
768
|
+
} catch {
|
|
769
|
+
return false;
|
|
770
|
+
}
|
|
771
|
+
}
|
|
722
772
|
function runTheme(args) {
|
|
723
773
|
const { flags, positional } = parseArgs2(args);
|
|
724
774
|
const code = positional[0];
|
|
@@ -738,9 +788,11 @@ function runTheme(args) {
|
|
|
738
788
|
);
|
|
739
789
|
console.log("");
|
|
740
790
|
console.log("Install (writes the tokens into your global CSS):");
|
|
741
|
-
console.log(
|
|
791
|
+
console.log(
|
|
792
|
+
isCommandSafe(themeInstallUrl(code, siteUrl, only)) ? ` ${themeInstallCommand(code, siteUrl, only)}` : ` (no command: ${shown(displayUrl(siteUrl))} holds a line break or control character)`
|
|
793
|
+
);
|
|
742
794
|
console.log("");
|
|
743
|
-
console.log(`Edit: ${themeBuilderUrl(code, siteUrl)}`);
|
|
795
|
+
console.log(`Edit: ${shown(themeBuilderUrl(code, siteUrl))}`);
|
|
744
796
|
}
|
|
745
797
|
async function runCli(args) {
|
|
746
798
|
const verb = args[0];
|
|
@@ -750,7 +802,7 @@ async function runCli(args) {
|
|
|
750
802
|
return;
|
|
751
803
|
}
|
|
752
804
|
if (!isCliVerb(verb)) {
|
|
753
|
-
console.error(`Unknown verb: "${verb}".`);
|
|
805
|
+
console.error(`Unknown verb: "${shown(verb)}".`);
|
|
754
806
|
console.error("");
|
|
755
807
|
printUsage2();
|
|
756
808
|
process.exitCode = 1;
|
|
@@ -805,6 +857,6 @@ if (isCliVerb(verbCandidate)) {
|
|
|
805
857
|
process.exit();
|
|
806
858
|
}
|
|
807
859
|
var { StdioServerTransport } = await import("@modelcontextprotocol/sdk/server/stdio.js");
|
|
808
|
-
var { server } = await import("./server-
|
|
860
|
+
var { server } = await import("./server-PR27VI6G.js");
|
|
809
861
|
var transport = new StdioServerTransport();
|
|
810
862
|
await server.connect(transport);
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
readPackageVersion,
|
|
13
13
|
searchComponentsTool,
|
|
14
14
|
viewComponentTool
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-NRQEEI2I.js";
|
|
16
16
|
|
|
17
17
|
// src/server.ts
|
|
18
18
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
@@ -26,7 +26,7 @@ var server = new McpServer(
|
|
|
26
26
|
capabilities: {
|
|
27
27
|
tools: {}
|
|
28
28
|
},
|
|
29
|
-
instructions: "Keystone UI MCP server. Use these tools to discover, search, view, and install Keystone UI components.
|
|
29
|
+
instructions: "Keystone UI MCP server. Use these tools to discover, search, view, and install Keystone UI components, blocks, and kits. Call get_project_context first: install mode decides imports and, for a package-mode project, the flavour to pass to get_add_command. Then use list_components or search_components to explore, and view_component to get full source code."
|
|
30
30
|
}
|
|
31
31
|
);
|
|
32
32
|
function text(value) {
|
|
@@ -54,7 +54,7 @@ server.tool(
|
|
|
54
54
|
"get_add_command",
|
|
55
55
|
TOOL_SPECS.get_add_command.description,
|
|
56
56
|
TOOL_SPECS.get_add_command.schema.shape,
|
|
57
|
-
(input) => text(getAddCommandTool(config, input))
|
|
57
|
+
async (input) => text(await getAddCommandTool(config, input))
|
|
58
58
|
);
|
|
59
59
|
server.tool(
|
|
60
60
|
"get_examples",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keystoneui/mcp",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.7",
|
|
4
4
|
"description": "MCP server and CLI for Keystone UI — lets AI agents and shell users discover, search, view, and install components, blocks, and named examples.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|