@keystoneui/mcp 0.2.0-beta.1 → 0.2.0-beta.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Keystone UI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -60,8 +60,10 @@ Run `keystoneui help` for the full list. Without any verb the binary launches th
60
60
 
61
61
  ## MCP tools
62
62
 
63
- When run without arguments the server exposes seven tools to MCP clients:
63
+ When run without arguments the server exposes nine tools to MCP clients:
64
64
 
65
+ - `get_docs` — full docs page for a component or block, including its API Reference
66
+ - `get_project_context` — install mode, aliases, theme CSS file, icon library, RSC
65
67
  - `list_components` — list components, blocks, or examples with pagination
66
68
  - `search_components` — fuzzy search across components, blocks, and examples
67
69
  - `view_component` — full source for one or more components
@@ -0,0 +1,549 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/config.ts
4
+ import { existsSync, readFileSync } from "fs";
5
+ import { resolve } from "path";
6
+ var DEFAULT_DOCS_URL = "https://keystoneui.io";
7
+ var DEFAULT_REGISTRY_URL = `${DEFAULT_DOCS_URL}/r`;
8
+ function resolveDocsUrl() {
9
+ return process.env.KEYSTONEUI_URL ?? DEFAULT_DOCS_URL;
10
+ }
11
+ function loadProjectConfig() {
12
+ const docsUrl = resolveDocsUrl();
13
+ const derivedRegistryUrl = docsUrl === DEFAULT_DOCS_URL ? DEFAULT_REGISTRY_URL : `${docsUrl}/r`;
14
+ const registryUrlEnv = process.env.KEYSTONEUI_REGISTRY_URL;
15
+ if (registryUrlEnv) {
16
+ return { docsUrl, registry: { url: registryUrlEnv } };
17
+ }
18
+ const cwd = process.cwd();
19
+ const configPath = resolve(cwd, "components.json");
20
+ if (existsSync(configPath)) {
21
+ try {
22
+ const raw = JSON.parse(readFileSync(configPath, "utf-8"));
23
+ const registryUrl = raw?.registries?.["@keystoneui"]?.url ?? derivedRegistryUrl;
24
+ return { docsUrl, registry: { url: registryUrl } };
25
+ } catch {
26
+ }
27
+ }
28
+ return { docsUrl, registry: { url: derivedRegistryUrl } };
29
+ }
30
+
31
+ // src/package-version.ts
32
+ import { readFileSync as readFileSync2 } from "fs";
33
+ import { fileURLToPath } from "url";
34
+ function readPackageVersion() {
35
+ try {
36
+ const pkgPath = fileURLToPath(new URL("../package.json", import.meta.url));
37
+ const pkg = JSON.parse(readFileSync2(pkgPath, "utf-8"));
38
+ return pkg.version ?? "unknown";
39
+ } catch {
40
+ return "unknown";
41
+ }
42
+ }
43
+
44
+ // src/tools.ts
45
+ import { z } from "zod";
46
+
47
+ // src/fetcher.ts
48
+ var cache = /* @__PURE__ */ new Map();
49
+ var CACHE_TTL_MS = 5 * 60 * 1e3;
50
+ async function fetchJson(url) {
51
+ const cached = cache.get(url);
52
+ if (cached && Date.now() - cached.timestamp < CACHE_TTL_MS) {
53
+ return cached.data;
54
+ }
55
+ const response = await fetch(url);
56
+ if (!response.ok) {
57
+ throw new Error(`Failed to fetch ${url}: ${response.status}`);
58
+ }
59
+ const data = await response.json();
60
+ cache.set(url, { data, timestamp: Date.now() });
61
+ return data;
62
+ }
63
+ function fetchManifest(registryUrl) {
64
+ return fetchJson(`${registryUrl}/registry.json`);
65
+ }
66
+ function fetchItem(registryUrl, name) {
67
+ return fetchJson(`${registryUrl}/${name}.json`);
68
+ }
69
+ function fetchExamples(registryUrl, name) {
70
+ return fetchJson(`${registryUrl}/demos/${name}`);
71
+ }
72
+
73
+ // src/project-context.ts
74
+ import { existsSync as existsSync2, readFileSync as readFileSync3 } from "fs";
75
+ import { resolve as resolve2 } from "path";
76
+ function readJson(path) {
77
+ if (!existsSync2(path)) {
78
+ return null;
79
+ }
80
+ try {
81
+ return JSON.parse(readFileSync3(path, "utf-8"));
82
+ } catch {
83
+ return null;
84
+ }
85
+ }
86
+ function detectPackageManager(cwd, manifest) {
87
+ const declared = manifest?.packageManager;
88
+ if (typeof declared === "string" && declared.length > 0) {
89
+ return declared.split("@")[0];
90
+ }
91
+ const lockfiles = [
92
+ ["pnpm-lock.yaml", "pnpm"],
93
+ ["bun.lock", "bun"],
94
+ ["bun.lockb", "bun"],
95
+ ["yarn.lock", "yarn"],
96
+ ["package-lock.json", "npm"]
97
+ ];
98
+ for (const [file, name] of lockfiles) {
99
+ if (existsSync2(resolve2(cwd, file))) {
100
+ return name;
101
+ }
102
+ }
103
+ return null;
104
+ }
105
+ function detectProjectContext(cwd = process.cwd()) {
106
+ const manifest = readJson(resolve2(cwd, "package.json"));
107
+ const components = readJson(resolve2(cwd, "components.json"));
108
+ const deps = {
109
+ ...manifest?.dependencies,
110
+ ...manifest?.devDependencies
111
+ };
112
+ const keystoneVersion = deps["@keystoneui/react"] ?? null;
113
+ let installMode = "unknown";
114
+ if (keystoneVersion) {
115
+ installMode = "package";
116
+ } else if (components) {
117
+ installMode = "registry";
118
+ }
119
+ const tailwind = components?.tailwind;
120
+ const css = tailwind?.css;
121
+ return {
122
+ installMode,
123
+ aliases: components?.aliases ?? null,
124
+ tailwindCssFile: typeof css === "string" && css.length > 0 ? css : null,
125
+ iconLibrary: typeof components?.iconLibrary === "string" ? components.iconLibrary : null,
126
+ isRSC: typeof components?.rsc === "boolean" ? components.rsc : null,
127
+ packageManager: detectPackageManager(cwd, manifest),
128
+ keystoneVersion
129
+ };
130
+ }
131
+ function importLineFor(name, ctx) {
132
+ if (ctx.installMode === "registry") {
133
+ const ui = ctx.aliases?.ui ?? "@/components/ui";
134
+ return `import { \u2026 } from "${ui}/${name}";`;
135
+ }
136
+ return `import { \u2026 } from "@keystoneui/react/${name}";`;
137
+ }
138
+ function describeInstallMode(ctx) {
139
+ if (ctx.installMode === "package") {
140
+ const version = ctx.keystoneVersion ? ` (${ctx.keystoneVersion})` : "";
141
+ return `**package** -- \`@keystoneui/react\`${version} is a dependency. Import from subpaths.`;
142
+ }
143
+ if (ctx.installMode === "registry") {
144
+ const ui = ctx.aliases?.ui ?? "@/components/ui";
145
+ return `**registry** -- source is vendored via shadcn. Import from \`${ui}\`.`;
146
+ }
147
+ return "**unknown** -- neither `@keystoneui/react` in dependencies nor a `components.json`. Ask before writing imports.";
148
+ }
149
+ function describeRsc(isRSC) {
150
+ if (isRSC === null) {
151
+ return "_unknown_";
152
+ }
153
+ return isRSC ? 'yes -- interactive files need `"use client"`' : "no";
154
+ }
155
+ function formatProjectContext(ctx) {
156
+ const rows = [
157
+ `| install mode | ${describeInstallMode(ctx)} |`,
158
+ `| ui alias | ${ctx.aliases?.ui ?? "_unknown_"} |`,
159
+ `| theme CSS file | ${ctx.tailwindCssFile ?? "_unknown_ -- ask which file owns the tokens"} |`,
160
+ `| icon library | ${ctx.iconLibrary ?? "_unknown_ -- ask before importing icons"} |`,
161
+ `| RSC | ${describeRsc(ctx.isRSC)} |`,
162
+ `| package manager | ${ctx.packageManager ?? "_unknown_"} |`
163
+ ];
164
+ return [
165
+ "# Project context",
166
+ "",
167
+ "| field | value |",
168
+ "|---|---|",
169
+ ...rows,
170
+ "",
171
+ `Example import: \`${importLineFor("button", ctx)}\``
172
+ ].join("\n");
173
+ }
174
+
175
+ // src/search.ts
176
+ import fuzzysort from "fuzzysort";
177
+ function applyFilters(items, type, category) {
178
+ let filtered = items;
179
+ if (type) {
180
+ filtered = filtered.filter((i) => i.type === `registry:${type}`);
181
+ }
182
+ if (category) {
183
+ filtered = filtered.filter((i) => i.categories?.includes(category));
184
+ }
185
+ return filtered;
186
+ }
187
+ function searchItems(manifest, query, opts = {}) {
188
+ const { limit = 20, offset = 0, type, category } = opts;
189
+ const items = applyFilters(manifest.items, type, category);
190
+ const targets = items.map((item) => ({
191
+ item,
192
+ searchable: `${item.name} ${item.title ?? ""} ${item.description ?? ""} ${(item.categories ?? []).join(" ")}`
193
+ }));
194
+ const results = fuzzysort.go(query, targets, {
195
+ key: "searchable",
196
+ threshold: -1e4
197
+ }).map((r) => ({ item: r.obj.item, score: r.score }));
198
+ return {
199
+ results: results.slice(offset, offset + limit),
200
+ total: results.length
201
+ };
202
+ }
203
+ function listItems(manifest, opts = {}) {
204
+ const { limit = 20, offset = 0, type, category } = opts;
205
+ const items = applyFilters(manifest.items, type, category);
206
+ return {
207
+ items: items.slice(offset, offset + limit),
208
+ total: items.length
209
+ };
210
+ }
211
+
212
+ // src/tools.ts
213
+ function formatItemSummary(item) {
214
+ const parts = [`**${item.title ?? item.name}** (\`${item.name}\`)`];
215
+ if (item.description) {
216
+ parts.push(item.description);
217
+ }
218
+ if (item.categories?.length) {
219
+ parts.push(`Categories: ${item.categories.join(", ")}`);
220
+ }
221
+ if (item.dependencies?.length) {
222
+ parts.push(`Dependencies: ${item.dependencies.join(", ")}`);
223
+ }
224
+ if (item.registryDependencies?.length) {
225
+ parts.push(
226
+ `Registry dependencies: ${item.registryDependencies.join(", ")}`
227
+ );
228
+ }
229
+ return parts.join("\n");
230
+ }
231
+ function formatItemDetail(item) {
232
+ const sections = [formatItemSummary(item)];
233
+ if (item.files?.length) {
234
+ for (const file of item.files) {
235
+ if (file.content) {
236
+ sections.push(`### ${file.path}
237
+ \`\`\`tsx
238
+ ${file.content}\`\`\``);
239
+ }
240
+ }
241
+ }
242
+ return sections.join("\n\n");
243
+ }
244
+ var listComponentsSchema = z.object({
245
+ limit: z.number().min(1).max(100).default(20).describe("Maximum number of items to return"),
246
+ offset: z.number().min(0).default(0).describe("Number of items to skip"),
247
+ type: z.enum(["ui", "block", "example"]).optional().describe(
248
+ "Filter by item type: 'ui' for components, 'block' for full-page blocks, 'example' for named demo variants like 'table-with-pagination'"
249
+ ),
250
+ category: z.string().optional().describe(
251
+ "Filter by category (e.g. 'authentication', 'login', 'signup', 'navigation', 'data', 'dashboard', 'admin', 'betting'). Currently only block items carry categories."
252
+ )
253
+ });
254
+ async function listComponentsTool(config, input) {
255
+ const manifest = await fetchManifest(config.registry.url);
256
+ const { items, total } = listItems(manifest, input);
257
+ const lines = items.map(formatItemSummary);
258
+ lines.push(`
259
+ ---
260
+ Showing ${items.length} of ${total} items.`);
261
+ if (input.offset + items.length < total) {
262
+ lines.push(`Use offset: ${input.offset + items.length} to see more.`);
263
+ }
264
+ return lines.join("\n\n");
265
+ }
266
+ var searchComponentsSchema = z.object({
267
+ query: z.string().describe("Search query (name, description, or keywords)"),
268
+ limit: z.number().min(1).max(50).default(10).describe("Maximum number of results"),
269
+ type: z.enum(["ui", "block", "example"]).optional().describe(
270
+ "Filter by item type: 'ui' for components, 'block' for full-page blocks, 'example' for named demo variants"
271
+ ),
272
+ category: z.string().optional().describe(
273
+ "Filter by category (e.g. 'authentication', 'login'). Currently only block items carry categories."
274
+ )
275
+ });
276
+ async function searchComponentsTool(config, input) {
277
+ const manifest = await fetchManifest(config.registry.url);
278
+ const { results, total } = searchItems(manifest, input.query, {
279
+ limit: input.limit,
280
+ type: input.type,
281
+ category: input.category
282
+ });
283
+ if (results.length === 0) {
284
+ return `No results found for "${input.query}".`;
285
+ }
286
+ const lines = results.map((r) => formatItemSummary(r.item));
287
+ lines.push(`
288
+ ---
289
+ ${total} result${total === 1 ? "" : "s"} found.`);
290
+ return lines.join("\n\n");
291
+ }
292
+ var viewComponentSchema = z.object({
293
+ names: z.array(z.string()).min(1).max(5).describe(
294
+ 'Component names to view (e.g. ["button", "card"]). Returns full source code.'
295
+ )
296
+ });
297
+ async function viewComponentTool(config, input) {
298
+ const results = await Promise.all(
299
+ input.names.map(async (name) => {
300
+ try {
301
+ const item = await fetchItem(config.registry.url, name);
302
+ return formatItemDetail(item);
303
+ } catch {
304
+ return `**${name}**: Not found in registry.`;
305
+ }
306
+ })
307
+ );
308
+ return results.join("\n\n---\n\n");
309
+ }
310
+ var getAddCommandSchema = z.object({
311
+ names: z.array(z.string()).min(1).max(20).describe("Component names to generate install commands for")
312
+ });
313
+ function getAddCommandTool(config, input) {
314
+ const urls = input.names.map((name) => `${config.registry.url}/${name}.json`);
315
+ const lines = [
316
+ "Install these components with the shadcn CLI:",
317
+ "",
318
+ "```bash",
319
+ `npx shadcn@latest add ${urls.join(" ")}`,
320
+ "```",
321
+ "",
322
+ "Or install individually:",
323
+ ""
324
+ ];
325
+ for (const url of urls) {
326
+ lines.push(`\`\`\`bash
327
+ npx shadcn@latest add ${url}
328
+ \`\`\``);
329
+ }
330
+ return lines.join("\n");
331
+ }
332
+ var getExamplesSchema = z.object({
333
+ name: z.string().describe(
334
+ 'Component or block name (e.g. "button", "signin-01", "tickets-01")'
335
+ )
336
+ });
337
+ async function getExamplesTool(config, input) {
338
+ try {
339
+ const bundle = await fetchExamples(config.registry.url, input.name);
340
+ if (!bundle.files.length) {
341
+ return `**${input.name}**: no example files found.`;
342
+ }
343
+ const sections = [
344
+ `# ${input.name} examples`,
345
+ `${bundle.files.length} file${bundle.files.length === 1 ? "" : "s"}:`,
346
+ ""
347
+ ];
348
+ for (const file of bundle.files) {
349
+ const ext = file.path.includes(".") ? file.path.split(".").pop() : "tsx";
350
+ sections.push(`### ${file.path}`);
351
+ sections.push(`\`\`\`${ext}
352
+ ${file.content}
353
+ \`\`\``);
354
+ }
355
+ return sections.join("\n\n");
356
+ } catch {
357
+ return `**${input.name}**: examples not found in registry.`;
358
+ }
359
+ }
360
+ function getThemeInfoTool(config) {
361
+ const registryUrl = config.registry.url;
362
+ const themeCtx = detectProjectContext();
363
+ return `# Keystone UI Theme
364
+
365
+ ## CSS Setup
366
+
367
+ Add these to \`${themeCtx.tailwindCssFile ?? "your global CSS file"}\` -- edit that
368
+ file rather than creating a new one, or the tokens will not reach the components.
369
+
370
+ \`\`\`css
371
+ @import "tailwindcss";
372
+ @import "@keystoneui/react/base.css";
373
+ \`\`\`
374
+
375
+ ## Semantic Color Tokens (OKLCH)
376
+
377
+ | Token | Light | Dark | Usage |
378
+ |---|---|---|---|
379
+ | \`--primary\` | \`oklch(0.21 0.006 285)\` | \`oklch(0.92 0.004 286)\` | Main actions, CTAs |
380
+ | \`--secondary\` | \`oklch(0.967 0.001 286)\` | \`oklch(0.274 0.006 286)\` | Alternative actions |
381
+ | \`--destructive\` | \`oklch(0.577 0.245 27)\` | \`oklch(0.704 0.191 22)\` | Destructive actions, a metric that got worse |
382
+ | \`--success\` | \`oklch(0.627 0.194 149)\` | \`oklch(0.723 0.19 150)\` | Positive status, a metric that improved |
383
+ | \`--warning\` | \`oklch(0.769 0.188 70)\` | \`oklch(0.828 0.189 84)\` | Caution and threshold states only |
384
+ | \`--muted\` | \`oklch(0.967 0.001 286)\` | \`oklch(0.274 0.006 286)\` | Subdued elements |
385
+ | \`--accent\` | \`oklch(0.967 0.001 286)\` | \`oklch(0.274 0.006 286)\` | Highlights |
386
+ | \`--background\` | \`oklch(1 0 0)\` | \`oklch(0.141 0.005 286)\` | Page background |
387
+ | \`--border\` | \`oklch(0.92 0.004 286)\` | \`oklch(1 0 0 / 10%)\` | Border color |
388
+ | \`--ring\` | \`oklch(0.21 0.006 286)\` | \`oklch(0.92 0.004 286)\` | Focus ring |
389
+
390
+ ## Radius Scale
391
+
392
+ Base: \`--radius: 0.625rem\` (10px). Derived values:
393
+ - \`rounded-sm\`: \`--radius * 0.6\` (6px)
394
+ - \`rounded-md\`: \`--radius * 0.8\` (8px)
395
+ - \`rounded-lg\`: \`--radius\` (10px, base)
396
+ - \`rounded-xl\`: \`--radius * 1.4\` (14px)
397
+
398
+ Ratios, not pixel offsets \u2014 the scale stays proportional at any base.
399
+
400
+ ## Custom Tokens
401
+
402
+ - \`--input-bg\`: Form control background (transparent light, 5% white dark)
403
+ - \`--popup-ring\`: Subtle popup container ring
404
+ - \`--border-muted\`: Lower-contrast separator inside popups, and Card's filled ring
405
+ - \`--success-foreground\` / \`--warning-foreground\`: Text on a success/warning fill. \`--warning-foreground\` is dark, not near-white \u2014 near-white on amber-500 is ~1.9:1 and fails WCAG
406
+ - \`--sidebar\` + 7 \`--sidebar-*\`: Read by an imported shadcn sidebar (keystone ships none). Declared as aliases, so the sidebar follows the active keystone theme
407
+
408
+ Use \`text-success\` / \`bg-warning\` rather than raw \`emerald\`/\`amber\` classes, and never add a \`dark:\` override to a status token.
409
+
410
+ ## Dark Mode
411
+
412
+ Add the \`dark\` class to a parent element.
413
+
414
+ ## Registry
415
+
416
+ Get the full style definition:
417
+ \`\`\`bash
418
+ npx shadcn@latest add ${registryUrl}/default.json
419
+ \`\`\``;
420
+ }
421
+ function auditChecklistTool() {
422
+ const ctx = detectProjectContext();
423
+ const registryMode = ctx.installMode === "registry";
424
+ const uiAlias = ctx.aliases?.ui ?? "@/components/ui";
425
+ const cssFile = ctx.tailwindCssFile ?? "your CSS entry point";
426
+ const iconPkg = iconPackageFor(ctx.iconLibrary);
427
+ return `# Post-Install Audit Checklist
428
+
429
+ ## 1. CSS Setup (\`${cssFile}\`)
430
+ - [ ] \`@import "tailwindcss"\` is present in \`${cssFile}\`
431
+ - [ ] \`@import "@keystoneui/react/base.css"\` is imported AFTER tailwindcss
432
+ - [ ] Dark mode variant is configured: \`@custom-variant dark (&:is(.dark *))\`
433
+
434
+ ## 2. Tailwind Configuration
435
+ - [ ] Using Tailwind CSS v4.1+
436
+ - [ ] Content paths include your component files
437
+
438
+ ## 3. Dependencies
439
+ - [ ] \`@keystoneui/react\` is installed
440
+ - [ ] Component-specific peer dependencies are installed (check each component's \`dependencies\` field)
441
+ - [ ] Using React 19+
442
+
443
+ ## 4. Import Pattern (install mode: ${ctx.installMode})
444
+ ${registryMode ? `- [ ] Importing from the project alias: \`import { Button } from "${uiAlias}/button"\`
445
+ - [ ] NOT importing from \`@keystoneui/react\` -- it is not a dependency in this project` : `- [ ] Using subpath imports: \`import { Button } from "@keystoneui/react/button"\`
446
+ - [ ] NOT using barrel imports from \`@keystoneui/react\``}
447
+
448
+ ## 5. Theme Variables
449
+ - [ ] CSS custom properties are defined in \`:root\` (see \`get_theme_info\` for the full list)
450
+ - [ ] Dark mode variables are defined in \`.dark\` selector
451
+
452
+ ## 6. Icon Library
453
+ - [ ] Using \`${iconPkg}\` for icons, matching this project's configured icon library
454
+
455
+ ## 7. Common Issues
456
+ - [ ] If hover styles feel "sticky" on mobile: ensure \`base.css\` is imported (it gates \`hover:\` with \`@media (hover: hover)\`)
457
+ - [ ] If buttons don't show pointer cursor: Tailwind v4 changed the default \u2014 Keystone UI handles this internally
458
+ - [ ] If focus rings look wrong: don't mix outline-based and ring-based focus patterns`;
459
+ }
460
+ var ICON_PACKAGES = {
461
+ lucide: "lucide-react",
462
+ tabler: "@tabler/icons-react",
463
+ hugeicons: "@hugeicons/react",
464
+ remix: "@remixicon/react"
465
+ };
466
+ function iconPackageFor(library) {
467
+ if (library === null) {
468
+ return "lucide-react";
469
+ }
470
+ return ICON_PACKAGES[library] ?? library;
471
+ }
472
+ var getDocsSchema = z.object({
473
+ name: z.string().describe('Component or block name (e.g. "select", "signin-01")'),
474
+ type: z.enum(["component", "block"]).default("component").describe("Which docs section to read from")
475
+ });
476
+ async function getDocsTool(config, input) {
477
+ const section = input.type === "block" ? "blocks" : "components";
478
+ const url = `${config.docsUrl}/llms.mdx/docs/${section}/${input.name}`;
479
+ try {
480
+ const response = await fetch(url, {
481
+ headers: { "User-Agent": "keystoneui-mcp" },
482
+ signal: AbortSignal.timeout(3e4)
483
+ });
484
+ if (!response.ok) {
485
+ return `**${input.name}**: no ${input.type} docs found (${response.status}). Try search_components to find the right name.`;
486
+ }
487
+ return await response.text();
488
+ } catch {
489
+ return `**${input.name}**: could not reach ${url}.`;
490
+ }
491
+ }
492
+ var emptySchema = z.object({});
493
+ var TOOL_SPECS = {
494
+ list_components: {
495
+ description: "List all available Keystone UI components, blocks, and named examples with pagination. Returns name, description, categories, and dependency info for each item.",
496
+ schema: listComponentsSchema
497
+ },
498
+ search_components: {
499
+ description: "Fuzzy search components, blocks, and named examples (e.g., `table-with-pagination`, `card-with-image`). Categories (e.g. 'authentication', 'login') participate in fuzzy matching. Use when the exact name isn't known; pair with `view_component` or `get_examples` to see code.",
500
+ schema: searchComponentsSchema
501
+ },
502
+ view_component: {
503
+ description: "Get full details for one or more Keystone UI components, including complete source code, dependencies, and registry dependencies. Use this to understand how a component works before using or customizing it.",
504
+ schema: viewComponentSchema
505
+ },
506
+ get_add_command: {
507
+ description: "Generate the shadcn CLI command to install one or more Keystone UI components into a project.",
508
+ schema: getAddCommandSchema
509
+ },
510
+ get_examples: {
511
+ description: "Fetch live demo files for a Keystone UI component or block. Returns the TSX source for every example/demo associated with the name (e.g. button, signin-01, tickets-01). Use after view_component to see real-world usage patterns.",
512
+ schema: getExamplesSchema
513
+ },
514
+ 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.",
516
+ schema: getDocsSchema
517
+ },
518
+ get_project_context: {
519
+ description: "Read this project's Keystone UI setup: install mode (npm package vs vendored registry source), path aliases, which CSS file owns the theme tokens, icon library, whether React Server Components are in use, and the package manager. Call this FIRST -- import style and which file to edit both depend on it, and guessing wrong is the most common source of broken output.",
520
+ schema: emptySchema
521
+ },
522
+ get_theme_info: {
523
+ description: "Get Keystone UI theme configuration: CSS setup, semantic color tokens (OKLCH), radius scale, dark mode setup, and custom tokens.",
524
+ schema: emptySchema
525
+ },
526
+ audit_checklist: {
527
+ description: "Get a post-install audit checklist to verify Keystone UI is correctly configured in your project. Covers CSS setup, Tailwind config, dependencies, imports, and common issues.",
528
+ schema: emptySchema
529
+ }
530
+ };
531
+ function getProjectContextTool() {
532
+ return formatProjectContext(detectProjectContext());
533
+ }
534
+
535
+ export {
536
+ loadProjectConfig,
537
+ readPackageVersion,
538
+ detectProjectContext,
539
+ listComponentsTool,
540
+ searchComponentsTool,
541
+ viewComponentTool,
542
+ getAddCommandTool,
543
+ getExamplesTool,
544
+ getThemeInfoTool,
545
+ auditChecklistTool,
546
+ getDocsTool,
547
+ TOOL_SPECS,
548
+ getProjectContextTool
549
+ };
package/dist/index.js CHANGED
@@ -1,28 +1,20 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  auditChecklistTool,
4
+ detectProjectContext,
4
5
  getExamplesTool,
