@keystoneui/mcp 0.2.0-beta.4 → 0.2.0-beta.6
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 +21 -19
- package/dist/chunk-LC22ZWZH.js +1372 -0
- package/dist/index.js +143 -90
- package/dist/{server-TNVOIXZW.js → server-HWF3HIOR.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-JVJEQ7VV.js +0 -560
package/dist/index.js
CHANGED
|
@@ -2,13 +2,27 @@
|
|
|
2
2
|
import {
|
|
3
3
|
auditChecklistTool,
|
|
4
4
|
detectProjectContext,
|
|
5
|
+
displayUrl,
|
|
6
|
+
escapedError,
|
|
5
7
|
getExamplesTool,
|
|
8
|
+
isCommandSafe,
|
|
6
9
|
listComponentsTool,
|
|
7
10
|
loadProjectConfig,
|
|
11
|
+
lookupManifest,
|
|
12
|
+
nameRefusal,
|
|
13
|
+
parseThemeCode,
|
|
14
|
+
parseThemeParts,
|
|
8
15
|
readPackageVersion,
|
|
16
|
+
redactUrlInError,
|
|
17
|
+
registryCatalogueUrl,
|
|
18
|
+
resolveDocs,
|
|
9
19
|
searchComponentsTool,
|
|
20
|
+
shown,
|
|
21
|
+
themeBuilderUrl,
|
|
22
|
+
themeInstallCommand,
|
|
23
|
+
themeInstallUrl,
|
|
10
24
|
viewComponentTool
|
|
11
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-LC22ZWZH.js";
|
|
12
26
|
|
|
13
27
|
// src/cli.ts
|
|
14
28
|
import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
|
|
@@ -84,15 +98,15 @@ function collect() {
|
|
|
84
98
|
node: process.version,
|
|
85
99
|
platform: process.platform,
|
|
86
100
|
cwd,
|
|
87
|
-
registryUrl: config.registry.url,
|
|
88
|
-
docsUrl
|
|
101
|
+
registryUrl: displayUrl(config.registry.url),
|
|
102
|
+
docsUrl: displayUrl(docsUrl)
|
|
89
103
|
},
|
|
90
104
|
mcpClients: detectMcpClients(cwd),
|
|
91
105
|
installedPackages: detectInstalledPackages(cwd),
|
|
92
106
|
links: {
|
|
93
|
-
docs: docsUrl,
|
|
94
|
-
registry:
|
|
95
|
-
llms: `${docsUrl}/llms.txt`
|
|
107
|
+
docs: displayUrl(docsUrl),
|
|
108
|
+
registry: displayUrl(registryCatalogueUrl(config.registry)),
|
|
109
|
+
llms: displayUrl(`${docsUrl}/llms.txt`)
|
|
96
110
|
}
|
|
97
111
|
};
|
|
98
112
|
}
|
|
@@ -102,6 +116,9 @@ function pad(label, width = 18) {
|
|
|
102
116
|
}
|
|
103
117
|
return label.padEnd(width, " ");
|
|
104
118
|
}
|
|
119
|
+
function shownOr(value) {
|
|
120
|
+
return value === null || value === void 0 ? "(unknown)" : shown(value);
|
|
121
|
+
}
|
|
105
122
|
function printText(data) {
|
|
106
123
|
const lines = [];
|
|
107
124
|
lines.push(`${data.package.name} v${data.package.version}`);
|
|
@@ -109,20 +126,20 @@ function printText(data) {
|
|
|
109
126
|
const p = data.project;
|
|
110
127
|
lines.push("Project");
|
|
111
128
|
lines.push(` ${pad("Install mode")}${p.installMode}`);
|
|
112
|
-
lines.push(` ${pad("UI alias")}${p.aliases?.ui
|
|
113
|
-
lines.push(` ${pad("Theme CSS")}${p.tailwindCssFile
|
|
114
|
-
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)}`);
|
|
115
132
|
lines.push(
|
|
116
133
|
` ${pad("RSC")}${p.isRSC === null ? "(unknown)" : String(p.isRSC)}`
|
|
117
134
|
);
|
|
118
|
-
lines.push(` ${pad("Package manager")}${p.packageManager
|
|
135
|
+
lines.push(` ${pad("Package manager")}${shownOr(p.packageManager)}`);
|
|
119
136
|
lines.push("");
|
|
120
137
|
lines.push("Environment");
|
|
121
|
-
lines.push(` ${pad("Node")}${data.environment.node}`);
|
|
122
|
-
lines.push(` ${pad("Platform")}${data.environment.platform}`);
|
|
123
|
-
lines.push(` ${pad("Project root")}${data.environment.cwd}`);
|
|
124
|
-
lines.push(` ${pad("Registry URL")}${data.environment.registryUrl}`);
|
|
125
|
-
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)}`);
|
|
126
143
|
lines.push("");
|
|
127
144
|
lines.push("MCP clients");
|
|
128
145
|
const configured = data.mcpClients.filter((c) => c.configured);
|
|
@@ -130,7 +147,7 @@ function printText(data) {
|
|
|
130
147
|
lines.push(" (none configured for keystoneui)");
|
|
131
148
|
} else {
|
|
132
149
|
for (const client of configured) {
|
|
133
|
-
lines.push(` ${pad(client.name)}${client.configPath}`);
|
|
150
|
+
lines.push(` ${pad(client.name)}${shown(client.configPath)}`);
|
|
134
151
|
}
|
|
135
152
|
}
|
|
136
153
|
lines.push("");
|
|
@@ -139,14 +156,14 @@ function printText(data) {
|
|
|
139
156
|
lines.push(" (none detected in this project)");
|
|
140
157
|
} else {
|
|
141
158
|
for (const pkg of data.installedPackages) {
|
|
142
|
-
lines.push(` ${pad(pkg.name, 28)}v${pkg.version}`);
|
|
159
|
+
lines.push(` ${pad(shown(pkg.name), 28)}v${shown(pkg.version)}`);
|
|
143
160
|
}
|
|
144
161
|
}
|
|
145
162
|
lines.push("");
|
|
146
163
|
lines.push("Links");
|
|
147
|
-
lines.push(` ${pad("Docs")}${data.links.docs}`);
|
|
148
|
-
lines.push(` ${pad("Registry")}${data.links.registry}`);
|
|
149
|
-
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)}`);
|
|
150
167
|
console.log(lines.join("\n"));
|
|
151
168
|
}
|
|
152
169
|
function runInfo(args) {
|
|
@@ -162,6 +179,7 @@ function runInfo(args) {
|
|
|
162
179
|
// src/init.ts
|
|
163
180
|
import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, writeFileSync } from "fs";
|
|
164
181
|
import { dirname, resolve as resolve2 } from "path";
|
|
182
|
+
var TRUST_POINTER = "The server runs with this project's settings. Before using it in a project you have not reviewed, read https://keystoneui.io/docs/agents/mcp-server#projects-you-do-not-trust";
|
|
165
183
|
var SERVER_ENTRY = {
|
|
166
184
|
command: "npx",
|
|
167
185
|
args: ["@keystoneui/mcp@latest"]
|
|
@@ -230,7 +248,11 @@ function mergeJsonConfig(existing, client) {
|
|
|
230
248
|
function writeJsonClient(client) {
|
|
231
249
|
const targetPath = resolve2(process.cwd(), client.configPath);
|
|
232
250
|
const dir = dirname(targetPath);
|
|
233
|
-
|
|
251
|
+
try {
|
|
252
|
+
mkdirSync(dir, { recursive: true });
|
|
253
|
+
} catch (error) {
|
|
254
|
+
throw escapedError(error);
|
|
255
|
+
}
|
|
234
256
|
let existing = {};
|
|
235
257
|
if (existsSync2(targetPath)) {
|
|
236
258
|
try {
|
|
@@ -239,10 +261,15 @@ function writeJsonClient(client) {
|
|
|
239
261
|
}
|
|
240
262
|
}
|
|
241
263
|
const merged = mergeJsonConfig(existing, client);
|
|
242
|
-
|
|
264
|
+
try {
|
|
265
|
+
writeFileSync(targetPath, `${JSON.stringify(merged, null, 2)}
|
|
243
266
|
`);
|
|
267
|
+
} catch (error) {
|
|
268
|
+
throw escapedError(error);
|
|
269
|
+
}
|
|
244
270
|
console.log(`Created ${client.configPath}`);
|
|
245
271
|
console.log(`Keystone UI MCP server configured for ${client.name}.`);
|
|
272
|
+
console.log(TRUST_POINTER);
|
|
246
273
|
}
|
|
247
274
|
function printCodexInstructions() {
|
|
248
275
|
console.log("Codex uses a global TOML config that cannot be auto-written.");
|
|
@@ -254,17 +281,18 @@ function printCodexInstructions() {
|
|
|
254
281
|
console.log(' args = ["@keystoneui/mcp@latest"]');
|
|
255
282
|
console.log("");
|
|
256
283
|
console.log("Then restart Codex.");
|
|
284
|
+
console.log(TRUST_POINTER);
|
|
257
285
|
}
|
|
258
286
|
function printUsage() {
|
|
259
287
|
const names = CLIENTS.map((c) => c.name).join(", ");
|
|
260
|
-
console.log("Usage: npx @keystoneui/mcp init --client <name>");
|
|
288
|
+
console.log("Usage: npx @keystoneui/mcp@latest init --client <name>");
|
|
261
289
|
console.log("");
|
|
262
290
|
console.log(`Supported clients: ${names}`);
|
|
263
291
|
console.log("");
|
|
264
292
|
console.log("Examples:");
|
|
265
|
-
console.log(" npx @keystoneui/mcp init --client cursor");
|
|
266
|
-
console.log(" npx @keystoneui/mcp init --client claude");
|
|
267
|
-
console.log(" npx @keystoneui/mcp init --client vscode");
|
|
293
|
+
console.log(" npx @keystoneui/mcp@latest init --client cursor");
|
|
294
|
+
console.log(" npx @keystoneui/mcp@latest init --client claude");
|
|
295
|
+
console.log(" npx @keystoneui/mcp@latest init --client vscode");
|
|
268
296
|
}
|
|
269
297
|
function init() {
|
|
270
298
|
const clientName = parseArgs();
|
|
@@ -275,7 +303,7 @@ function init() {
|
|
|
275
303
|
}
|
|
276
304
|
const client = CLIENTS.find((c) => c.name === clientName);
|
|
277
305
|
if (!client) {
|
|
278
|
-
console.error(`Unknown client: "${clientName}"`);
|
|
306
|
+
console.error(`Unknown client: "${shown(clientName)}"`);
|
|
279
307
|
console.error("");
|
|
280
308
|
printUsage();
|
|
281
309
|
process.exitCode = 1;
|
|
@@ -288,43 +316,6 @@ function init() {
|
|
|
288
316
|
writeJsonClient(client);
|
|
289
317
|
}
|
|
290
318
|
|
|
291
|
-
// src/theme.ts
|
|
292
|
-
var THEME_CODE_RE = /^k1_([a-z]+)_(\d+(?:\.\d+)?)_(\d+(?:\.\d+)?)_(\d+(?:\.\d+)?)_([a-z]+)_([a-z-]+)$/;
|
|
293
|
-
function parseThemeCode(code) {
|
|
294
|
-
const match = THEME_CODE_RE.exec(code);
|
|
295
|
-
if (!match) {
|
|
296
|
-
return null;
|
|
297
|
-
}
|
|
298
|
-
const [, base, l, c, h, radius, font] = match;
|
|
299
|
-
return { base, font, primary: `oklch(${l} ${c} ${h})`, radius };
|
|
300
|
-
}
|
|
301
|
-
function themeInstallCommand(code, siteUrl, only = []) {
|
|
302
|
-
const query = only.length > 0 ? `?only=${only.join(",")}` : "";
|
|
303
|
-
return `npx shadcn@latest add ${siteUrl}/r/theme/${code}.json${query}`;
|
|
304
|
-
}
|
|
305
|
-
function themeBuilderUrl(code, siteUrl) {
|
|
306
|
-
const match = THEME_CODE_RE.exec(code);
|
|
307
|
-
if (!match) {
|
|
308
|
-
return null;
|
|
309
|
-
}
|
|
310
|
-
const [, base, primaryL, primaryC, primaryH, radius, font] = match;
|
|
311
|
-
const params = new URLSearchParams({
|
|
312
|
-
base,
|
|
313
|
-
primaryL,
|
|
314
|
-
primaryC,
|
|
315
|
-
primaryH,
|
|
316
|
-
radius,
|
|
317
|
-
font
|
|
318
|
-
});
|
|
319
|
-
return `${siteUrl}/theme-builder?${params}`;
|
|
320
|
-
}
|
|
321
|
-
function parseThemeParts(value) {
|
|
322
|
-
if (!value) {
|
|
323
|
-
return [];
|
|
324
|
-
}
|
|
325
|
-
return value.split(",").map((part) => part.trim()).filter((part) => part === "theme" || part === "font");
|
|
326
|
-
}
|
|
327
|
-
|
|
328
319
|
// src/theme-audit.ts
|
|
329
320
|
var TEXT_PAIRS = [
|
|
330
321
|
["foreground", "background"],
|
|
@@ -470,7 +461,7 @@ function auditTheme(tokens) {
|
|
|
470
461
|
}
|
|
471
462
|
function formatAudit(file, results) {
|
|
472
463
|
if (results.length === 0) {
|
|
473
|
-
return `No keystone token pairs found in ${file}. Pass the CSS file that holds :root and .dark.`;
|
|
464
|
+
return `No keystone token pairs found in ${shown(file)}. Pass the CSS file that holds :root and .dark.`;
|
|
474
465
|
}
|
|
475
466
|
const lines = results.map((r) => {
|
|
476
467
|
const mark = { fail: "\u2716", pass: "\u2714", skip: "\u2013" }[r.status];
|
|
@@ -479,7 +470,7 @@ function formatAudit(file, results) {
|
|
|
479
470
|
});
|
|
480
471
|
const failed = results.filter((r) => r.status === "fail").length;
|
|
481
472
|
return [
|
|
482
|
-
`Theme contrast \u2014 ${file} (WCAG AA for text: ${AA_TEXT}:1)`,
|
|
473
|
+
`Theme contrast \u2014 ${shown(file)} (WCAG AA for text: ${AA_TEXT}:1)`,
|
|
483
474
|
"",
|
|
484
475
|
...lines,
|
|
485
476
|
"",
|
|
@@ -524,24 +515,46 @@ function parseArgs2(args) {
|
|
|
524
515
|
}
|
|
525
516
|
return { flags, positional };
|
|
526
517
|
}
|
|
518
|
+
var TYPES = [
|
|
519
|
+
"ui",
|
|
520
|
+
"block",
|
|
521
|
+
"example",
|
|
522
|
+
"kit",
|
|
523
|
+
"style",
|
|
524
|
+
"theme",
|
|
525
|
+
"item"
|
|
526
|
+
];
|
|
527
527
|
function parseType(value) {
|
|
528
528
|
if (value === void 0) {
|
|
529
529
|
return;
|
|
530
530
|
}
|
|
531
|
-
if (value
|
|
531
|
+
if (TYPES.includes(value)) {
|
|
532
532
|
return value;
|
|
533
533
|
}
|
|
534
534
|
throw new Error(
|
|
535
|
-
`Invalid --type value "${value}". Expected one of:
|
|
535
|
+
`Invalid --type value "${shown(value)}". Expected one of: ${TYPES.join(", ")}.`
|
|
536
536
|
);
|
|
537
537
|
}
|
|
538
|
+
function refuseInvalid(names) {
|
|
539
|
+
const valid = [];
|
|
540
|
+
for (const name of names) {
|
|
541
|
+
const refusal = nameRefusal(name);
|
|
542
|
+
if (refusal) {
|
|
543
|
+
console.error(refusal);
|
|
544
|
+
process.exitCode = 1;
|
|
545
|
+
} else {
|
|
546
|
+
valid.push(name);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
return valid;
|
|
550
|
+
}
|
|
538
551
|
function parseInt10(value, fallback) {
|
|
539
552
|
if (value === void 0) {
|
|
540
553
|
return fallback;
|
|
541
554
|
}
|
|
542
555
|
const n = Number.parseInt(value, 10);
|
|
543
556
|
if (Number.isNaN(n)) {
|
|
544
|
-
throw new Error(`Expected an integer, got "${value}".`);
|
|
557
|
+
throw new Error(`Expected an integer, got "${shown(value)}".`);
|
|
545
558
|
}
|
|
546
559
|
return n;
|
|
547
560
|
}
|
|
@@ -555,24 +568,26 @@ function printUsage2() {
|
|
|
555
568
|
);
|
|
556
569
|
console.log(" search <query> [--type T] [--category C] [--limit N]");
|
|
557
570
|
console.log(
|
|
558
|
-
" Fuzzy search components, blocks, examples"
|
|
571
|
+
" Fuzzy search components, blocks, kits, examples"
|
|
559
572
|
);
|
|
560
573
|
console.log(" list [--type T] [--category C] [--limit N] [--offset N]");
|
|
561
574
|
console.log(
|
|
562
|
-
" List items (T = ui|block|example)"
|
|
575
|
+
" List items (T = ui|block|example|kit|style|theme|item)"
|
|
576
|
+
);
|
|
577
|
+
console.log(
|
|
578
|
+
" view <name> [<name>...] Show source of components, blocks, kits"
|
|
563
579
|
);
|
|
564
|
-
console.log(" view <name> [<name>...] Show component source");
|
|
565
580
|
console.log(
|
|
566
581
|
" examples <name> Show all demos for a component/block"
|
|
567
582
|
);
|
|
568
583
|
console.log(
|
|
569
|
-
" docs <name>
|
|
584
|
+
" docs <name> [--type component|block] Fetch /llms.mdx/docs/{components|blocks}/<name>"
|
|
570
585
|
);
|
|
571
586
|
console.log(
|
|
572
587
|
" audit [--theme [css]] [--strict] Post-install checklist, or measure your theme's contrast"
|
|
573
588
|
);
|
|
574
589
|
console.log(
|
|
575
|
-
" blocks [<filter>] [--category C] List or filter full-page blocks"
|
|
590
|
+
" blocks [<filter>] [--category C] List or filter full-page blocks; an exact block name views it (kits: list --type kit)"
|
|
576
591
|
);
|
|
577
592
|
console.log(
|
|
578
593
|
" theme <code> [--only theme,font] Install a theme-builder code via shadcn"
|
|
@@ -584,7 +599,7 @@ async function runSearch(args) {
|
|
|
584
599
|
const { flags, positional } = parseArgs2(args);
|
|
585
600
|
if (positional.length === 0) {
|
|
586
601
|
console.error(
|
|
587
|
-
"Usage: keystoneui search <query> [--type ui|block|example] [--category C] [--limit N]"
|
|
602
|
+
"Usage: keystoneui search <query> [--type ui|block|example|kit|style|theme|item] [--category C] [--limit N]"
|
|
588
603
|
);
|
|
589
604
|
process.exitCode = 1;
|
|
590
605
|
return;
|
|
@@ -624,8 +639,12 @@ async function runView(args) {
|
|
|
624
639
|
process.exitCode = 1;
|
|
625
640
|
return;
|
|
626
641
|
}
|
|
642
|
+
const names = refuseInvalid(positional);
|
|
643
|
+
if (names.length === 0) {
|
|
644
|
+
return;
|
|
645
|
+
}
|
|
627
646
|
const config = loadProjectConfig();
|
|
628
|
-
const text = await viewComponentTool(config, { names
|
|
647
|
+
const text = await viewComponentTool(config, { names });
|
|
629
648
|
console.log(text);
|
|
630
649
|
}
|
|
631
650
|
async function runExamples(args) {
|
|
@@ -635,31 +654,39 @@ async function runExamples(args) {
|
|
|
635
654
|
process.exitCode = 1;
|
|
636
655
|
return;
|
|
637
656
|
}
|
|
657
|
+
if (refuseInvalid([positional[0]]).length === 0) {
|
|
658
|
+
return;
|
|
659
|
+
}
|
|
638
660
|
const config = loadProjectConfig();
|
|
639
661
|
const text = await getExamplesTool(config, { name: positional[0] });
|
|
640
662
|
console.log(text);
|
|
641
663
|
}
|
|
642
664
|
async function runDocs(args) {
|
|
643
|
-
const { positional } = parseArgs2(args);
|
|
665
|
+
const { flags, positional } = parseArgs2(args);
|
|
644
666
|
if (positional.length === 0) {
|
|
645
|
-
console.error("Usage: keystoneui docs <name>");
|
|
667
|
+
console.error("Usage: keystoneui docs <name> [--type component|block]");
|
|
646
668
|
process.exitCode = 1;
|
|
647
669
|
return;
|
|
648
670
|
}
|
|
649
671
|
const name = positional[0];
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
672
|
+
if (refuseInvalid([name]).length === 0) {
|
|
673
|
+
return;
|
|
674
|
+
}
|
|
675
|
+
const section = flags.type === "block" ? "blocks" : "components";
|
|
676
|
+
const result = await resolveDocs(loadProjectConfig(), name, section, () => ({
|
|
653
677
|
headers: { "User-Agent": "keystoneui-cli/0.1" }
|
|
654
|
-
});
|
|
655
|
-
if (
|
|
678
|
+
}));
|
|
679
|
+
if (result.kind === "unreachable") {
|
|
680
|
+
throw escapedError(redactUrlInError(result.error, result.url));
|
|
681
|
+
}
|
|
682
|
+
if (result.kind === "status") {
|
|
656
683
|
console.error(
|
|
657
|
-
`Failed to fetch ${url}: ${
|
|
684
|
+
`Failed to fetch ${shown(displayUrl(result.url))}: ${result.status} ${shown(result.statusText)}`
|
|
658
685
|
);
|
|
659
686
|
process.exitCode = 1;
|
|
660
687
|
return;
|
|
661
688
|
}
|
|
662
|
-
console.log(
|
|
689
|
+
console.log(result.text);
|
|
663
690
|
}
|
|
664
691
|
function runAudit(args) {
|
|
665
692
|
const { flags } = parseArgs2(args);
|
|
@@ -675,7 +702,13 @@ function runAudit(args) {
|
|
|
675
702
|
process.exitCode = 1;
|
|
676
703
|
return;
|
|
677
704
|
}
|
|
678
|
-
|
|
705
|
+
let css;
|
|
706
|
+
try {
|
|
707
|
+
css = readFileSync3(file, "utf-8");
|
|
708
|
+
} catch (error) {
|
|
709
|
+
throw escapedError(error);
|
|
710
|
+
}
|
|
711
|
+
const results = auditTheme(readThemeTokens(css));
|
|
679
712
|
console.log(formatAudit(file, results));
|
|
680
713
|
if (flags.strict === "true" && results.some((r) => r.status === "fail")) {
|
|
681
714
|
process.exitCode = 1;
|
|
@@ -701,6 +734,14 @@ async function runBlocks(args) {
|
|
|
701
734
|
console.log(text2);
|
|
702
735
|
return;
|
|
703
736
|
}
|
|
737
|
+
if (positional.length === 1 && await isBlockName(config, filter)) {
|
|
738
|
+
if (refuseInvalid([filter]).length === 0) {
|
|
739
|
+
return;
|
|
740
|
+
}
|
|
741
|
+
const text2 = await viewComponentTool(config, { names: [filter] });
|
|
742
|
+
console.log(text2);
|
|
743
|
+
return;
|
|
744
|
+
}
|
|
704
745
|
const text = await searchComponentsTool(config, {
|
|
705
746
|
query: filter,
|
|
706
747
|
limit: 20,
|
|
@@ -709,6 +750,16 @@ async function runBlocks(args) {
|
|
|
709
750
|
});
|
|
710
751
|
console.log(text);
|
|
711
752
|
}
|
|
753
|
+
async function isBlockName(config, name) {
|
|
754
|
+
try {
|
|
755
|
+
const { items } = await lookupManifest(config.registry);
|
|
756
|
+
return items.some(
|
|
757
|
+
(item) => item.name === name && item.type === "registry:block"
|
|
758
|
+
);
|
|
759
|
+
} catch {
|
|
760
|
+
return false;
|
|
761
|
+
}
|
|
762
|
+
}
|
|
712
763
|
function runTheme(args) {
|
|
713
764
|
const { flags, positional } = parseArgs2(args);
|
|
714
765
|
const code = positional[0];
|
|
@@ -728,9 +779,11 @@ function runTheme(args) {
|
|
|
728
779
|
);
|
|
729
780
|
console.log("");
|
|
730
781
|
console.log("Install (writes the tokens into your global CSS):");
|
|
731
|
-
console.log(
|
|
782
|
+
console.log(
|
|
783
|
+
isCommandSafe(themeInstallUrl(code, siteUrl, only)) ? ` ${themeInstallCommand(code, siteUrl, only)}` : ` (no command: ${shown(displayUrl(siteUrl))} holds a line break or control character)`
|
|
784
|
+
);
|
|
732
785
|
console.log("");
|
|
733
|
-
console.log(`Edit: ${themeBuilderUrl(code, siteUrl)}`);
|
|
786
|
+
console.log(`Edit: ${shown(themeBuilderUrl(code, siteUrl))}`);
|
|
734
787
|
}
|
|
735
788
|
async function runCli(args) {
|
|
736
789
|
const verb = args[0];
|
|
@@ -740,7 +793,7 @@ async function runCli(args) {
|
|
|
740
793
|
return;
|
|
741
794
|
}
|
|
742
795
|
if (!isCliVerb(verb)) {
|
|
743
|
-
console.error(`Unknown verb: "${verb}".`);
|
|
796
|
+
console.error(`Unknown verb: "${shown(verb)}".`);
|
|
744
797
|
console.error("");
|
|
745
798
|
printUsage2();
|
|
746
799
|
process.exitCode = 1;
|
|
@@ -795,6 +848,6 @@ if (isCliVerb(verbCandidate)) {
|
|
|
795
848
|
process.exit();
|
|
796
849
|
}
|
|
797
850
|
var { StdioServerTransport } = await import("@modelcontextprotocol/sdk/server/stdio.js");
|
|
798
|
-
var { server } = await import("./server-
|
|
851
|
+
var { server } = await import("./server-HWF3HIOR.js");
|
|
799
852
|
var transport = new StdioServerTransport();
|
|
800
853
|
await server.connect(transport);
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
readPackageVersion,
|
|
13
13
|
searchComponentsTool,
|
|
14
14
|
viewComponentTool
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-LC22ZWZH.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.6",
|
|
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",
|