@keystoneui/mcp 0.2.0-beta.3 → 0.2.0-beta.5

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 CHANGED
@@ -12,11 +12,13 @@ The single binary runs in two modes:
12
12
  ### As an MCP server
13
13
 
14
14
  ```bash
15
- npx -y @keystoneui/mcp init --client claude
15
+ npx -y @keystoneui/mcp@latest init --client claude
16
16
  ```
17
17
 
18
18
  Supported clients: `claude`, `cursor`, `vscode`, `opencode`, `codex`. The `init` command writes the appropriate config file for the chosen client and points it at `npx @keystoneui/mcp@latest`.
19
19
 
20
+ The server runs with the settings of the project it starts in. Before using it in a project you have not reviewed, read [Projects you do not trust](https://keystoneui.io/docs/agents/mcp-server#projects-you-do-not-trust).
21
+
20
22
  Once configured, ask your agent things like:
21
23
 
22
24
  - *"List Keystone UI components."*
@@ -27,20 +29,23 @@ Once configured, ask your agent things like:
27
29
 
28
30
  ```bash
29
31
  # Discover
30
- npx keystoneui search "table pagination"
31
- npx keystoneui list --type example
32
- npx keystoneui blocks signin
32
+ npx @keystoneui/mcp search "table pagination"
33
+ npx @keystoneui/mcp list --type example
34
+ npx @keystoneui/mcp blocks signin
33
35
 
34
36
  # Inspect
35
- npx keystoneui view button
36
- npx keystoneui docs button # /llms.mdx/docs/components/button
37
- npx keystoneui examples table # all demo files for the table component
37
+ npx @keystoneui/mcp view button
38
+ npx @keystoneui/mcp docs button # /llms.mdx/docs/components/button
39
+ npx @keystoneui/mcp examples table # all demo files for the table component
38
40
 
39
41
  # Install (delegates to shadcn CLI)
40
42
  npx shadcn@latest add https://keystoneui.io/r/table-with-pagination.json
41
43
 
42
44
  # Verify
43
- npx keystoneui audit
45
+ npx @keystoneui/mcp audit
46
+
47
+ # Theme (a code from https://keystoneui.io/theme-builder)
48
+ npx @keystoneui/mcp theme k1_slate_0.55_0.2_262.5_large_inter
44
49
  ```
45
50
 
46
51
  ## Verbs
@@ -53,8 +58,9 @@ npx keystoneui audit
53
58
  | `view <name> [<name>...]` | Show component source |
54
59
  | `examples <name>` | All demo files for a component or block |
55
60
  | `docs <name>` | Fetch the LLM-resolved MDX page (`/llms.mdx/docs/components/<name>`) |
56
- | `audit` | Print the post-install checklist |
61
+ | `audit [--theme [css]] [--strict]` | Print the post-install checklist, or measure every text/surface token pair in your theme against WCAG AA |
57
62
  | `blocks [<filter>]` | List or filter full-page blocks |
63
+ | `theme <code> [--only theme,font]` | Decode a theme-builder code and print its `shadcn add` command |
58
64
 
59
65
  Run `keystoneui help` for the full list. Without any verb the binary launches the MCP stdio server.
60
66
 
@@ -44,6 +44,51 @@ function readPackageVersion() {
44
44
  // src/tools.ts
45
45
  import { z } from "zod";
46
46
 
47
+ // src/display-url.ts
48
+ import { inspect } from "util";
49
+ var DISPLAYED_PROTOCOLS = /* @__PURE__ */ new Set(["http:", "https:", "file:"]);
50
+ var PATH_AFTER_AUTHORITY = /^[\0- ]*[a-z][a-z\d+.-]*:[/\\]{2}[^/\\?#]*[/\\]/i;
51
+ function displayUrl(raw) {
52
+ let url;
53
+ try {
54
+ url = new URL(raw);
55
+ } catch {
56
+ return "<unparseable URL>";
57
+ }
58
+ if (!DISPLAYED_PROTOCOLS.has(url.protocol)) {
59
+ return "<unsupported URL>";
60
+ }
61
+ if (!(url.username || url.password || url.search || url.hash)) {
62
+ return raw;
63
+ }
64
+ url.username = "";
65
+ url.password = "";
66
+ url.hash = "";
67
+ const keys = [...url.searchParams.keys()];
68
+ url.search = keys.map((key) => `${encodeURIComponent(key)}=REDACTED`).join("&");
69
+ if (url.host && url.pathname === "/" && !PATH_AFTER_AUTHORITY.test(raw)) {
70
+ return `${url.protocol}//${url.host}${url.search}`;
71
+ }
72
+ return url.href;
73
+ }
74
+ var LONE_SURROGATE = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g;
75
+ function wellFormed(text) {
76
+ return text.replace(LONE_SURROGATE, "\uFFFD");
77
+ }
78
+ function redactUrlInError(error, url) {
79
+ const forms = [.../* @__PURE__ */ new Set([url, wellFormed(url)])];
80
+ const full = inspect(error, { depth: 10 });
81
+ if (!forms.some((form) => full.includes(form))) {
82
+ return error;
83
+ }
84
+ const shown = displayUrl(url);
85
+ let message = error instanceof Error ? error.message : String(error ?? "Unknown error");
86
+ for (const form of forms) {
87
+ message = message.replaceAll(form, () => shown);
88
+ }
89
+ return error instanceof TypeError ? new TypeError(message) : new Error(message);
90
+ }
91
+
47
92
  // src/fetcher.ts
48
93
  var cache = /* @__PURE__ */ new Map();
49
94
  var CACHE_TTL_MS = 5 * 60 * 1e3;
@@ -52,9 +97,14 @@ async function fetchJson(url) {
52
97
  if (cached && Date.now() - cached.timestamp < CACHE_TTL_MS) {
53
98
  return cached.data;
54
99
  }
55
- const response = await fetch(url);
100
+ let response;
101
+ try {
102
+ response = await fetch(url);
103
+ } catch (error) {
104
+ throw redactUrlInError(error, url);
105
+ }
56
106
  if (!response.ok) {
57
- throw new Error(`Failed to fetch ${url}: ${response.status}`);
107
+ throw new Error(`Failed to fetch ${displayUrl(url)}: ${response.status}`);
58
108
  }
59
109
  const data = await response.json();
60
110
  cache.set(url, { data, timestamp: Date.now() });
@@ -381,6 +431,7 @@ file rather than creating a new one, or the tokens will not reach the components
381
431
  | \`--destructive\` | \`oklch(0.577 0.245 27)\` | \`oklch(0.704 0.191 22)\` | Destructive actions, a metric that got worse |
382
432
  | \`--success\` | \`oklch(0.627 0.194 149)\` | \`oklch(0.723 0.19 150)\` | Positive status, a metric that improved |
383
433
  | \`--warning\` | \`oklch(0.769 0.188 70)\` | \`oklch(0.828 0.189 84)\` | Caution and threshold states only |
434
+ | \`--info\` | \`oklch(0.546 0.245 263)\` | \`oklch(0.707 0.165 255)\` | Neutral notices (info Alert, info Toast) |
384
435
  | \`--muted\` | \`oklch(0.967 0.001 286)\` | \`oklch(0.274 0.006 286)\` | Subdued elements |
385
436
  | \`--accent\` | \`oklch(0.967 0.001 286)\` | \`oklch(0.274 0.006 286)\` | Highlights |
386
437
  | \`--background\` | \`oklch(1 0 0)\` | \`oklch(0.141 0.005 286)\` | Page background |
@@ -416,7 +467,17 @@ Add the \`dark\` class to a parent element.
416
467
  Get the full style definition:
417
468
  \`\`\`bash
418
469
  npx shadcn@latest add ${registryUrl}/default.json
419
- \`\`\``;
470
+ \`\`\`
471
+
472
+ ## Custom themes
473
+
474
+ The theme builder (${config.docsUrl}/theme-builder) encodes a theme as a code,
475
+ \`k1_<base>_<L>_<C>_<H>_<radius>_<font>\`, served as a \`registry:theme\` item.
476
+ Install one, or only its colours (\`?only=theme\`) or font (\`?only=font\`):
477
+ \`\`\`bash
478
+ npx shadcn@latest add ${registryUrl}/theme/<code>.json
479
+ \`\`\`
480
+ \`keystoneui theme <code>\` prints the decoded settings and this command.`;
420
481
  }
421
482
  function auditChecklistTool() {
422
483
  const ctx = detectProjectContext();
@@ -486,7 +547,7 @@ async function getDocsTool(config, input) {
486
547
  }
487
548
  return await response.text();
488
549
  } catch {
489
- return `**${input.name}**: could not reach ${url}.`;
550
+ return `**${input.name}**: could not reach ${displayUrl(url)}.`;
490
551
  }
491
552
  }
492
553
  var emptySchema = z.object({});
@@ -512,7 +573,7 @@ var TOOL_SPECS = {
512
573
  schema: getExamplesSchema
513
574
  },
514
575
  get_docs: {
515
- description: "Fetch the full documentation page for a component or block, including its API Reference table. Props are documented ONLY here -- not in the registry -- so view_component alone will not give you a prop's type or default. Previews arrive resolved to inline TSX, so one call returns prose and working code.",
576
+ description: "Fetch the full documentation page for a component or block, including its Composition tree (the parts hierarchy, and nestings Base UI rejects) and its API Reference table. Read it before composing any compound component. Props are documented ONLY here -- not in the registry -- so view_component alone will not give you a prop's type or default. Previews arrive resolved to inline TSX, so one call returns prose and working code.",
516
577
  schema: getDocsSchema
517
578
  },
518
579
  get_project_context: {
@@ -534,6 +595,8 @@ function getProjectContextTool() {
534
595
 
535
596
  export {
536
597
  loadProjectConfig,
598
+ displayUrl,
599
+ redactUrlInError,
537
600
  readPackageVersion,
538
601
  detectProjectContext,
539
602
  listComponentsTool,
package/dist/index.js CHANGED
@@ -2,13 +2,18 @@
2
2
  import {
3
3
  auditChecklistTool,
4
4
  detectProjectContext,
5
+ displayUrl,
5
6
  getExamplesTool,
6
7
  listComponentsTool,
7
8
  loadProjectConfig,
8
9
  readPackageVersion,
10
+ redactUrlInError,
9
11
  searchComponentsTool,
10
12
  viewComponentTool
11
- } from "./chunk-VGA5HGCS.js";
13
+ } from "./chunk-TAXPGE7O.js";
14
+
15
+ // src/cli.ts
16
+ import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
12
17
 
13
18
  // src/info.ts
14
19
  import { existsSync, readFileSync } from "fs";
@@ -81,15 +86,15 @@ function collect() {
81
86
  node: process.version,
82
87
  platform: process.platform,
83
88
  cwd,
84
- registryUrl: config.registry.url,
85
- docsUrl
89
+ registryUrl: displayUrl(config.registry.url),
90
+ docsUrl: displayUrl(docsUrl)
86
91
  },
87
92
  mcpClients: detectMcpClients(cwd),
88
93
  installedPackages: detectInstalledPackages(cwd),
89
94
  links: {
90
- docs: docsUrl,
91
- registry: `${config.registry.url}/registry.json`,
92
- llms: `${docsUrl}/llms.txt`
95
+ docs: displayUrl(docsUrl),
96
+ registry: displayUrl(`${config.registry.url}/registry.json`),
97
+ llms: displayUrl(`${docsUrl}/llms.txt`)
93
98
  }
94
99
  };
95
100
  }
@@ -159,6 +164,7 @@ function runInfo(args) {
159
164
  // src/init.ts
160
165
  import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, writeFileSync } from "fs";
161
166
  import { dirname, resolve as resolve2 } from "path";
167
+ 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";
162
168
  var SERVER_ENTRY = {
163
169
  command: "npx",
164
170
  args: ["@keystoneui/mcp@latest"]
@@ -240,6 +246,7 @@ function writeJsonClient(client) {
240
246
  `);
241
247
  console.log(`Created ${client.configPath}`);
242
248
  console.log(`Keystone UI MCP server configured for ${client.name}.`);
249
+ console.log(TRUST_POINTER);
243
250
  }
244
251
  function printCodexInstructions() {
245
252
  console.log("Codex uses a global TOML config that cannot be auto-written.");
@@ -251,17 +258,18 @@ function printCodexInstructions() {
251
258
  console.log(' args = ["@keystoneui/mcp@latest"]');
252
259
  console.log("");
253
260
  console.log("Then restart Codex.");
261
+ console.log(TRUST_POINTER);
254
262
  }
255
263
  function printUsage() {
256
264
  const names = CLIENTS.map((c) => c.name).join(", ");
257
- console.log("Usage: npx @keystoneui/mcp init --client <name>");
265
+ console.log("Usage: npx @keystoneui/mcp@latest init --client <name>");
258
266
  console.log("");
259
267
  console.log(`Supported clients: ${names}`);
260
268
  console.log("");
261
269
  console.log("Examples:");
262
- console.log(" npx @keystoneui/mcp init --client cursor");
263
- console.log(" npx @keystoneui/mcp init --client claude");
264
- console.log(" npx @keystoneui/mcp init --client vscode");
270
+ console.log(" npx @keystoneui/mcp@latest init --client cursor");
271
+ console.log(" npx @keystoneui/mcp@latest init --client claude");
272
+ console.log(" npx @keystoneui/mcp@latest init --client vscode");
265
273
  }
266
274
  function init() {
267
275
  const clientName = parseArgs();
@@ -285,6 +293,205 @@ function init() {
285
293
  writeJsonClient(client);
286
294
  }
287
295
 
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
+ // src/theme-audit.ts
334
+ var TEXT_PAIRS = [
335
+ ["foreground", "background"],
336
+ ["card-foreground", "card"],
337
+ ["popover-foreground", "popover"],
338
+ ["primary-foreground", "primary"],
339
+ ["secondary-foreground", "secondary"],
340
+ ["muted-foreground", "background"],
341
+ ["accent-foreground", "accent"],
342
+ ["destructive-foreground", "destructive"],
343
+ ["success-foreground", "success"],
344
+ ["warning-foreground", "warning"],
345
+ ["info-foreground", "info"]
346
+ ];
347
+ var AA_TEXT = 4.5;
348
+ var DECLARATION_RE = /--([\w-]+)\s*:\s*([^;]+);/g;
349
+ var OKLCH_RE = /^oklch\(\s*([\d.]+)(%?)\s+([\d.]+)\s+([\d.]+)(?:deg)?\s*\)$/i;
350
+ var HEX_RE = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i;
351
+ var COMMENT_RE = /\/\*[\s\S]*?\*\//g;
352
+ function declarations(block) {
353
+ const out = {};
354
+ for (const [, name, value] of block.matchAll(DECLARATION_RE)) {
355
+ out[name] = value.trim();
356
+ }
357
+ return out;
358
+ }
359
+ function closingBrace(css, open) {
360
+ let depth = 0;
361
+ for (let i = open; i < css.length; i++) {
362
+ if (css[i] === "{") {
363
+ depth++;
364
+ } else if (css[i] === "}") {
365
+ depth--;
366
+ if (depth === 0) {
367
+ return i;
368
+ }
369
+ }
370
+ }
371
+ return css.length;
372
+ }
373
+ function themeBlocks(css) {
374
+ const blocks = [];
375
+ const preludes = [];
376
+ let start = 0;
377
+ for (let i = 0; i < css.length; i++) {
378
+ const ch = css[i];
379
+ if (ch === "{") {
380
+ const prelude = css.slice(start, i).trim();
381
+ const ancestorsOk = preludes.every((p) => p.startsWith("@layer"));
382
+ if (ancestorsOk && (prelude === ":root" || prelude === ".dark")) {
383
+ const j = closingBrace(css, i);
384
+ blocks.push({ body: css.slice(i + 1, j), selector: prelude });
385
+ i = j;
386
+ start = j + 1;
387
+ continue;
388
+ }
389
+ preludes.push(prelude);
390
+ start = i + 1;
391
+ } else if (ch === "}") {
392
+ preludes.pop();
393
+ start = i + 1;
394
+ } else if (ch === ";") {
395
+ start = i + 1;
396
+ }
397
+ }
398
+ return blocks;
399
+ }
400
+ function readThemeTokens(css) {
401
+ const stripped = css.replace(COMMENT_RE, "");
402
+ const light = {};
403
+ const dark = {};
404
+ for (const { body, selector } of themeBlocks(stripped)) {
405
+ Object.assign(selector === ":root" ? light : dark, declarations(body));
406
+ }
407
+ return { dark: { ...light, ...dark }, light };
408
+ }
409
+ function linearRgb(value) {
410
+ const oklch = OKLCH_RE.exec(value.trim());
411
+ if (oklch) {
412
+ const l = Number(oklch[1]) / (oklch[2] === "%" ? 100 : 1);
413
+ const c = Number(oklch[3]);
414
+ const h = Number(oklch[4]) * Math.PI / 180;
415
+ const a = c * Math.cos(h);
416
+ const b = c * Math.sin(h);
417
+ const l3 = (l + 0.3963377774 * a + 0.2158037573 * b) ** 3;
418
+ const m3 = (l - 0.1055613458 * a - 0.0638541728 * b) ** 3;
419
+ const s3 = (l - 0.0894841775 * a - 1.291485548 * b) ** 3;
420
+ const clamp = (x) => Math.min(Math.max(x, 0), 1);
421
+ return [
422
+ clamp(4.0767416621 * l3 - 3.3077115913 * m3 + 0.2309699292 * s3),
423
+ clamp(
424
+ -1.2684380046 * l3 + 2.6097574011 * m3 - 0.3413193965 * s3
425
+ ),
426
+ clamp(-0.0041960863 * l3 - 0.7034186147 * m3 + 1.707614701 * s3)
427
+ ];
428
+ }
429
+ const hex = HEX_RE.exec(value.trim());
430
+ if (hex) {
431
+ const digits = hex[1].length === 3 ? [...hex[1]].map((d) => d + d).join("") : hex[1];
432
+ const channel = (i) => {
433
+ const v = Number.parseInt(digits.slice(i, i + 2), 16) / 255;
434
+ return v <= 0.04045 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4;
435
+ };
436
+ return [channel(0), channel(2), channel(4)];
437
+ }
438
+ return null;
439
+ }
440
+ function contrastRatio(fg, bg) {
441
+ const a = linearRgb(fg);
442
+ const b = linearRgb(bg);
443
+ if (!(a && b)) {
444
+ return null;
445
+ }
446
+ const y = ([r, g, bl]) => 0.2126 * r + 0.7152 * g + 0.0722 * bl;
447
+ const [hi, lo] = [y(a), y(b)].sort((p, q) => q - p);
448
+ return (hi + 0.05) / (lo + 0.05);
449
+ }
450
+ function statusOf(ratio) {
451
+ if (ratio === null) {
452
+ return "skip";
453
+ }
454
+ return ratio >= AA_TEXT ? "pass" : "fail";
455
+ }
456
+ function auditTheme(tokens) {
457
+ const results = [];
458
+ for (const mode of ["light", "dark"]) {
459
+ for (const [fg, bg] of TEXT_PAIRS) {
460
+ const fgValue = tokens[mode][fg];
461
+ const bgValue = tokens[mode][bg];
462
+ if (!(fgValue && bgValue)) {
463
+ continue;
464
+ }
465
+ const ratio = contrastRatio(fgValue, bgValue);
466
+ results.push({
467
+ mode,
468
+ pair: `${fg} on ${bg}`,
469
+ ratio,
470
+ status: statusOf(ratio)
471
+ });
472
+ }
473
+ }
474
+ return results;
475
+ }
476
+ function formatAudit(file, results) {
477
+ if (results.length === 0) {
478
+ return `No keystone token pairs found in ${file}. Pass the CSS file that holds :root and .dark.`;
479
+ }
480
+ const lines = results.map((r) => {
481
+ const mark = { fail: "\u2716", pass: "\u2714", skip: "\u2013" }[r.status];
482
+ const ratio = r.ratio === null ? "needs a browser" : `${r.ratio.toFixed(2)}:1`;
483
+ return `${mark} ${r.mode.padEnd(5)} ${r.pair.padEnd(42)} ${ratio}`;
484
+ });
485
+ const failed = results.filter((r) => r.status === "fail").length;
486
+ return [
487
+ `Theme contrast \u2014 ${file} (WCAG AA for text: ${AA_TEXT}:1)`,
488
+ "",
489
+ ...lines,
490
+ "",
491
+ failed === 0 ? "All measurable pairs pass." : `${failed} pair(s) under ${AA_TEXT}:1.`
492
+ ].join("\n");
493
+ }
494
+
288
495
  // src/cli.ts
289
496
  var VERBS = [
290
497
  "init",
@@ -295,7 +502,8 @@ var VERBS = [
295
502
  "examples",
296
503
  "docs",
297
504
  "audit",
298
- "blocks"
505
+ "blocks",
506
+ "theme"
299
507
  ];
300
508
  var BLOCK_NAME_PATTERN = /^[a-z0-9-]+$/;
301
509
  function isCliVerb(arg) {
@@ -366,11 +574,14 @@ function printUsage2() {
366
574
  " docs <name> Fetch /llms.mdx/docs/components/<name>"
367
575
  );
368
576
  console.log(
369
- " audit Print post-install checklist"
577
+ " audit [--theme [css]] [--strict] Post-install checklist, or measure your theme's contrast"
370
578
  );
371
579
  console.log(
372
580
  " blocks [<filter>] [--category C] List or filter full-page blocks"
373
581
  );
582
+ console.log(
583
+ " theme <code> [--only theme,font] Install a theme-builder code via shadcn"
584
+ );
374
585
  console.log("");
375
586
  console.log("Without a verb, launches the MCP stdio server.");
376
587
  }
@@ -443,20 +654,42 @@ async function runDocs(args) {
443
654
  const name = positional[0];
444
655
  const siteUrl = process.env.KEYSTONEUI_URL ?? "https://keystoneui.io";
445
656
  const url = `${siteUrl}/llms.mdx/docs/components/${name}`;
446
- const response = await fetch(url, {
447
- headers: { "User-Agent": "keystoneui-cli/0.1" }
448
- });
657
+ let response;
658
+ try {
659
+ response = await fetch(url, {
660
+ headers: { "User-Agent": "keystoneui-cli/0.1" }
661
+ });
662
+ } catch (error) {
663
+ throw redactUrlInError(error, url);
664
+ }
449
665
  if (!response.ok) {
450
666
  console.error(
451
- `Failed to fetch ${url}: ${response.status} ${response.statusText}`
667
+ `Failed to fetch ${displayUrl(url)}: ${response.status} ${response.statusText}`
452
668
  );
453
669
  process.exitCode = 1;
454
670
  return;
455
671
  }
456
672
  console.log(await response.text());
457
673
  }
458
- function runAudit() {
459
- console.log(auditChecklistTool());
674
+ function runAudit(args) {
675
+ const { flags } = parseArgs2(args);
676
+ if (!("theme" in flags)) {
677
+ console.log(auditChecklistTool());
678
+ return;
679
+ }
680
+ const file = flags.theme === "true" ? detectProjectContext().tailwindCssFile : flags.theme;
681
+ if (!(file && existsSync3(file))) {
682
+ console.error(
683
+ "Usage: keystoneui audit --theme [path/to/globals.css] [--strict]\nNo CSS file found \u2014 pass the one that holds your :root and .dark tokens."
684
+ );
685
+ process.exitCode = 1;
686
+ return;
687
+ }
688
+ const results = auditTheme(readThemeTokens(readFileSync3(file, "utf-8")));
689
+ console.log(formatAudit(file, results));
690
+ if (flags.strict === "true" && results.some((r) => r.status === "fail")) {
691
+ process.exitCode = 1;
692
+ }
460
693
  }
461
694
  async function runBlocks(args) {
462
695
  const { flags, positional } = parseArgs2(args);
@@ -486,6 +719,29 @@ async function runBlocks(args) {
486
719
  });
487
720
  console.log(text);
488
721
  }
722
+ function runTheme(args) {
723
+ const { flags, positional } = parseArgs2(args);
724
+ const code = positional[0];
725
+ const fields = code ? parseThemeCode(code) : null;
726
+ if (!(code && fields)) {
727
+ console.error(
728
+ "Usage: keystoneui theme <code> [--only theme,font]\nCopy a code from https://keystoneui.io/theme-builder (Code panel)."
729
+ );
730
+ process.exitCode = 1;
731
+ return;
732
+ }
733
+ const siteUrl = process.env.KEYSTONEUI_URL ?? "https://keystoneui.io";
734
+ const only = parseThemeParts(flags.only);
735
+ console.log(`Theme ${code}`);
736
+ console.log(
737
+ ` base ${fields.base} \xB7 primary ${fields.primary} \xB7 radius ${fields.radius} \xB7 font ${fields.font}`
738
+ );
739
+ console.log("");
740
+ console.log("Install (writes the tokens into your global CSS):");
741
+ console.log(` ${themeInstallCommand(code, siteUrl, only)}`);
742
+ console.log("");
743
+ console.log(`Edit: ${themeBuilderUrl(code, siteUrl)}`);
744
+ }
489
745
  async function runCli(args) {
490
746
  const verb = args[0];
491
747
  const rest = args.slice(1);
@@ -523,11 +779,14 @@ async function runCli(args) {
523
779
  await runDocs(rest);
524
780
  return;
525
781
  case "audit":
526
- runAudit();
782
+ runAudit(rest);
527
783
  return;
528
784
  case "blocks":
529
785
  await runBlocks(rest);
530
786
  return;
787
+ case "theme":
788
+ runTheme(rest);
789
+ return;
531
790
  default: {
532
791
  const exhaustive = verb;
533
792
  throw new Error(`Unhandled verb: ${exhaustive}`);
@@ -546,6 +805,6 @@ if (isCliVerb(verbCandidate)) {
546
805
  process.exit();
547
806
  }
548
807
  var { StdioServerTransport } = await import("@modelcontextprotocol/sdk/server/stdio.js");
549
- var { server } = await import("./server-2OYYC4H7.js");
808
+ var { server } = await import("./server-7ZU3YJ7K.js");
550
809
  var transport = new StdioServerTransport();
551
810
  await server.connect(transport);
@@ -12,7 +12,7 @@ import {
12
12
  readPackageVersion,
13
13
  searchComponentsTool,
14
14
  viewComponentTool
15
- } from "./chunk-VGA5HGCS.js";
15
+ } from "./chunk-TAXPGE7O.js";
16
16
 
17
17
  // src/server.ts
18
18
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keystoneui/mcp",
3
- "version": "0.2.0-beta.3",
3
+ "version": "0.2.0-beta.5",
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",
@@ -45,7 +45,7 @@
45
45
  "@types/node": "^26.6.5",
46
46
  "tsup": "^8.5.1",
47
47
  "typescript": "^7.0.2",
48
- "vitest": "^5.0.3",
48
+ "vitest": "^5.0.5",
49
49
  "@keystoneui/typescript-config": "0.0.0"
50
50
  },
51
51
  "publishConfig": {