5
6
  listComponentsTool,
6
7
  loadProjectConfig,
8
+ readPackageVersion,
7
9
  searchComponentsTool,
8
10
  viewComponentTool
9
- } from "./chunk-DZNQW5EA.js";
11
+ } from "./chunk-VGA5HGCS.js";
10
12
 
11
13
  // src/info.ts
12
14
  import { existsSync, readFileSync } from "fs";
13
15
  import { homedir } from "os";
14
16
  import { resolve } from "path";
15
- import { fileURLToPath } from "url";
16
17
  var DEFAULT_DOCS_URL = "https://keystoneui.io";
17
- function readPackageVersion() {
18
- try {
19
- const pkgPath = fileURLToPath(new URL("../package.json", import.meta.url));
20
- const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
21
- return pkg.version ?? "unknown";
22
- } catch {
23
- return "unknown";
24
- }
25
- }
26
18
  function detectMcpClients(cwd) {
27
19
  const candidates = [
28
20
  { name: "claude", path: resolve(cwd, ".mcp.json") },
@@ -82,8 +74,9 @@ function collect() {
82
74
  const docsUrl = process.env.KEYSTONEUI_URL ?? DEFAULT_DOCS_URL;
83
75
  const version = readPackageVersion();
84
76
  return {
85
- schema: 1,
77
+ schema: 2,
86
78
  package: { name: "@keystoneui/mcp", version },
79
+ project: detectProjectContext(cwd),
87
80
  environment: {
88
81
  node: process.version,
89
82
  platform: process.platform,
@@ -110,6 +103,17 @@ function printText(data) {
110
103
  const lines = [];
111
104
  lines.push(`${data.package.name} v${data.package.version}`);
112
105
  lines.push("");
106
+ const p = data.project;
107
+ lines.push("Project");
108
+ lines.push(` ${pad("Install mode")}${p.installMode}`);
109
+ lines.push(` ${pad("UI alias")}${p.aliases?.ui ?? "(unknown)"}`);
110
+ lines.push(` ${pad("Theme CSS")}${p.tailwindCssFile ?? "(unknown)"}`);
111
+ lines.push(` ${pad("Icon library")}${p.iconLibrary ?? "(unknown)"}`);
112
+ lines.push(
113
+ ` ${pad("RSC")}${p.isRSC === null ? "(unknown)" : String(p.isRSC)}`
114
+ );
115
+ lines.push(` ${pad("Package manager")}${p.packageManager ?? "(unknown)"}`);
116
+ lines.push("");
113
117
  lines.push("Environment");
114
118
  lines.push(` ${pad("Node")}${data.environment.node}`);
115
119
  lines.push(` ${pad("Platform")}${data.environment.platform}`);
@@ -542,6 +546,6 @@ if (isCliVerb(verbCandidate)) {
542
546
  process.exit();
543
547
  }
544
548
  var { StdioServerTransport } = await import("@modelcontextprotocol/sdk/server/stdio.js");
545
- var { server } = await import("./server-5ZV7UIUD.js");
549
+ var { server } = await import("./server-2OYYC4H7.js");
546
550
  var transport = new StdioServerTransport();
547
551
  await server.connect(transport);
@@ -0,0 +1,88 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ TOOL_SPECS,
4
+ auditChecklistTool,
5
+ getAddCommandTool,
6
+ getDocsTool,
7
+ getExamplesTool,
8
+ getProjectContextTool,
9
+ getThemeInfoTool,
10
+ listComponentsTool,
11
+ loadProjectConfig,
12
+ readPackageVersion,
13
+ searchComponentsTool,
14
+ viewComponentTool
15
+ } from "./chunk-VGA5HGCS.js";
16
+
17
+ // src/server.ts
18
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
19
+ var config = loadProjectConfig();
20
+ var server = new McpServer(
21
+ {
22
+ name: "keystoneui",
23
+ version: readPackageVersion()
24
+ },
25
+ {
26
+ capabilities: {
27
+ tools: {}
28
+ },
29
+ instructions: "Keystone UI MCP server. Use these tools to discover, search, view, and install Keystone UI components. Start with list_components or search_components to explore available components, then view_component to get full source code."
30
+ }
31
+ );
32
+ function text(value) {
33
+ return { content: [{ type: "text", text: value }] };
34
+ }
35
+ server.tool(
36
+ "list_components",
37
+ TOOL_SPECS.list_components.description,
38
+ TOOL_SPECS.list_components.schema.shape,
39
+ async (input) => text(await listComponentsTool(config, input))
40
+ );
41
+ server.tool(
42
+ "search_components",
43
+ TOOL_SPECS.search_components.description,
44
+ TOOL_SPECS.search_components.schema.shape,
45
+ async (input) => text(await searchComponentsTool(config, input))
46
+ );
47
+ server.tool(
48
+ "view_component",
49
+ TOOL_SPECS.view_component.description,
50
+ TOOL_SPECS.view_component.schema.shape,
51
+ async (input) => text(await viewComponentTool(config, input))
52
+ );
53
+ server.tool(
54
+ "get_add_command",
55
+ TOOL_SPECS.get_add_command.description,
56
+ TOOL_SPECS.get_add_command.schema.shape,
57
+ (input) => text(getAddCommandTool(config, input))
58
+ );
59
+ server.tool(
60
+ "get_examples",
61
+ TOOL_SPECS.get_examples.description,
62
+ TOOL_SPECS.get_examples.schema.shape,
63
+ async (input) => text(await getExamplesTool(config, input))
64
+ );
65
+ server.tool(
66
+ "get_docs",
67
+ TOOL_SPECS.get_docs.description,
68
+ TOOL_SPECS.get_docs.schema.shape,
69
+ async (input) => text(await getDocsTool(config, input))
70
+ );
71
+ server.tool(
72
+ "get_project_context",
73
+ TOOL_SPECS.get_project_context.description,
74
+ () => text(getProjectContextTool())
75
+ );
76
+ server.tool(
77
+ "get_theme_info",
78
+ TOOL_SPECS.get_theme_info.description,
79
+ async () => text(await getThemeInfoTool(config))
80
+ );
81
+ server.tool(
82
+ "audit_checklist",
83
+ TOOL_SPECS.audit_checklist.description,
84
+ async () => text(await auditChecklistTool())
85
+ );
86
+ export {
87
+ server
88
+ };
package/package.json CHANGED
@@ -1,9 +1,21 @@
1
1
  {
2
2
  "name": "@keystoneui/mcp",
3
- "version": "0.2.0-beta.1",
3
+ "version": "0.2.0-beta.2",
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",
7
+ "homepage": "https://keystoneui.io/docs/agents/mcp-server",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/keystone-ui/react.git",
11
+ "directory": "packages/keystoneui-mcp"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/keystone-ui/react/issues"
15
+ },
16
+ "engines": {
17
+ "node": ">=22"
18
+ },
7
19
  "keywords": [
8
20
  "keystoneui",
9
21
  "mcp",
@@ -25,14 +37,15 @@
25
37
  "README.md"
26
38
  ],
27
39
  "dependencies": {
28
- "@modelcontextprotocol/sdk": "^1.29.0",
29
- "fuzzysort": "^3.1.0",
30
- "zod": "^4.3.6"
40
+ "@modelcontextprotocol/sdk": "^1.30.0",
41
+ "fuzzysort": "^4.0.2",
42
+ "zod": "^4.5.4"
31
43
  },
32
44
  "devDependencies": {
33
- "@types/node": "^25.6.0",
34
- "tsup": "^8.5.0",
45
+ "@types/node": "^26.4.1",
46
+ "tsup": "^8.5.1",
35
47
  "typescript": "^6.0.3",
48
+ "vitest": "^4.1.11",
36
49
  "@keystoneui/typescript-config": "0.0.0"
37
50
  },
38
51
  "publishConfig": {
@@ -41,6 +54,8 @@
41
54
  "scripts": {
42
55
  "build": "tsup",
43
56
  "dev": "tsup --watch",
44
- "clean": "rm -rf dist node_modules"
57
+ "clean": "rm -rf dist node_modules",
58
+ "test": "vitest run",
59
+ "test:watch": "vitest"
45
60
  }
46
61
  }
@@ -1,331 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // src/config.ts
4
- import { existsSync, readFileSync } from "fs";
5
- import { resolve } from "path";
6
- var DEFAULT_REGISTRY_URL = "https://keystoneui.io/r";
7
- function loadProjectConfig() {
8
- const registryUrlEnv = process.env.KEYSTONEUI_REGISTRY_URL;
9
- if (registryUrlEnv) {
10
- return { registry: { url: registryUrlEnv } };
11
- }
12
- const cwd = process.cwd();
13
- const configPath = resolve(cwd, "components.json");
14
- if (existsSync(configPath)) {
15
- try {
16
- const raw = JSON.parse(readFileSync(configPath, "utf-8"));
17
- const registryUrl = raw?.registries?.["@keystoneui"]?.url ?? DEFAULT_REGISTRY_URL;
18
- return { registry: { url: registryUrl } };
19
- } catch {
20
- }
21
- }
22
- return { registry: { url: DEFAULT_REGISTRY_URL } };
23
- }
24
-
25
- // src/tools.ts
26
- import { z } from "zod";
27
-
28
- // src/fetcher.ts
29
- var cache = /* @__PURE__ */ new Map();
30
- var CACHE_TTL_MS = 5 * 60 * 1e3;
31
- async function fetchJson(url) {
32
- const cached = cache.get(url);
33
- if (cached && Date.now() - cached.timestamp < CACHE_TTL_MS) {
34
- return cached.data;
35
- }
36
- const response = await fetch(url);
37
- if (!response.ok) {
38
- throw new Error(`Failed to fetch ${url}: ${response.status}`);
39
- }
40
- const data = await response.json();
41
- cache.set(url, { data, timestamp: Date.now() });
42
- return data;
43
- }
44
- function fetchManifest(registryUrl) {
45
- return fetchJson(`${registryUrl}/registry.json`);
46
- }
47
- function fetchItem(registryUrl, name) {
48
- return fetchJson(`${registryUrl}/${name}.json`);
49
- }
50
- function fetchExamples(registryUrl, name) {
51
- return fetchJson(`${registryUrl}/demos/${name}`);
52
- }
53
-
54
- // src/search.ts
55
- import fuzzysort from "fuzzysort";
56
- function applyFilters(items, type, category) {
57
- let filtered = items;
58
- if (type) {
59
- filtered = filtered.filter((i) => i.type === `registry:${type}`);
60
- }
61
- if (category) {
62
- filtered = filtered.filter((i) => i.categories?.includes(category));
63
- }
64
- return filtered;
65
- }
66
- function searchItems(manifest, query, opts = {}) {
67
- const { limit = 20, offset = 0, type, category } = opts;
68
- const items = applyFilters(manifest.items, type, category);
69
- const targets = items.map((item) => ({
70
- item,
71
- searchable: `${item.name} ${item.title ?? ""} ${item.description ?? ""} ${(item.categories ?? []).join(" ")}`
72
- }));
73
- const results = fuzzysort.go(query, targets, {
74
- key: "searchable",
75
- threshold: -1e4
76
- }).map((r) => ({ item: r.obj.item, score: r.score }));
77
- return {
78
- results: results.slice(offset, offset + limit),
79
- total: results.length
80
- };
81
- }
82
- function listItems(manifest, opts = {}) {
83
- const { limit = 20, offset = 0, type, category } = opts;
84
- const items = applyFilters(manifest.items, type, category);
85
- return {
86
- items: items.slice(offset, offset + limit),
87
- total: items.length
88
- };
89
- }
90
-
91
- // src/tools.ts
92
- function formatItemSummary(item) {
93
- const parts = [`**${item.title ?? item.name}** (\`${item.name}\`)`];
94
- if (item.description) {
95
- parts.push(item.description);
96
- }
97
- if (item.categories?.length) {
98
- parts.push(`Categories: ${item.categories.join(", ")}`);
99
- }
100
- if (item.dependencies?.length) {
101
- parts.push(`Dependencies: ${item.dependencies.join(", ")}`);
102
- }
103
- if (item.registryDependencies?.length) {
104
- parts.push(
105
- `Registry dependencies: ${item.registryDependencies.join(", ")}`
106
- );
107
- }
108
- return parts.join("\n");
109
- }
110
- function formatItemDetail(item) {
111
- const sections = [formatItemSummary(item)];
112
- if (item.files?.length) {
113
- for (const file of item.files) {
114
- if (file.content) {
115
- sections.push(`### ${file.path}
116
- \`\`\`tsx
117
- ${file.content}\`\`\``);
118
- }
119
- }
120
- }
121
- return sections.join("\n\n");
122
- }
123
- var listComponentsSchema = z.object({
124
- limit: z.number().min(1).max(100).default(20).describe("Maximum number of items to return"),
125
- offset: z.number().min(0).default(0).describe("Number of items to skip"),
126
- type: z.enum(["ui", "block", "example"]).optional().describe(
127
- "Filter by item type: 'ui' for components, 'block' for full-page blocks, 'example' for named demo variants like 'table-with-pagination'"
128
- ),
129
- category: z.string().optional().describe(
130
- "Filter by category (e.g. 'authentication', 'login', 'signup', 'navigation', 'data', 'betting'). Currently only block items carry categories."
131
- )
132
- });
133
- async function listComponentsTool(config, input) {
134
- const manifest = await fetchManifest(config.registry.url);
135
- const { items, total } = listItems(manifest, input);
136
- const lines = items.map(formatItemSummary);
137
- lines.push(`
138
- ---
139
- Showing ${items.length} of ${total} items.`);
140
- if (input.offset + items.length < total) {
141
- lines.push(`Use offset: ${input.offset + items.length} to see more.`);
142
- }
143
- return lines.join("\n\n");
144
- }
145
- var searchComponentsSchema = z.object({
146
- query: z.string().describe("Search query (name, description, or keywords)"),
147
- limit: z.number().min(1).max(50).default(10).describe("Maximum number of results"),
148
- type: z.enum(["ui", "block", "example"]).optional().describe(
149
- "Filter by item type: 'ui' for components, 'block' for full-page blocks, 'example' for named demo variants"
150
- ),
151
- category: z.string().optional().describe(
152
- "Filter by category (e.g. 'authentication', 'login'). Currently only block items carry categories."
153
- )
154
- });
155
- async function searchComponentsTool(config, input) {
156
- const manifest = await fetchManifest(config.registry.url);
157
- const { results, total } = searchItems(manifest, input.query, {
158
- limit: input.limit,
159
- type: input.type,
160
- category: input.category
161
- });
162
- if (results.length === 0) {
163
- return `No results found for "${input.query}".`;
164
- }
165
- const lines = results.map((r) => formatItemSummary(r.item));
166
- lines.push(`
167
- ---
168
- ${total} result${total === 1 ? "" : "s"} found.`);
169
- return lines.join("\n\n");
170
- }
171
- var viewComponentSchema = z.object({
172
- names: z.array(z.string()).min(1).max(5).describe(
173
- 'Component names to view (e.g. ["button", "card"]). Returns full source code.'
174
- )
175
- });
176
- async function viewComponentTool(config, input) {
177
- const results = await Promise.all(
178
- input.names.map(async (name) => {
179
- try {
180
- const item = await fetchItem(config.registry.url, name);
181
- return formatItemDetail(item);
182
- } catch {
183
- return `**${name}**: Not found in registry.`;
184
- }
185
- })
186
- );
187
- return results.join("\n\n---\n\n");
188
- }
189
- var getAddCommandSchema = z.object({
190
- names: z.array(z.string()).min(1).describe("Component names to generate install commands for")
191
- });
192
- function getAddCommandTool(config, input) {
193
- const urls = input.names.map((name) => `${config.registry.url}/${name}.json`);
194
- const lines = [
195
- "Install these components with the shadcn CLI:",
196
- "",
197
- "```bash",
198
- `npx shadcn@latest add ${urls.join(" ")}`,
199
- "```",
200
- "",
201
- "Or install individually:",
202
- ""
203
- ];
204
- for (const url of urls) {
205
- lines.push(`\`\`\`bash
206
- npx shadcn@latest add ${url}
207
- \`\`\``);
208
- }
209
- return lines.join("\n");
210
- }
211
- var getExamplesSchema = z.object({
212
- name: z.string().describe(
213
- 'Component or block name to fetch examples for (e.g. "button" or "tickets-01")'
214
- )
215
- });
216
- async function getExamplesTool(config, input) {
217
- try {
218
- const bundle = await fetchExamples(config.registry.url, input.name);
219
- if (!bundle.files.length) {
220
- return `**${input.name}**: no example files found.`;
221
- }
222
- const sections = [
223
- `# ${input.name} examples`,
224
- `${bundle.files.length} file${bundle.files.length === 1 ? "" : "s"}:`,
225
- ""
226
- ];
227
- for (const file of bundle.files) {
228
- const ext = file.path.includes(".") ? file.path.split(".").pop() : "tsx";
229
- sections.push(`### ${file.path}`);
230
- sections.push(`\`\`\`${ext}
231
- ${file.content}
232
- \`\`\``);
233
- }
234
- return sections.join("\n\n");
235
- } catch {
236
- return `**${input.name}**: examples not found in registry.`;
237
- }
238
- }
239
- function getThemeInfoTool(config) {
240
- const registryUrl = config.registry.url;
241
- return `# Keystone UI Theme
242
-
243
- ## CSS Setup
244
-
245
- \`\`\`css
246
- @import "tailwindcss";
247
- @import "@keystoneui/react/base.css";
248
- \`\`\`
249
-
250
- ## Semantic Color Tokens (OKLCH)
251
-
252
- | Token | Light | Dark | Usage |
253
- |---|---|---|---|
254
- | \`--primary\` | \`oklch(0.21 0.006 285)\` | \`oklch(0.92 0.004 286)\` | Main actions, CTAs |
255
- | \`--secondary\` | \`oklch(0.967 0.001 286)\` | \`oklch(0.274 0.006 286)\` | Alternative actions |
256
- | \`--destructive\` | \`oklch(0.577 0.245 27)\` | \`oklch(0.704 0.191 22)\` | Destructive actions |
257
- | \`--muted\` | \`oklch(0.967 0.001 286)\` | \`oklch(0.274 0.006 286)\` | Subdued elements |
258
- | \`--accent\` | \`oklch(0.967 0.001 286)\` | \`oklch(0.274 0.006 286)\` | Highlights |
259
- | \`--background\` | \`oklch(1 0 0)\` | \`oklch(0.141 0.005 286)\` | Page background |
260
- | \`--border\` | \`oklch(0.92 0.004 286)\` | \`oklch(1 0 0 / 10%)\` | Border color |
261
- | \`--ring\` | \`oklch(0.21 0.006 286)\` | \`oklch(0.92 0.004 286)\` | Focus ring |
262
-
263
- ## Radius Scale
264
-
265
- Base: \`--radius: 0.625rem\` (10px). Derived values:
266
- - \`rounded-sm\`: 6px
267
- - \`rounded-md\`: 8px
268
- - \`rounded-lg\`: 10px (base)
269
- - \`rounded-xl\`: 14px
270
-
271
- ## Custom Tokens
272
-
273
- - \`--input-bg\`: Form control background (transparent light, 5% white dark)
274
- - \`--popup-ring\`: Subtle popup container ring
275
- - \`--border-muted\`: Lower-contrast separator inside popups
276
-
277
- ## Dark Mode
278
-
279
- Add the \`dark\` class to a parent element.
280
-
281
- ## Registry
282
-
283
- Get the full style definition:
284
- \`\`\`bash
285
- npx shadcn@latest add ${registryUrl}/default.json
286
- \`\`\``;
287
- }
288
- function auditChecklistTool() {
289
- return `# Post-Install Audit Checklist
290
-
291
- ## 1. CSS Setup
292
- - [ ] \`@import "tailwindcss"\` is present in your CSS entry point
293
- - [ ] \`@import "@keystoneui/react/base.css"\` is imported AFTER tailwindcss
294
- - [ ] Dark mode variant is configured: \`@custom-variant dark (&:is(.dark *))\`
295
-
296
- ## 2. Tailwind Configuration
297
- - [ ] Using Tailwind CSS v4.1+
298
- - [ ] Content paths include your component files
299
-
300
- ## 3. Dependencies
301
- - [ ] \`@keystoneui/react\` is installed
302
- - [ ] Component-specific peer dependencies are installed (check each component's \`dependencies\` field)
303
- - [ ] Using React 19+
304
-
305
- ## 4. Import Pattern
306
- - [ ] Using subpath imports: \`import { Button } from "@keystoneui/react/button"\`
307
- - [ ] NOT using barrel imports from \`@keystoneui/react\`
308
-
309
- ## 5. Theme Variables
310
- - [ ] CSS custom properties are defined in \`:root\` (see \`get_theme_info\` for the full list)
311
- - [ ] Dark mode variables are defined in \`.dark\` selector
312
-
313
- ## 6. Icon Library
314
- - [ ] Using \`lucide-react\` for icons (not \`@iconify/react\` or others)
315
-
316
- ## 7. Common Issues
317
- - [ ] If hover styles feel "sticky" on mobile: ensure \`base.css\` is imported (it gates \`hover:\` with \`@media (hover: hover)\`)
318
- - [ ] If buttons don't show pointer cursor: Tailwind v4 changed the default \u2014 Keystone UI handles this internally
319
- - [ ] If focus rings look wrong: don't mix outline-based and ring-based focus patterns`;
320
- }
321
-
322
- export {
323
- loadProjectConfig,
324
- listComponentsTool,
325
- searchComponentsTool,
326
- viewComponentTool,
327
- getAddCommandTool,
328
- getExamplesTool,
329
- getThemeInfoTool,
330
- auditChecklistTool
331
- };
@@ -1,137 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- auditChecklistTool,
4
- getAddCommandTool,
5
- getExamplesTool,
6
- getThemeInfoTool,
7
- listComponentsTool,
8
- loadProjectConfig,
9
- searchComponentsTool,
10
- viewComponentTool
11
- } from "./chunk-DZNQW5EA.js";
12
-
13
- // src/server.ts
14
- import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
15
- import { z } from "zod";
16
- var config = loadProjectConfig();
17
- var server = new McpServer(
18
- {
19
- name: "keystoneui",
20
- version: "0.1.0"
21
- },
22
- {
23
- capabilities: {
24
- tools: {}
25
- },
26
- instructions: "Keystone UI MCP server. Use these tools to discover, search, view, and install Keystone UI components. Start with list_components or search_components to explore available components, then view_component to get full source code."
27
- }
28
- );
29
- server.tool(
30
- "list_components",
31
- "List all available Keystone UI components, blocks, and named examples with pagination. Returns name, description, categories, and dependency info for each item.",
32
- {
33
- limit: z.number().min(1).max(100).default(20).describe("Maximum number of items to return"),
34
- offset: z.number().min(0).default(0).describe("Number of items to skip"),
35
- type: z.enum(["ui", "block", "example"]).optional().describe(
36
- "Filter by item type: 'ui' for components, 'block' for full-page blocks, 'example' for named demo variants like 'table-with-pagination'"
37
- ),
38
- category: z.string().optional().describe(
39
- "Filter by category (e.g. 'authentication', 'login', 'signup', 'navigation', 'data', 'betting'). Currently only block items carry categories."
40
- )
41
- },
42
- async ({ limit, offset, type, category }) => ({
43
- content: [
44
- {
45
- type: "text",
46
- text: await listComponentsTool(config, {
47
- limit,
48
- offset,
49
- type,
50
- category
51
- })
52
- }
53
- ]
54
- })
55
- );
56
- server.tool(
57
- "search_components",
58
- "Fuzzy search components, blocks, and named examples (e.g., `table-with-pagination`, `card-with-image`). Categories (e.g. 'authentication', 'login') participate in fuzzy matching. Use when the exact name isn't known; pair with `view_component` or `get_examples` to see code.",
59
- {
60
- query: z.string().describe("Search query (name, description, or keywords)"),
61
- limit: z.number().min(1).max(50).default(10).describe("Maximum number of results"),
62
- type: z.enum(["ui", "block", "example"]).optional().describe(
63
- "Filter by item type: 'ui' for components, 'block' for full-page blocks, 'example' for named demo variants"
64
- ),
65
- category: z.string().optional().describe(
66
- "Filter by category (e.g. 'authentication', 'login'). Currently only block items carry categories."
67
- )
68
- },
69
- async ({ query, limit, type, category }) => ({
70
- content: [
71
- {
72
- type: "text",
73
- text: await searchComponentsTool(config, {
74
- query,
75
- limit,
76
- type,
77
- category
78
- })
79
- }
80
- ]
81
- })
82
- );
83
- server.tool(
84
- "view_component",
85
- "Get full details for one or more Keystone UI components, including complete source code, dependencies, and registry dependencies. Use this to understand how a component works before using or customizing it.",
86
- {
87
- names: z.array(z.string()).min(1).max(5).describe(
88
- 'Component names to view (e.g. ["button", "card"]). Returns full source code.'
89
- )
90
- },
91
- async ({ names }) => ({
92
- content: [
93
- { type: "text", text: await viewComponentTool(config, { names }) }
94
- ]
95
- })
96
- );
97
- server.tool(
98
- "get_add_command",
99
- "Generate the shadcn CLI command to install one or more Keystone UI components into a project.",
100
- {
101
- names: z.array(z.string()).min(1).describe("Component names to generate install commands for")
102
- },
103
- async ({ names }) => ({
104
- content: [
105
- { type: "text", text: await getAddCommandTool(config, { names }) }
106
- ]
107
- })
108
- );
109
- server.tool(
110
- "get_examples",
111
- "Fetch live demo files for a Keystone UI component or block. Returns the TSX source for every example/demo associated with the name (e.g. button, signin-01, tickets-01). Use after view_component to see real-world usage patterns.",
112
- {
113
- name: z.string().describe(
114
- 'Component or block name (e.g. "button", "signin-01", "tickets-01")'
115
- )
116
- },
117
- async ({ name }) => ({
118
- content: [{ type: "text", text: await getExamplesTool(config, { name }) }]
119
- })
120
- );
121
- server.tool(
122
- "get_theme_info",
123
- "Get Keystone UI theme configuration: CSS setup, semantic color tokens (OKLCH), radius scale, dark mode setup, and custom tokens.",
124
- async () => ({
125
- content: [{ type: "text", text: await getThemeInfoTool(config) }]
126
- })
127
- );
128
- server.tool(
129
- "audit_checklist",
130
- "Get a post-install audit checklist to verify Keystone UI is correctly configured in your project. Covers CSS setup, Tailwind config, dependencies, imports, and common issues.",
131
- async () => ({
132
- content: [{ type: "text", text: await auditChecklistTool() }]
133
- })
134
- );
135
- export {
136
- server
137
- };