@rlx-ui/mcp 0.0.2 → 0.0.4

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/dist/cli.js CHANGED
@@ -1,214 +1,192 @@
1
- import { McpServer as I } from "@modelcontextprotocol/sdk/server/mcp.js";
2
- import { StdioServerTransport as U } from "@modelcontextprotocol/sdk/server/stdio.js";
3
- import { z as p } from "zod";
4
- import { readFileSync as _ } from "fs";
5
- import { fileURLToPath as P } from "url";
6
- import { join as x, dirname as X } from "path";
7
- const E = P(import.meta.url), w = X(E);
8
- let h = null;
9
- function f() {
10
- if (h)
11
- return h;
1
+ import { McpServer as L } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { StdioServerTransport as R } from "@modelcontextprotocol/sdk/server/stdio.js";
3
+ import { z as c } from "zod";
4
+ import { promises as T, readFileSync as j } from "node:fs";
5
+ import { fileURLToPath as C } from "node:url";
6
+ import x, { join as p, dirname as S } from "node:path";
7
+ function l(s) {
8
+ return {
9
+ content: [
10
+ {
11
+ type: "text",
12
+ text: JSON.stringify(s, null, 2)
13
+ }
14
+ ]
15
+ };
16
+ }
17
+ function U(s, t, i) {
18
+ return l({
19
+ error: s,
20
+ ...t && { slug: t },
21
+ ...i && { category: i }
22
+ });
23
+ }
24
+ function d(s, t) {
25
+ return U("Component not found", s, t);
26
+ }
27
+ async function I(s) {
28
+ try {
29
+ return await T.readFile(s, "utf-8");
30
+ } catch {
31
+ return null;
32
+ }
33
+ }
34
+ const v = C(import.meta.url), f = S(v);
35
+ let m = null;
36
+ function u() {
37
+ if (m)
38
+ return m;
12
39
  try {
13
40
  const s = [
14
- x(w, "data/registry.json"),
41
+ p(f, "data/registry.json"),
15
42
  // From dist/ to dist/data/ (copied during build)
16
- x(w, "../src/data/registry.json"),
43
+ p(f, "../src/data/registry.json"),
17
44
  // From dist/ to src/data/ (development)
18
- x(w, "../data/registry.json"),
45
+ p(f, "../data/registry.json"),
19
46
  // Fallback
20
- x(process.cwd(), "src/data/registry.json"),
47
+ p(process.cwd(), "src/data/registry.json"),
21
48
  // From package root (published)
22
- x(process.cwd(), "libs/rlx-ui/mcp/src/data/registry.json")
49
+ p(process.cwd(), "libs/rlx-ui/mcp/src/data/registry.json")
23
50
  // Development
24
51
  ];
25
- let i = null;
26
- for (const t of s)
52
+ let t = null;
53
+ for (const i of s)
27
54
  try {
28
- i = _(t, "utf-8");
55
+ t = j(i, "utf-8");
29
56
  break;
30
57
  } catch {
31
58
  continue;
32
59
  }
33
- if (!i)
60
+ if (!t)
34
61
  throw new Error("Could not find registry.json in any expected location");
35
- return h = JSON.parse(i), h;
62
+ return m = JSON.parse(t), m;
36
63
  } catch (s) {
37
- return console.error("Warning: Could not load component registry:", s), h = {
64
+ return console.error("Warning: Could not load component registry:", s), m = {
38
65
  widgets: [],
39
66
  components: [],
40
67
  animates: [],
41
68
  hooks: [],
42
69
  utils: [],
43
70
  extractedAt: (/* @__PURE__ */ new Date()).toISOString()
44
- }, h;
71
+ }, m;
45
72
  }
46
73
  }
47
- function L() {
48
- return f().widgets;
74
+ function _() {
75
+ return u().widgets;
49
76
  }
50
- function $() {
51
- return f().components;
77
+ function O() {
78
+ return u().components;
52
79
  }
53
- function N() {
54
- return f().animates;
80
+ function X() {
81
+ return u().animates;
55
82
  }
56
- function R() {
57
- return f().hooks;
83
+ function F() {
84
+ return u().hooks;
58
85
  }
59
- function T() {
60
- return f().utils;
86
+ function N() {
87
+ return u().utils;
61
88
  }
62
- function y(s, i) {
63
- const t = f();
64
- if (i === "widget" || !i) {
65
- const e = t.widgets.find((n) => n.slug === s);
89
+ function g(s, t) {
90
+ const i = u();
91
+ if (t === "widget" || !t) {
92
+ const e = i.widgets.find((n) => n.slug === s);
66
93
  if (e) return e;
67
94
  }
68
- if (i === "component" || !i) {
69
- const e = t.components.find((n) => n.slug === s);
95
+ if (t === "component" || !t) {
96
+ const e = i.components.find((n) => n.slug === s);
70
97
  if (e) return e;
71
98
  }
72
- if (i === "animate" || !i) {
73
- const e = t.animates.find((n) => n.slug === s);
99
+ if (t === "animate" || !t) {
100
+ const e = i.animates.find((n) => n.slug === s);
74
101
  if (e) return e;
75
102
  }
76
- if (i === "hook" || !i) {
77
- const e = t.hooks.find((n) => n.slug === s);
103
+ if (t === "hook" || !t) {
104
+ const e = i.hooks.find((n) => n.slug === s);
78
105
  if (e) return e;
79
106
  }
80
- if (i === "util" || !i) {
81
- const e = t.utils.find((n) => n.slug === s);
107
+ if (t === "util" || !t) {
108
+ const e = i.utils.find((n) => n.slug === s);
82
109
  if (e) return e;
83
110
  }
84
111
  }
85
- function M(s) {
86
- const i = f(), t = [
87
- ...i.widgets,
88
- ...i.components,
89
- ...i.animates,
90
- ...i.hooks,
91
- ...i.utils
112
+ function J(s) {
113
+ const t = u(), i = [
114
+ ...t.widgets,
115
+ ...t.components,
116
+ ...t.animates,
117
+ ...t.hooks,
118
+ ...t.utils
92
119
  ], e = s.toLowerCase();
93
- return t.filter(
120
+ return i.filter(
94
121
  (n) => n.name.toLowerCase().includes(e) || n.slug.toLowerCase().includes(e)
95
122
  );
96
123
  }
124
+ function h() {
125
+ return _();
126
+ }
127
+ function y() {
128
+ return O();
129
+ }
97
130
  function b() {
98
- return L();
131
+ return X();
99
132
  }
100
133
  function k() {
101
- return $();
134
+ return F();
102
135
  }
103
- function v() {
136
+ function w() {
104
137
  return N();
105
138
  }
106
- function S() {
107
- return R();
108
- }
109
- function C() {
110
- return T();
139
+ function $(s) {
140
+ return J(s);
111
141
  }
112
- function A(s) {
113
- return M(s);
142
+ function M(s, t) {
143
+ return g(s, t) || null;
114
144
  }
115
- function G(s, i) {
116
- return y(s, i) || null;
117
- }
118
- function V(s, i) {
119
- const t = y(s, i);
120
- if (!t)
121
- return { found: !1 };
122
- let e, n;
123
- if (t.sourcePath && typeof t.sourcePath == "string") {
124
- const o = t.sourcePath, r = o.match(
125
- /(?:export\s+)?(?:interface|type)\s+(\w+Props?)\s*[=:]\s*\{[\s\S]*?\}/g
126
- );
127
- r && r.length > 0 ? e = r[0] : o.trim().startsWith("export") ? n = "Source code contains only export statements. Props definition may be in component file." : (e = o.substring(0, 1e3), n = "Full source code provided. Props interface may be defined in the component file.");
128
- } else
129
- n = "Source code not available in registry.";
130
- return {
131
- found: !0,
132
- component: t,
133
- props: e,
134
- note: n
135
- };
136
- }
137
- function J(s, i, t) {
138
- var o, r;
139
- const e = y(s, i);
145
+ function q(s, t, i) {
146
+ var o;
147
+ const e = g(s, t);
140
148
  if (!e)
141
149
  return { found: !1 };
142
150
  const n = [];
143
- if (e.variants && e.variants.forEach((a) => {
144
- n.push({ name: a.name, type: "variant" });
145
- }), e.examples && e.examples.forEach((a) => {
146
- n.push({ name: a.name, type: "example" });
147
- }), t) {
148
- const a = (o = e.variants) == null ? void 0 : o.find((d) => d.name === t);
149
- if (a && a.code)
150
- return {
151
- found: !0,
152
- component: e,
153
- example: {
154
- name: a.name,
155
- code: a.code,
156
- preview: a.preview
157
- },
158
- availableExamples: n
159
- };
160
- const l = (r = e.examples) == null ? void 0 : r.find((d) => d.name === t);
161
- return l && l.code ? {
151
+ if (e.demos && e.demos.forEach((r) => {
152
+ n.push({ name: r.name });
153
+ }), i) {
154
+ const r = (o = e.demos) == null ? void 0 : o.find((a) => a.name === i);
155
+ return r && r.code ? {
162
156
  found: !0,
163
157
  component: e,
164
158
  example: {
165
- name: l.name,
166
- code: l.code,
167
- preview: l.preview
159
+ name: r.name,
160
+ code: r.code
168
161
  },
169
- availableExamples: n
162
+ availableDemos: n
170
163
  } : {
171
164
  found: !0,
172
165
  component: e,
173
- availableExamples: n
166
+ availableDemos: n
174
167
  };
175
168
  }
176
- if (e.variants && e.variants.length > 0) {
177
- const a = e.variants[0];
178
- if (a.code)
169
+ if (e.demos && e.demos.length > 0) {
170
+ const r = e.demos[0];
171
+ if (r.code)
179
172
  return {
180
173
  found: !0,
181
174
  component: e,
182
175
  example: {
183
- name: a.name,
184
- code: a.code,
185
- preview: a.preview
176
+ name: r.name,
177
+ code: r.code
186
178
  },
187
- availableExamples: n
188
- };
189
- }
190
- if (e.examples && e.examples.length > 0) {
191
- const a = e.examples[0];
192
- if (a.code)
193
- return {
194
- found: !0,
195
- component: e,
196
- example: {
197
- name: a.name,
198
- code: a.code,
199
- preview: a.preview
200
- },
201
- availableExamples: n
179
+ availableDemos: n
202
180
  };
203
181
  }
204
182
  return {
205
183
  found: !0,
206
184
  component: e,
207
- availableExamples: n
185
+ availableDemos: n
208
186
  };
209
187
  }
210
- function j(s, i, t = "pnpm") {
211
- const e = y(s, i);
188
+ function A(s, t, i = "pnpm") {
189
+ const e = g(s, t);
212
190
  if (!e)
213
191
  return { found: !1 };
214
192
  let n;
@@ -232,7 +210,7 @@ function j(s, i, t = "pnpm") {
232
210
  return { found: !1 };
233
211
  }
234
212
  let o;
235
- switch (t) {
213
+ switch (i) {
236
214
  case "npm":
237
215
  o = `npm install ${n}`;
238
216
  break;
@@ -252,143 +230,24 @@ function j(s, i, t = "pnpm") {
252
230
  category: e.category
253
231
  };
254
232
  }
255
- function q(s, i, t, e) {
256
- var d;
257
- const n = y(s, i);
258
- if (!n)
259
- return { found: !1 };
260
- const o = J(s, i);
261
- let r;
262
- if ((d = o.example) != null && d.code) {
263
- if (r = o.example.code, t && Object.keys(t).length > 0)
264
- for (const [m, c] of Object.entries(t)) {
265
- const u = new RegExp(`${m}=\\{[^}]*\\}`, "g");
266
- typeof c == "string" ? r = r.replace(u, `${m}="${c}"`) : r = r.replace(u, `${m}={${JSON.stringify(c)}}`);
267
- }
268
- } else {
269
- const m = B(n), c = D(n);
270
- r = `import { ${c} } from "${m}";
271
-
272
- export const MyComponent = () => {
273
- return (
274
- <${c}${t ? z(t) : ""}>
275
- {/* Your content here */}
276
- </${c}>
277
- );
278
- };`;
279
- }
280
- const a = j(s, i, "pnpm"), l = a.found ? a.command : void 0;
281
- return {
233
+ function D(s, t) {
234
+ const i = g(s, t);
235
+ return i ? i.sourceCode && typeof i.sourceCode == "string" ? {
282
236
  found: !0,
283
- component: n,
284
- code: r,
285
- installation: l,
286
- note: e ? `Generated for use case: ${e}` : void 0
287
- };
288
- }
289
- function F(s) {
290
- const i = [
291
- ...L(),
292
- ...$(),
293
- ...R(),
294
- ...T(),
295
- ...N()
296
- ], t = [], e = s.toLowerCase(), n = e.split(/\s+/).filter((o) => o.length >= 3);
297
- for (const o of i) {
298
- let r = 0;
299
- const a = [];
300
- o.name.toLowerCase().includes(e) && (r += 10, a.push("name matches")), o.slug.toLowerCase().includes(e) && (r += 8, a.push("slug matches"));
301
- for (const l of n)
302
- l.length < 3 || (o.name.toLowerCase().includes(l) && (r += 3, a.push(`name contains "${l}"`)), o.slug.toLowerCase().includes(l) && (r += 2, a.push(`slug contains "${l}"`)));
303
- (e.includes("button") || e.includes("click")) && (o.slug === "button" || o.slug === "button-group") && (r += 15, a.push("perfect match for button use case")), (e.includes("form") || e.includes("input")) && o.category === "widget" && (o.slug.includes("input") || o.slug.includes("form") || o.slug.includes("field")) && (r += 12, a.push("form-related component")), (e.includes("dialog") || e.includes("modal")) && (o.slug.includes("dialog") || o.slug.includes("modal")) && (r += 15, a.push("perfect match for dialog/modal")), (e.includes("menu") || e.includes("dropdown")) && (o.slug.includes("menu") || o.slug.includes("dropdown")) && (r += 12, a.push("menu-related component")), (e.includes("hook") || e.includes("react hook")) && o.category === "hook" && (r += 10, a.push("React hook")), r > 0 && t.push({
304
- component: o,
305
- relevance: r,
306
- reason: a.join(", ")
307
- });
308
- }
309
- return t.sort((o, r) => r.relevance - o.relevance), { suggestions: t.slice(0, 5) };
310
- }
311
- function W(s) {
312
- const i = [], t = [], e = [];
313
- for (const c of s) {
314
- const u = y(c);
315
- i.push({
316
- slug: c,
317
- found: !!u,
318
- component: u || void 0
319
- });
320
- }
321
- const n = i.filter((c) => !c.found);
322
- n.length > 0 && e.push(
323
- `Some components not found: ${n.map((c) => c.slug).join(", ")}`
324
- );
325
- const o = i.filter((c) => c.found && c.component), r = o.some(
326
- (c) => {
327
- var u, g;
328
- return ((u = c.component) == null ? void 0 : u.slug.includes("dialog")) || ((g = c.component) == null ? void 0 : g.slug.includes("modal"));
329
- }
330
- ), a = o.some((c) => {
331
- var u;
332
- return ((u = c.component) == null ? void 0 : u.slug) === "button";
333
- }), l = o.some(
334
- (c) => {
335
- var u, g, O;
336
- return ((u = c.component) == null ? void 0 : u.slug.includes("input")) || ((g = c.component) == null ? void 0 : g.slug.includes("form")) || ((O = c.component) == null ? void 0 : O.slug.includes("field"));
337
- }
338
- );
339
- r && !a && t.push(
340
- "Consider adding a Button component to trigger the dialog/modal"
341
- ), l && !a && t.push("Consider adding a Button component for form submission"), o.filter(
342
- (c) => {
343
- var u, g;
344
- return ((u = c.component) == null ? void 0 : u.slug.includes("dialog")) || ((g = c.component) == null ? void 0 : g.slug.includes("modal"));
345
- }
346
- ).length > 1 && e.push("Multiple dialog/modal components detected. Consider using one at a time.");
347
- const m = new Set(
348
- o.map((c) => {
349
- var u;
350
- return (u = c.component) == null ? void 0 : u.category;
351
- }).filter(Boolean)
352
- );
353
- return m.size > 1 && t.push(
354
- `Components span multiple categories: ${Array.from(m).join(", ")}`
355
- ), {
356
- compatible: e.length === 0,
357
- components: i,
358
- notes: t,
359
- warnings: e
360
- };
361
- }
362
- function B(s) {
363
- switch (s.category) {
364
- case "widget":
365
- return `@rlx-widgets/${s.slug}`;
366
- case "component":
367
- return `@rlx-components/${s.slug}`;
368
- case "hook":
369
- return `@rlx-hooks/${s.slug}`;
370
- case "util":
371
- return `@rlx-utils/${s.slug}`;
372
- case "animate":
373
- return `@rlx-animates/${s.slug}`;
374
- default:
375
- return "";
376
- }
377
- }
378
- function D(s) {
379
- return s.name.split(" ")[0];
380
- }
381
- function z(s) {
382
- const i = [];
383
- for (const [t, e] of Object.entries(s))
384
- typeof e == "string" ? i.push(`${t}="${e}"`) : typeof e == "boolean" ? i.push(e ? t : `${t}={false}`) : i.push(`${t}={${JSON.stringify(e)}}`);
385
- return i.length > 0 ? ` ${i.join(" ")}` : "";
237
+ component: i,
238
+ sourceCode: i.sourceCode,
239
+ sourceFiles: i.sourceFiles || {}
240
+ } : {
241
+ found: !0,
242
+ component: i,
243
+ sourceFiles: i.sourceFiles || {}
244
+ } : { found: !1 };
386
245
  }
387
- async function H() {
388
- const s = new I(
246
+ async function E() {
247
+ const s = await G(), t = new L(
389
248
  {
390
249
  name: "@rlx-ui/mcp",
391
- version: "0.0.2"
250
+ version: s
392
251
  },
393
252
  {
394
253
  capabilities: {
@@ -397,529 +256,223 @@ async function H() {
397
256
  }
398
257
  }
399
258
  );
400
- s.registerTool(
259
+ t.registerTool(
401
260
  "list_widgets",
402
261
  {
403
262
  description: "List all available widgets in the RLX UI library"
404
263
  },
405
264
  async () => {
406
- const t = b();
407
- return {
408
- content: [
409
- {
410
- type: "text",
411
- text: JSON.stringify(
412
- {
413
- count: t.length,
414
- widgets: t.map((e) => {
415
- var n, o;
416
- return {
417
- name: e.name,
418
- slug: e.slug,
419
- path: e.path,
420
- hasVariants: (((n = e.variants) == null ? void 0 : n.length) ?? 0) > 0,
421
- hasExamples: (((o = e.examples) == null ? void 0 : o.length) ?? 0) > 0
422
- };
423
- })
424
- },
425
- null,
426
- 2
427
- )
428
- }
429
- ]
430
- };
265
+ const e = h();
266
+ return l({
267
+ count: e.length,
268
+ widgets: e.map((n) => {
269
+ var o;
270
+ return {
271
+ name: n.name,
272
+ slug: n.slug,
273
+ demosCount: ((o = n.demos) == null ? void 0 : o.length) ?? 0
274
+ };
275
+ })
276
+ });
431
277
  }
432
- ), s.registerTool(
278
+ ), t.registerTool(
433
279
  "list_components",
434
280
  {
435
281
  description: "List all available components in the RLX UI library"
436
282
  },
437
283
  async () => {
438
- const t = k();
439
- return {
440
- content: [
441
- {
442
- type: "text",
443
- text: JSON.stringify(
444
- {
445
- count: t.length,
446
- components: t.map((e) => {
447
- var n, o;
448
- return {
449
- name: e.name,
450
- slug: e.slug,
451
- path: e.path,
452
- hasVariants: (((n = e.variants) == null ? void 0 : n.length) ?? 0) > 0,
453
- hasExamples: (((o = e.examples) == null ? void 0 : o.length) ?? 0) > 0
454
- };
455
- })
456
- },
457
- null,
458
- 2
459
- )
460
- }
461
- ]
462
- };
284
+ const e = y();
285
+ return l({
286
+ count: e.length,
287
+ components: e.map((n) => {
288
+ var o;
289
+ return {
290
+ name: n.name,
291
+ slug: n.slug,
292
+ demosCount: ((o = n.demos) == null ? void 0 : o.length) ?? 0
293
+ };
294
+ })
295
+ });
463
296
  }
464
- ), s.registerTool(
297
+ ), t.registerTool(
465
298
  "list_animates",
466
299
  {
467
300
  description: "List all available animations in the RLX UI library"
468
301
  },
469
302
  async () => {
470
- const t = v();
471
- return {
472
- content: [
473
- {
474
- type: "text",
475
- text: JSON.stringify(
476
- {
477
- count: t.length,
478
- animates: t.map((e) => {
479
- var n;
480
- return {
481
- name: e.name,
482
- slug: e.slug,
483
- path: e.path,
484
- hasVariants: (((n = e.variants) == null ? void 0 : n.length) ?? 0) > 0
485
- };
486
- })
487
- },
488
- null,
489
- 2
490
- )
491
- }
492
- ]
493
- };
303
+ const e = b();
304
+ return l({
305
+ count: e.length,
306
+ animates: e.map((n) => {
307
+ var o;
308
+ return {
309
+ name: n.name,
310
+ slug: n.slug,
311
+ demosCount: ((o = n.demos) == null ? void 0 : o.length) ?? 0
312
+ };
313
+ })
314
+ });
494
315
  }
495
- ), s.registerTool(
316
+ ), t.registerTool(
496
317
  "list_hooks",
497
318
  {
498
319
  description: "List all available React hooks in the RLX UI library"
499
320
  },
500
321
  async () => {
501
- const t = S();
502
- return {
503
- content: [
504
- {
505
- type: "text",
506
- text: JSON.stringify(
507
- {
508
- count: t.length,
509
- hooks: t.map((e) => {
510
- var n, o;
511
- return {
512
- name: e.name,
513
- slug: e.slug,
514
- path: e.path,
515
- hasVariants: (((n = e.variants) == null ? void 0 : n.length) ?? 0) > 0,
516
- hasExamples: (((o = e.examples) == null ? void 0 : o.length) ?? 0) > 0
517
- };
518
- })
519
- },
520
- null,
521
- 2
522
- )
523
- }
524
- ]
525
- };
322
+ const e = k();
323
+ return l({
324
+ count: e.length,
325
+ hooks: e.map((n) => {
326
+ var o;
327
+ return {
328
+ name: n.name,
329
+ slug: n.slug,
330
+ demosCount: ((o = n.demos) == null ? void 0 : o.length) ?? 0
331
+ };
332
+ })
333
+ });
526
334
  }
527
- ), s.registerTool(
335
+ ), t.registerTool(
528
336
  "list_utils",
529
337
  {
530
338
  description: "List all available utility functions in the RLX UI library"
531
339
  },
532
340
  async () => {
533
- const t = C();
534
- return {
535
- content: [
536
- {
537
- type: "text",
538
- text: JSON.stringify(
539
- {
540
- count: t.length,
541
- utils: t.map((e) => {
542
- var n, o;
543
- return {
544
- name: e.name,
545
- slug: e.slug,
546
- path: e.path,
547
- hasVariants: (((n = e.variants) == null ? void 0 : n.length) ?? 0) > 0,
548
- hasExamples: (((o = e.examples) == null ? void 0 : o.length) ?? 0) > 0
549
- };
550
- })
551
- },
552
- null,
553
- 2
554
- )
555
- }
556
- ]
557
- };
341
+ const e = w();
342
+ return l({
343
+ count: e.length,
344
+ utils: e.map((n) => {
345
+ var o;
346
+ return {
347
+ name: n.name,
348
+ slug: n.slug,
349
+ demosCount: ((o = n.demos) == null ? void 0 : o.length) ?? 0
350
+ };
351
+ })
352
+ });
558
353
  }
559
- ), s.registerTool(
354
+ ), t.registerTool(
560
355
  "search_component",
561
356
  {
562
357
  description: "Search for components, widgets, hooks, utils, or animates by name or slug",
563
358
  inputSchema: {
564
- query: p.string().describe("Search query to find components")
359
+ query: c.string().describe("Search query to find components")
565
360
  }
566
361
  },
567
- async (t) => {
568
- const e = A(t.query);
569
- return {
570
- content: [
571
- {
572
- type: "text",
573
- text: JSON.stringify(
574
- {
575
- query: t.query,
576
- count: e.length,
577
- results: e.map((n) => ({
578
- name: n.name,
579
- slug: n.slug,
580
- category: n.category,
581
- path: n.path
582
- }))
583
- },
584
- null,
585
- 2
586
- )
587
- }
588
- ]
589
- };
362
+ async (e) => {
363
+ const n = $(e.query);
364
+ return l({
365
+ query: e.query,
366
+ count: n.length,
367
+ results: n.map((o) => ({
368
+ name: o.name,
369
+ slug: o.slug,
370
+ category: o.category
371
+ }))
372
+ });
590
373
  }
591
- ), s.registerTool(
374
+ ), t.registerTool(
592
375
  "get_component_info",
593
376
  {
594
377
  description: "Get detailed information about a specific component, widget, hook, util, or animate",
595
378
  inputSchema: {
596
- slug: p.string().describe("The slug/name of the component (e.g., 'button', 'use-copy-to-clipboard')"),
597
- category: p.enum(["widget", "component", "hook", "util", "animate"]).optional().describe("Optional category to narrow the search")
379
+ slug: c.string().describe(
380
+ "The slug/name of the component (e.g., 'button', 'use-copy-to-clipboard')"
381
+ ),
382
+ category: c.enum(["widget", "component", "hook", "util", "animate"]).optional().describe("Optional category to narrow the search")
598
383
  }
599
384
  },
600
- async (t) => {
601
- var n, o, r, a;
602
- const e = G(t.slug, t.category);
603
- return e ? {
604
- content: [
605
- {
606
- type: "text",
607
- text: JSON.stringify(
608
- {
609
- name: e.name,
610
- slug: e.slug,
611
- category: e.category,
612
- path: e.path,
613
- hasSourceCode: !!e.sourcePath && typeof e.sourcePath == "string",
614
- variantsCount: ((n = e.variants) == null ? void 0 : n.length) ?? 0,
615
- examplesCount: ((o = e.examples) == null ? void 0 : o.length) ?? 0,
616
- variants: (r = e.variants) == null ? void 0 : r.map((l) => ({
617
- name: l.name,
618
- hasCode: !!l.code,
619
- hasPreview: !!l.preview
620
- })),
621
- examples: (a = e.examples) == null ? void 0 : a.map((l) => ({
622
- name: l.name,
623
- hasCode: !!l.code,
624
- hasPreview: !!l.preview
625
- }))
626
- },
627
- null,
628
- 2
629
- )
630
- }
631
- ]
632
- } : {
633
- content: [
634
- {
635
- type: "text",
636
- text: JSON.stringify(
637
- {
638
- error: "Component not found",
639
- slug: t.slug,
640
- category: t.category
641
- },
642
- null,
643
- 2
644
- )
645
- }
646
- ]
647
- };
385
+ async (e) => {
386
+ var o, r;
387
+ const n = M(e.slug, e.category);
388
+ return n ? l({
389
+ name: n.name,
390
+ slug: n.slug,
391
+ category: n.category,
392
+ hasSourceCode: !!n.sourceCode && typeof n.sourceCode == "string",
393
+ demosCount: ((o = n.demos) == null ? void 0 : o.length) ?? 0,
394
+ demos: (r = n.demos) == null ? void 0 : r.map((a) => ({
395
+ name: a.name,
396
+ hasCode: !!a.code
397
+ }))
398
+ }) : d(e.slug, e.category);
648
399
  }
649
- ), s.registerTool(
650
- "get_component_props",
400
+ ), t.registerTool(
401
+ "get_component_example",
651
402
  {
652
- description: "Get TypeScript props/interface definition for a component",
403
+ description: "Get code examples (demos) for a component",
653
404
  inputSchema: {
654
- slug: p.string().describe("The slug/name of the component"),
655
- category: p.enum(["widget", "component", "hook", "util", "animate"]).optional().describe("Optional category to narrow the search")
405
+ slug: c.string().describe("The slug/name of the component"),
406
+ category: c.enum(["widget", "component", "hook", "util", "animate"]).optional().describe("Optional category to narrow the search"),
407
+ exampleName: c.string().optional().describe(
408
+ "Optional specific example/variant name. If not provided, returns the first available example."
409
+ )
656
410
  }
657
411
  },
658
- async (t) => {
659
- var n, o, r;
660
- const e = V(t.slug, t.category);
661
- return e.found ? {
662
- content: [
663
- {
664
- type: "text",
665
- text: JSON.stringify(
666
- {
667
- component: {
668
- name: (n = e.component) == null ? void 0 : n.name,
669
- slug: (o = e.component) == null ? void 0 : o.slug,
670
- category: (r = e.component) == null ? void 0 : r.category
671
- },
672
- props: e.props,
673
- note: e.note
674
- },
675
- null,
676
- 2
677
- )
678
- }
679
- ]
680
- } : {
681
- content: [
682
- {
683
- type: "text",
684
- text: JSON.stringify(
685
- {
686
- error: "Component not found",
687
- slug: t.slug,
688
- category: t.category
689
- },
690
- null,
691
- 2
692
- )
693
- }
694
- ]
695
- };
412
+ async (e) => {
413
+ var o, r, a;
414
+ const n = q(
415
+ e.slug,
416
+ e.category,
417
+ e.exampleName
418
+ );
419
+ return n.found ? l({
420
+ component: {
421
+ name: (o = n.component) == null ? void 0 : o.name,
422
+ slug: (r = n.component) == null ? void 0 : r.slug,
423
+ category: (a = n.component) == null ? void 0 : a.category
424
+ },
425
+ example: n.example,
426
+ availableDemos: n.availableDemos
427
+ }) : d(e.slug, e.category);
696
428
  }
697
- ), s.registerTool(
698
- "get_component_example",
429
+ ), t.registerTool(
430
+ "get_component_source",
699
431
  {
700
- description: "Get code examples for a component (variants or examples)",
432
+ description: "Get the complete source code for a component, including main file and all related files (utils, types, etc.)",
701
433
  inputSchema: {
702
- slug: p.string().describe("The slug/name of the component"),
703
- category: p.enum(["widget", "component", "hook", "util", "animate"]).optional().describe("Optional category to narrow the search"),
704
- exampleName: p.string().optional().describe("Optional specific example/variant name. If not provided, returns the first available example.")
434
+ slug: c.string().describe("The slug/name of the component"),
435
+ category: c.enum(["widget", "component", "hook", "util", "animate"]).optional().describe("Optional category to narrow the search")
705
436
  }
706
437
  },
707
- async (t) => {
708
- var n, o, r;
709
- const e = J(t.slug, t.category, t.exampleName);
710
- return e.found ? {
711
- content: [
712
- {
713
- type: "text",
714
- text: JSON.stringify(
715
- {
716
- component: {
717
- name: (n = e.component) == null ? void 0 : n.name,
718
- slug: (o = e.component) == null ? void 0 : o.slug,
719
- category: (r = e.component) == null ? void 0 : r.category
720
- },
721
- example: e.example,
722
- availableExamples: e.availableExamples
723
- },
724
- null,
725
- 2
726
- )
727
- }
728
- ]
729
- } : {
730
- content: [
731
- {
732
- type: "text",
733
- text: JSON.stringify(
734
- {
735
- error: "Component not found",
736
- slug: t.slug,
737
- category: t.category
738
- },
739
- null,
740
- 2
741
- )
742
- }
743
- ]
744
- };
438
+ async (e) => {
439
+ var o, r, a;
440
+ const n = D(e.slug, e.category);
441
+ return n.found ? l({
442
+ component: {
443
+ name: (o = n.component) == null ? void 0 : o.name,
444
+ slug: (r = n.component) == null ? void 0 : r.slug,
445
+ category: (a = n.component) == null ? void 0 : a.category
446
+ },
447
+ sourceCode: n.sourceCode,
448
+ sourceFiles: n.sourceFiles,
449
+ note: n.sourceFiles && Object.keys(n.sourceFiles).length > 0 ? `This component has ${Object.keys(n.sourceFiles).length} related file(s). The main file is in sourceCode, and related files (utils, types, etc.) are in sourceFiles with relative paths as keys.` : "This component has no related files."
450
+ }) : d(e.slug, e.category);
745
451
  }
746
- ), s.registerTool(
452
+ ), t.registerTool(
747
453
  "get_installation_command",
748
454
  {
749
455
  description: "Get npm/pnpm/yarn installation command for a component",
750
456
  inputSchema: {
751
- slug: p.string().describe("The slug/name of the component"),
752
- category: p.enum(["widget", "component", "hook", "util", "animate"]).optional().describe("Optional category to narrow the search"),
753
- packageManager: p.enum(["npm", "pnpm", "yarn"]).optional().default("pnpm").describe("Package manager to use (default: pnpm)")
754
- }
755
- },
756
- async (t) => {
757
- const e = j(
758
- t.slug,
759
- t.category,
760
- t.packageManager || "pnpm"
761
- );
762
- return e.found ? {
763
- content: [
764
- {
765
- type: "text",
766
- text: JSON.stringify(
767
- {
768
- command: e.command,
769
- packageName: e.packageName,
770
- category: e.category,
771
- packageManager: t.packageManager || "pnpm"
772
- },
773
- null,
774
- 2
775
- )
776
- }
777
- ]
778
- } : {
779
- content: [
780
- {
781
- type: "text",
782
- text: JSON.stringify(
783
- {
784
- error: "Component not found",
785
- slug: t.slug,
786
- category: t.category
787
- },
788
- null,
789
- 2
790
- )
791
- }
792
- ]
793
- };
794
- }
795
- ), s.registerTool(
796
- "generate_component_code",
797
- {
798
- description: "Generate component usage code with optional props and use case",
799
- inputSchema: {
800
- slug: p.string().describe("The slug/name of the component"),
801
- category: p.enum(["widget", "component", "hook", "util", "animate"]).optional().describe("Optional category to narrow the search"),
802
- props: p.record(p.string(), p.unknown()).optional().describe("Optional props to customize the generated code"),
803
- useCase: p.string().optional().describe("Optional description of the use case")
457
+ slug: c.string().describe("The slug/name of the component"),
458
+ category: c.enum(["widget", "component", "hook", "util", "animate"]).optional().describe("Optional category to narrow the search"),
459
+ packageManager: c.enum(["npm", "pnpm", "yarn"]).optional().default("pnpm").describe("Package manager to use (default: pnpm)")
804
460
  }
805
461
  },
806
- async (t) => {
807
- var n, o, r;
808
- const e = q(
809
- t.slug,
810
- t.category,
811
- t.props,
812
- t.useCase
462
+ async (e) => {
463
+ const n = A(
464
+ e.slug,
465
+ e.category,
466
+ e.packageManager || "pnpm"
813
467
  );
814
- return e.found ? {
815
- content: [
816
- {
817
- type: "text",
818
- text: JSON.stringify(
819
- {
820
- component: {
821
- name: (n = e.component) == null ? void 0 : n.name,
822
- slug: (o = e.component) == null ? void 0 : o.slug,
823
- category: (r = e.component) == null ? void 0 : r.category
824
- },
825
- code: e.code,
826
- installation: e.installation,
827
- note: e.note
828
- },
829
- null,
830
- 2
831
- )
832
- }
833
- ]
834
- } : {
835
- content: [
836
- {
837
- type: "text",
838
- text: JSON.stringify(
839
- {
840
- error: "Component not found",
841
- slug: t.slug,
842
- category: t.category
843
- },
844
- null,
845
- 2
846
- )
847
- }
848
- ]
849
- };
850
- }
851
- ), s.registerTool(
852
- "suggest_component",
853
- {
854
- description: "Suggest which component to use for a specific use case",
855
- inputSchema: {
856
- description: p.string().describe("Description of what you want to build or accomplish")
857
- }
858
- },
859
- async (t) => {
860
- const e = F(t.description);
861
- return {
862
- content: [
863
- {
864
- type: "text",
865
- text: JSON.stringify(
866
- {
867
- description: t.description,
868
- suggestions: e.suggestions.map((n) => ({
869
- component: {
870
- name: n.component.name,
871
- slug: n.component.slug,
872
- category: n.component.category,
873
- path: n.component.path
874
- },
875
- relevance: n.relevance,
876
- reason: n.reason
877
- }))
878
- },
879
- null,
880
- 2
881
- )
882
- }
883
- ]
884
- };
885
- }
886
- ), s.registerTool(
887
- "check_component_compatibility",
888
- {
889
- description: "Check if multiple components work well together",
890
- inputSchema: {
891
- componentSlugs: p.array(p.string()).describe("Array of component slugs to check compatibility")
892
- }
893
- },
894
- async (t) => {
895
- const e = W(t.componentSlugs);
896
- return {
897
- content: [
898
- {
899
- type: "text",
900
- text: JSON.stringify(
901
- {
902
- compatible: e.compatible,
903
- components: e.components.map((n) => ({
904
- slug: n.slug,
905
- found: n.found,
906
- component: n.component ? {
907
- name: n.component.name,
908
- slug: n.component.slug,
909
- category: n.component.category
910
- } : void 0
911
- })),
912
- notes: e.notes,
913
- warnings: e.warnings
914
- },
915
- null,
916
- 2
917
- )
918
- }
919
- ]
920
- };
468
+ return n.found ? l({
469
+ command: n.command,
470
+ packageName: n.packageName,
471
+ category: n.category,
472
+ packageManager: e.packageManager || "pnpm"
473
+ }) : d(e.slug, e.category);
921
474
  }
922
- ), s.registerResource(
475
+ ), t.registerResource(
923
476
  "RLX UI Widgets",
924
477
  "rlx-ui://widgets",
925
478
  {
@@ -927,18 +480,18 @@ async function H() {
927
480
  mimeType: "application/json"
928
481
  },
929
482
  async () => {
930
- const t = b();
483
+ const e = h();
931
484
  return {
932
485
  contents: [
933
486
  {
934
487
  uri: "rlx-ui://widgets",
935
488
  mimeType: "application/json",
936
- text: JSON.stringify(t, null, 2)
489
+ text: JSON.stringify(e, null, 2)
937
490
  }
938
491
  ]
939
492
  };
940
493
  }
941
- ), s.registerResource(
494
+ ), t.registerResource(
942
495
  "RLX UI Components",
943
496
  "rlx-ui://components",
944
497
  {
@@ -946,18 +499,18 @@ async function H() {
946
499
  mimeType: "application/json"
947
500
  },
948
501
  async () => {
949
- const t = k();
502
+ const e = y();
950
503
  return {
951
504
  contents: [
952
505
  {
953
506
  uri: "rlx-ui://components",
954
507
  mimeType: "application/json",
955
- text: JSON.stringify(t, null, 2)
508
+ text: JSON.stringify(e, null, 2)
956
509
  }
957
510
  ]
958
511
  };
959
512
  }
960
- ), s.registerResource(
513
+ ), t.registerResource(
961
514
  "RLX UI Animates",
962
515
  "rlx-ui://animates",
963
516
  {
@@ -965,18 +518,18 @@ async function H() {
965
518
  mimeType: "application/json"
966
519
  },
967
520
  async () => {
968
- const t = v();
521
+ const e = b();
969
522
  return {
970
523
  contents: [
971
524
  {
972
525
  uri: "rlx-ui://animates",
973
526
  mimeType: "application/json",
974
- text: JSON.stringify(t, null, 2)
527
+ text: JSON.stringify(e, null, 2)
975
528
  }
976
529
  ]
977
530
  };
978
531
  }
979
- ), s.registerResource(
532
+ ), t.registerResource(
980
533
  "RLX UI Hooks",
981
534
  "rlx-ui://hooks",
982
535
  {
@@ -984,18 +537,18 @@ async function H() {
984
537
  mimeType: "application/json"
985
538
  },
986
539
  async () => {
987
- const t = S();
540
+ const e = k();
988
541
  return {
989
542
  contents: [
990
543
  {
991
544
  uri: "rlx-ui://hooks",
992
545
  mimeType: "application/json",
993
- text: JSON.stringify(t, null, 2)
546
+ text: JSON.stringify(e, null, 2)
994
547
  }
995
548
  ]
996
549
  };
997
550
  }
998
- ), s.registerResource(
551
+ ), t.registerResource(
999
552
  "RLX UI Utils",
1000
553
  "rlx-ui://utils",
1001
554
  {
@@ -1003,18 +556,18 @@ async function H() {
1003
556
  mimeType: "application/json"
1004
557
  },
1005
558
  async () => {
1006
- const t = C();
559
+ const e = w();
1007
560
  return {
1008
561
  contents: [
1009
562
  {
1010
563
  uri: "rlx-ui://utils",
1011
564
  mimeType: "application/json",
1012
- text: JSON.stringify(t, null, 2)
565
+ text: JSON.stringify(e, null, 2)
1013
566
  }
1014
567
  ]
1015
568
  };
1016
569
  }
1017
- ), s.registerResource(
570
+ ), t.registerResource(
1018
571
  "RLX UI Information",
1019
572
  "rlx-ui://info",
1020
573
  {
@@ -1022,7 +575,7 @@ async function H() {
1022
575
  mimeType: "application/json"
1023
576
  },
1024
577
  async () => {
1025
- const t = b(), e = k(), n = v(), o = S(), r = C();
578
+ const e = h(), n = y(), o = b(), r = k(), a = w();
1026
579
  return {
1027
580
  contents: [
1028
581
  {
@@ -1032,15 +585,15 @@ async function H() {
1032
585
  {
1033
586
  name: "RLX UI",
1034
587
  description: "A comprehensive UI component library",
1035
- version: "0.0.2",
588
+ version: s,
1036
589
  mcpServer: "@rlx-ui/mcp",
1037
590
  stats: {
1038
- widgets: t.length,
1039
- components: e.length,
1040
- animates: n.length,
1041
- hooks: o.length,
1042
- utils: r.length,
1043
- total: t.length + e.length + n.length + o.length + r.length
591
+ widgets: e.length,
592
+ components: n.length,
593
+ animates: o.length,
594
+ hooks: r.length,
595
+ utils: a.length,
596
+ total: e.length + n.length + o.length + r.length + a.length
1044
597
  }
1045
598
  },
1046
599
  null,
@@ -1051,9 +604,20 @@ async function H() {
1051
604
  };
1052
605
  }
1053
606
  );
1054
- const i = new U();
1055
- await s.connect(i), console.error("RLX UI MCP Server running on stdio");
607
+ const i = new R();
608
+ await t.connect(i), console.error("RLX UI MCP Server running on stdio");
609
+ }
610
+ async function G() {
611
+ const s = C(import.meta.url), t = x.dirname(s), i = await I(
612
+ x.join(t, "..", "package.json")
613
+ );
614
+ if (!i)
615
+ throw new Error("Unable to find package.json");
616
+ const n = JSON.parse(i).version;
617
+ if (!n)
618
+ throw new Error("Unable to read version from package.json");
619
+ return n;
1056
620
  }
1057
- H().catch((s) => {
621
+ E().catch((s) => {
1058
622
  console.error("Fatal error in main():", s), process.exit(1);
1059
623
  });