@rlx-ui/mcp 0.0.2 → 0.0.3

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,394 +1,270 @@
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 x } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { StdioServerTransport as C } from "@modelcontextprotocol/sdk/server/stdio.js";
3
+ import { z as a } from "zod";
4
+ import { readFileSync as T } from "fs";
5
+ import { fileURLToPath as L } from "url";
6
+ import { join as m, dirname as R } from "path";
7
+ const S = L(import.meta.url), f = R(S);
8
+ let u = null;
9
+ function l() {
10
+ if (u)
11
+ return u;
12
12
  try {
13
- const s = [
14
- x(w, "data/registry.json"),
13
+ const o = [
14
+ m(f, "data/registry.json"),
15
15
  // From dist/ to dist/data/ (copied during build)
16
- x(w, "../src/data/registry.json"),
16
+ m(f, "../src/data/registry.json"),
17
17
  // From dist/ to src/data/ (development)
18
- x(w, "../data/registry.json"),
18
+ m(f, "../data/registry.json"),
19
19
  // Fallback
20
- x(process.cwd(), "src/data/registry.json"),
20
+ m(process.cwd(), "src/data/registry.json"),
21
21
  // From package root (published)
22
- x(process.cwd(), "libs/rlx-ui/mcp/src/data/registry.json")
22
+ m(process.cwd(), "libs/rlx-ui/mcp/src/data/registry.json")
23
23
  // Development
24
24
  ];
25
- let i = null;
26
- for (const t of s)
25
+ let s = null;
26
+ for (const n of o)
27
27
  try {
28
- i = _(t, "utf-8");
28
+ s = T(n, "utf-8");
29
29
  break;
30
30
  } catch {
31
31
  continue;
32
32
  }
33
- if (!i)
33
+ if (!s)
34
34
  throw new Error("Could not find registry.json in any expected location");
35
- return h = JSON.parse(i), h;
36
- } catch (s) {
37
- return console.error("Warning: Could not load component registry:", s), h = {
35
+ return u = JSON.parse(s), u;
36
+ } catch (o) {
37
+ return console.error("Warning: Could not load component registry:", o), u = {
38
38
  widgets: [],
39
39
  components: [],
40
40
  animates: [],
41
41
  hooks: [],
42
42
  utils: [],
43
43
  extractedAt: (/* @__PURE__ */ new Date()).toISOString()
44
- }, h;
44
+ }, u;
45
45
  }
46
46
  }
47
- function L() {
48
- return f().widgets;
47
+ function j() {
48
+ return l().widgets;
49
49
  }
50
- function $() {
51
- return f().components;
50
+ function I() {
51
+ return l().components;
52
52
  }
53
- function N() {
54
- return f().animates;
53
+ function U() {
54
+ return l().animates;
55
55
  }
56
- function R() {
57
- return f().hooks;
56
+ function v() {
57
+ return l().hooks;
58
58
  }
59
- function T() {
60
- return f().utils;
59
+ function _() {
60
+ return l().utils;
61
61
  }
62
- function y(s, i) {
63
- const t = f();
64
- if (i === "widget" || !i) {
65
- const e = t.widgets.find((n) => n.slug === s);
62
+ function d(o, s) {
63
+ const n = l();
64
+ if (s === "widget" || !s) {
65
+ const e = n.widgets.find((t) => t.slug === o);
66
66
  if (e) return e;
67
67
  }
68
- if (i === "component" || !i) {
69
- const e = t.components.find((n) => n.slug === s);
68
+ if (s === "component" || !s) {
69
+ const e = n.components.find((t) => t.slug === o);
70
70
  if (e) return e;
71
71
  }
72
- if (i === "animate" || !i) {
73
- const e = t.animates.find((n) => n.slug === s);
72
+ if (s === "animate" || !s) {
73
+ const e = n.animates.find((t) => t.slug === o);
74
74
  if (e) return e;
75
75
  }
76
- if (i === "hook" || !i) {
77
- const e = t.hooks.find((n) => n.slug === s);
76
+ if (s === "hook" || !s) {
77
+ const e = n.hooks.find((t) => t.slug === o);
78
78
  if (e) return e;
79
79
  }
80
- if (i === "util" || !i) {
81
- const e = t.utils.find((n) => n.slug === s);
80
+ if (s === "util" || !s) {
81
+ const e = n.utils.find((t) => t.slug === o);
82
82
  if (e) return e;
83
83
  }
84
84
  }
85
- function M(s) {
86
- const i = f(), t = [
87
- ...i.widgets,
88
- ...i.components,
89
- ...i.animates,
90
- ...i.hooks,
91
- ...i.utils
92
- ], e = s.toLowerCase();
93
- return t.filter(
94
- (n) => n.name.toLowerCase().includes(e) || n.slug.toLowerCase().includes(e)
85
+ function O(o) {
86
+ const s = l(), n = [
87
+ ...s.widgets,
88
+ ...s.components,
89
+ ...s.animates,
90
+ ...s.hooks,
91
+ ...s.utils
92
+ ], e = o.toLowerCase();
93
+ return n.filter(
94
+ (t) => t.name.toLowerCase().includes(e) || t.slug.toLowerCase().includes(e)
95
95
  );
96
96
  }
97
- function b() {
98
- return L();
97
+ function h() {
98
+ return j();
99
99
  }
100
- function k() {
101
- return $();
100
+ function y() {
101
+ return I();
102
102
  }
103
- function v() {
104
- return N();
103
+ function b() {
104
+ return U();
105
105
  }
106
- function S() {
107
- return R();
106
+ function k() {
107
+ return v();
108
108
  }
109
- function C() {
110
- return T();
109
+ function w() {
110
+ return _();
111
111
  }
112
- function A(s) {
113
- return M(s);
112
+ function X(o) {
113
+ return O(o);
114
114
  }
115
- function G(s, i) {
116
- return y(s, i) || null;
115
+ function F(o, s) {
116
+ return d(o, s) || null;
117
117
  }
118
- function V(s, i) {
119
- const t = y(s, i);
120
- if (!t)
118
+ function N(o, s) {
119
+ const n = d(o, s);
120
+ if (!n)
121
121
  return { found: !1 };
122
- let e, n;
123
- if (t.sourcePath && typeof t.sourcePath == "string") {
124
- const o = t.sourcePath, r = o.match(
122
+ let e, t;
123
+ if (n.sourceCode && typeof n.sourceCode == "string") {
124
+ const r = n.sourceCode;
125
+ if (n.sourceFiles && Object.keys(n.sourceFiles).length > 0) {
126
+ const g = Object.keys(n.sourceFiles).join(", ");
127
+ t = `This component has ${Object.keys(n.sourceFiles).length} related file(s): ${g}. Use get_component_source to get the complete codebase.`;
128
+ }
129
+ const i = r.match(
125
130
  /(?:export\s+)?(?:interface|type)\s+(\w+Props?)\s*[=:]\s*\{[\s\S]*?\}/g
126
131
  );
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.");
132
+ i && i.length > 0 ? e = i[0] : r.trim().startsWith("export") ? t = "Source code contains only export statements. Props definition may be in component file." : (e = r.substring(0, 1e3), t = "Full source code provided. Props interface may be defined in the component file.");
128
133
  } else
129
- n = "Source code not available in registry.";
134
+ t = "Source code not available in registry.";
130
135
  return {
131
136
  found: !0,
132
- component: t,
137
+ component: n,
133
138
  props: e,
134
- note: n
139
+ note: t
135
140
  };
136
141
  }
137
- function J(s, i, t) {
138
- var o, r;
139
- const e = y(s, i);
142
+ function $(o, s, n) {
143
+ var r;
144
+ const e = d(o, s);
140
145
  if (!e)
141
146
  return { found: !1 };
142
- 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 ? {
147
+ const t = [];
148
+ if (e.demos && e.demos.forEach((i) => {
149
+ t.push({ name: i.name });
150
+ }), n) {
151
+ const i = (r = e.demos) == null ? void 0 : r.find((g) => g.name === n);
152
+ return i && i.code ? {
162
153
  found: !0,
163
154
  component: e,
164
155
  example: {
165
- name: l.name,
166
- code: l.code,
167
- preview: l.preview
156
+ name: i.name,
157
+ code: i.code
168
158
  },
169
- availableExamples: n
159
+ availableDemos: t
170
160
  } : {
171
161
  found: !0,
172
162
  component: e,
173
- availableExamples: n
163
+ availableDemos: t
174
164
  };
175
165
  }
176
- if (e.variants && e.variants.length > 0) {
177
- const a = e.variants[0];
178
- if (a.code)
179
- return {
180
- found: !0,
181
- component: e,
182
- example: {
183
- name: a.name,
184
- code: a.code,
185
- preview: a.preview
186
- },
187
- availableExamples: n
188
- };
189
- }
190
- if (e.examples && e.examples.length > 0) {
191
- const a = e.examples[0];
192
- if (a.code)
166
+ if (e.demos && e.demos.length > 0) {
167
+ const i = e.demos[0];
168
+ if (i.code)
193
169
  return {
194
170
  found: !0,
195
171
  component: e,
196
172
  example: {
197
- name: a.name,
198
- code: a.code,
199
- preview: a.preview
173
+ name: i.name,
174
+ code: i.code
200
175
  },
201
- availableExamples: n
176
+ availableDemos: t
202
177
  };
203
178
  }
204
179
  return {
205
180
  found: !0,
206
181
  component: e,
207
- availableExamples: n
182
+ availableDemos: t
208
183
  };
209
184
  }
210
- function j(s, i, t = "pnpm") {
211
- const e = y(s, i);
185
+ function P(o, s, n = "pnpm") {
186
+ const e = d(o, s);
212
187
  if (!e)
213
188
  return { found: !1 };
214
- let n;
189
+ let t;
215
190
  switch (e.category) {
216
191
  case "widget":
217
- n = `@rlx-widgets/${e.slug}`;
192
+ t = `@rlx-widgets/${e.slug}`;
218
193
  break;
219
194
  case "component":
220
- n = `@rlx-components/${e.slug}`;
195
+ t = `@rlx-components/${e.slug}`;
221
196
  break;
222
197
  case "hook":
223
- n = `@rlx-hooks/${e.slug}`;
198
+ t = `@rlx-hooks/${e.slug}`;
224
199
  break;
225
200
  case "util":
226
- n = `@rlx-utils/${e.slug}`;
201
+ t = `@rlx-utils/${e.slug}`;
227
202
  break;
228
203
  case "animate":
229
- n = `@rlx-animates/${e.slug}`;
204
+ t = `@rlx-animates/${e.slug}`;
230
205
  break;
231
206
  default:
232
207
  return { found: !1 };
233
208
  }
234
- let o;
235
- switch (t) {
209
+ let r;
210
+ switch (n) {
236
211
  case "npm":
237
- o = `npm install ${n}`;
212
+ r = `npm install ${t}`;
238
213
  break;
239
214
  case "pnpm":
240
- o = `pnpm add ${n}`;
215
+ r = `pnpm add ${t}`;
241
216
  break;
242
217
  case "yarn":
243
- o = `yarn add ${n}`;
218
+ r = `yarn add ${t}`;
244
219
  break;
245
220
  default:
246
- o = `pnpm add ${n}`;
221
+ r = `pnpm add ${t}`;
247
222
  }
248
223
  return {
249
224
  found: !0,
250
- command: o,
251
- packageName: n,
225
+ command: r,
226
+ packageName: t,
252
227
  category: e.category
253
228
  };
254
229
  }
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 {
230
+ function J(o, s) {
231
+ const n = d(o, s);
232
+ return n ? n.sourceCode && typeof n.sourceCode == "string" ? {
282
233
  found: !0,
283
234
  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) };
235
+ sourceCode: n.sourceCode,
236
+ sourceFiles: n.sourceFiles || {}
237
+ } : {
238
+ found: !0,
239
+ component: n,
240
+ sourceFiles: n.sourceFiles || {}
241
+ } : { found: !1 };
310
242
  }
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
243
+ function c(o) {
244
+ return {
245
+ content: [
246
+ {
247
+ type: "text",
248
+ text: JSON.stringify(o, null, 2)
249
+ }
250
+ ]
360
251
  };
361
252
  }
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];
253
+ function M(o, s, n) {
254
+ return c({
255
+ error: o,
256
+ ...s && { slug: s },
257
+ ...n && { category: n }
258
+ });
380
259
  }
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(" ")}` : "";
260
+ function p(o, s) {
261
+ return M("Component not found", o, s);
386
262
  }
387
- async function H() {
388
- const s = new I(
263
+ async function G() {
264
+ const o = new x(
389
265
  {
390
266
  name: "@rlx-ui/mcp",
391
- version: "0.0.2"
267
+ version: "0.0.3"
392
268
  },
393
269
  {
394
270
  capabilities: {
@@ -397,529 +273,237 @@ async function H() {
397
273
  }
398
274
  }
399
275
  );
400
- s.registerTool(
276
+ o.registerTool(
401
277
  "list_widgets",
402
278
  {
403
279
  description: "List all available widgets in the RLX UI library"
404
280
  },
405
281
  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
- };
282
+ const n = h();
283
+ return c({
284
+ count: n.length,
285
+ widgets: n.map((e) => {
286
+ var t;
287
+ return {
288
+ name: e.name,
289
+ slug: e.slug,
290
+ demosCount: ((t = e.demos) == null ? void 0 : t.length) ?? 0
291
+ };
292
+ })
293
+ });
431
294
  }
432
- ), s.registerTool(
295
+ ), o.registerTool(
433
296
  "list_components",
434
297
  {
435
298
  description: "List all available components in the RLX UI library"
436
299
  },
437
300
  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
- };
301
+ const n = y();
302
+ return c({
303
+ count: n.length,
304
+ components: n.map((e) => {
305
+ var t;
306
+ return {
307
+ name: e.name,
308
+ slug: e.slug,
309
+ demosCount: ((t = e.demos) == null ? void 0 : t.length) ?? 0
310
+ };
311
+ })
312
+ });
463
313
  }
464
- ), s.registerTool(
314
+ ), o.registerTool(
465
315
  "list_animates",
466
316
  {
467
317
  description: "List all available animations in the RLX UI library"
468
318
  },
469
319
  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
- };
320
+ const n = b();
321
+ return c({
322
+ count: n.length,
323
+ animates: n.map((e) => {
324
+ var t;
325
+ return {
326
+ name: e.name,
327
+ slug: e.slug,
328
+ demosCount: ((t = e.demos) == null ? void 0 : t.length) ?? 0
329
+ };
330
+ })
331
+ });
494
332
  }
495
- ), s.registerTool(
333
+ ), o.registerTool(
496
334
  "list_hooks",
497
335
  {
498
336
  description: "List all available React hooks in the RLX UI library"
499
337
  },
500
338
  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
- };
339
+ const n = k();
340
+ return c({
341
+ count: n.length,
342
+ hooks: n.map((e) => {
343
+ var t;
344
+ return {
345
+ name: e.name,
346
+ slug: e.slug,
347
+ demosCount: ((t = e.demos) == null ? void 0 : t.length) ?? 0
348
+ };
349
+ })
350
+ });
526
351
  }
527
- ), s.registerTool(
352
+ ), o.registerTool(
528
353
  "list_utils",
529
354
  {
530
355
  description: "List all available utility functions in the RLX UI library"
531
356
  },
532
357
  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
- };
358
+ const n = w();
359
+ return c({
360
+ count: n.length,
361
+ utils: n.map((e) => {
362
+ var t;
363
+ return {
364
+ name: e.name,
365
+ slug: e.slug,
366
+ demosCount: ((t = e.demos) == null ? void 0 : t.length) ?? 0
367
+ };
368
+ })
369
+ });
558
370
  }
559
- ), s.registerTool(
371
+ ), o.registerTool(
560
372
  "search_component",
561
373
  {
562
374
  description: "Search for components, widgets, hooks, utils, or animates by name or slug",
563
375
  inputSchema: {
564
- query: p.string().describe("Search query to find components")
376
+ query: a.string().describe("Search query to find components")
565
377
  }
566
378
  },
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
- };
379
+ async (n) => {
380
+ const e = X(n.query);
381
+ return c({
382
+ query: n.query,
383
+ count: e.length,
384
+ results: e.map((t) => ({
385
+ name: t.name,
386
+ slug: t.slug,
387
+ category: t.category
388
+ }))
389
+ });
590
390
  }
591
- ), s.registerTool(
391
+ ), o.registerTool(
592
392
  "get_component_info",
593
393
  {
594
394
  description: "Get detailed information about a specific component, widget, hook, util, or animate",
595
395
  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")
396
+ slug: a.string().describe("The slug/name of the component (e.g., 'button', 'use-copy-to-clipboard')"),
397
+ category: a.enum(["widget", "component", "hook", "util", "animate"]).optional().describe("Optional category to narrow the search")
598
398
  }
599
399
  },
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
- };
400
+ async (n) => {
401
+ var t, r;
402
+ const e = F(n.slug, n.category);
403
+ return e ? c({
404
+ name: e.name,
405
+ slug: e.slug,
406
+ category: e.category,
407
+ hasSourceCode: !!e.sourceCode && typeof e.sourceCode == "string",
408
+ demosCount: ((t = e.demos) == null ? void 0 : t.length) ?? 0,
409
+ demos: (r = e.demos) == null ? void 0 : r.map((i) => ({
410
+ name: i.name,
411
+ hasCode: !!i.code
412
+ }))
413
+ }) : p(n.slug, n.category);
648
414
  }
649
- ), s.registerTool(
415
+ ), o.registerTool(
650
416
  "get_component_props",
651
417
  {
652
418
  description: "Get TypeScript props/interface definition for a component",
653
419
  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")
420
+ slug: a.string().describe("The slug/name of the component"),
421
+ category: a.enum(["widget", "component", "hook", "util", "animate"]).optional().describe("Optional category to narrow the search")
656
422
  }
657
423
  },
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
- };
424
+ async (n) => {
425
+ var t, r, i;
426
+ const e = N(n.slug, n.category);
427
+ return e.found ? c({
428
+ component: {
429
+ name: (t = e.component) == null ? void 0 : t.name,
430
+ slug: (r = e.component) == null ? void 0 : r.slug,
431
+ category: (i = e.component) == null ? void 0 : i.category
432
+ },
433
+ props: e.props,
434
+ note: e.note
435
+ }) : p(n.slug, n.category);
696
436
  }
697
- ), s.registerTool(
437
+ ), o.registerTool(
698
438
  "get_component_example",
699
439
  {
700
- description: "Get code examples for a component (variants or examples)",
440
+ description: "Get code examples (demos) for a component",
701
441
  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.")
442
+ slug: a.string().describe("The slug/name of the component"),
443
+ category: a.enum(["widget", "component", "hook", "util", "animate"]).optional().describe("Optional category to narrow the search"),
444
+ exampleName: a.string().optional().describe("Optional specific example/variant name. If not provided, returns the first available example.")
705
445
  }
706
446
  },
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
- };
447
+ async (n) => {
448
+ var t, r, i;
449
+ const e = $(n.slug, n.category, n.exampleName);
450
+ return e.found ? c({
451
+ component: {
452
+ name: (t = e.component) == null ? void 0 : t.name,
453
+ slug: (r = e.component) == null ? void 0 : r.slug,
454
+ category: (i = e.component) == null ? void 0 : i.category
455
+ },
456
+ example: e.example,
457
+ availableDemos: e.availableDemos
458
+ }) : p(n.slug, n.category);
745
459
  }
746
- ), s.registerTool(
747
- "get_installation_command",
460
+ ), o.registerTool(
461
+ "get_component_source",
748
462
  {
749
- description: "Get npm/pnpm/yarn installation command for a component",
463
+ description: "Get the complete source code for a component, including main file and all related files (utils, types, etc.)",
750
464
  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)")
465
+ slug: a.string().describe("The slug/name of the component"),
466
+ category: a.enum(["widget", "component", "hook", "util", "animate"]).optional().describe("Optional category to narrow the search")
754
467
  }
755
468
  },
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
- };
469
+ async (n) => {
470
+ var t, r, i;
471
+ const e = J(n.slug, n.category);
472
+ return e.found ? c({
473
+ component: {
474
+ name: (t = e.component) == null ? void 0 : t.name,
475
+ slug: (r = e.component) == null ? void 0 : r.slug,
476
+ category: (i = e.component) == null ? void 0 : i.category
477
+ },
478
+ sourceCode: e.sourceCode,
479
+ sourceFiles: e.sourceFiles,
480
+ note: e.sourceFiles && Object.keys(e.sourceFiles).length > 0 ? `This component has ${Object.keys(e.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."
481
+ }) : p(n.slug, n.category);
794
482
  }
795
- ), s.registerTool(
796
- "generate_component_code",
483
+ ), o.registerTool(
484
+ "get_installation_command",
797
485
  {
798
- description: "Generate component usage code with optional props and use case",
486
+ description: "Get npm/pnpm/yarn installation command for a component",
799
487
  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")
488
+ slug: a.string().describe("The slug/name of the component"),
489
+ category: a.enum(["widget", "component", "hook", "util", "animate"]).optional().describe("Optional category to narrow the search"),
490
+ packageManager: a.enum(["npm", "pnpm", "yarn"]).optional().default("pnpm").describe("Package manager to use (default: pnpm)")
804
491
  }
805
492
  },
806
- async (t) => {
807
- var n, o, r;
808
- const e = q(
809
- t.slug,
810
- t.category,
811
- t.props,
812
- t.useCase
493
+ async (n) => {
494
+ const e = P(
495
+ n.slug,
496
+ n.category,
497
+ n.packageManager || "pnpm"
813
498
  );
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
- };
499
+ return e.found ? c({
500
+ command: e.command,
501
+ packageName: e.packageName,
502
+ category: e.category,
503
+ packageManager: n.packageManager || "pnpm"
504
+ }) : p(n.slug, n.category);
921
505
  }
922
- ), s.registerResource(
506
+ ), o.registerResource(
923
507
  "RLX UI Widgets",
924
508
  "rlx-ui://widgets",
925
509
  {
@@ -927,18 +511,18 @@ async function H() {
927
511
  mimeType: "application/json"
928
512
  },
929
513
  async () => {
930
- const t = b();
514
+ const n = h();
931
515
  return {
932
516
  contents: [
933
517
  {
934
518
  uri: "rlx-ui://widgets",
935
519
  mimeType: "application/json",
936
- text: JSON.stringify(t, null, 2)
520
+ text: JSON.stringify(n, null, 2)
937
521
  }
938
522
  ]
939
523
  };
940
524
  }
941
- ), s.registerResource(
525
+ ), o.registerResource(
942
526
  "RLX UI Components",
943
527
  "rlx-ui://components",
944
528
  {
@@ -946,18 +530,18 @@ async function H() {
946
530
  mimeType: "application/json"
947
531
  },
948
532
  async () => {
949
- const t = k();
533
+ const n = y();
950
534
  return {
951
535
  contents: [
952
536
  {
953
537
  uri: "rlx-ui://components",
954
538
  mimeType: "application/json",
955
- text: JSON.stringify(t, null, 2)
539
+ text: JSON.stringify(n, null, 2)
956
540
  }
957
541
  ]
958
542
  };
959
543
  }
960
- ), s.registerResource(
544
+ ), o.registerResource(
961
545
  "RLX UI Animates",
962
546
  "rlx-ui://animates",
963
547
  {
@@ -965,18 +549,18 @@ async function H() {
965
549
  mimeType: "application/json"
966
550
  },
967
551
  async () => {
968
- const t = v();
552
+ const n = b();
969
553
  return {
970
554
  contents: [
971
555
  {
972
556
  uri: "rlx-ui://animates",
973
557
  mimeType: "application/json",
974
- text: JSON.stringify(t, null, 2)
558
+ text: JSON.stringify(n, null, 2)
975
559
  }
976
560
  ]
977
561
  };
978
562
  }
979
- ), s.registerResource(
563
+ ), o.registerResource(
980
564
  "RLX UI Hooks",
981
565
  "rlx-ui://hooks",
982
566
  {
@@ -984,18 +568,18 @@ async function H() {
984
568
  mimeType: "application/json"
985
569
  },
986
570
  async () => {
987
- const t = S();
571
+ const n = k();
988
572
  return {
989
573
  contents: [
990
574
  {
991
575
  uri: "rlx-ui://hooks",
992
576
  mimeType: "application/json",
993
- text: JSON.stringify(t, null, 2)
577
+ text: JSON.stringify(n, null, 2)
994
578
  }
995
579
  ]
996
580
  };
997
581
  }
998
- ), s.registerResource(
582
+ ), o.registerResource(
999
583
  "RLX UI Utils",
1000
584
  "rlx-ui://utils",
1001
585
  {
@@ -1003,18 +587,18 @@ async function H() {
1003
587
  mimeType: "application/json"
1004
588
  },
1005
589
  async () => {
1006
- const t = C();
590
+ const n = w();
1007
591
  return {
1008
592
  contents: [
1009
593
  {
1010
594
  uri: "rlx-ui://utils",
1011
595
  mimeType: "application/json",
1012
- text: JSON.stringify(t, null, 2)
596
+ text: JSON.stringify(n, null, 2)
1013
597
  }
1014
598
  ]
1015
599
  };
1016
600
  }
1017
- ), s.registerResource(
601
+ ), o.registerResource(
1018
602
  "RLX UI Information",
1019
603
  "rlx-ui://info",
1020
604
  {
@@ -1022,7 +606,7 @@ async function H() {
1022
606
  mimeType: "application/json"
1023
607
  },
1024
608
  async () => {
1025
- const t = b(), e = k(), n = v(), o = S(), r = C();
609
+ const n = h(), e = y(), t = b(), r = k(), i = w();
1026
610
  return {
1027
611
  contents: [
1028
612
  {
@@ -1032,15 +616,15 @@ async function H() {
1032
616
  {
1033
617
  name: "RLX UI",
1034
618
  description: "A comprehensive UI component library",
1035
- version: "0.0.2",
619
+ version: "0.0.3",
1036
620
  mcpServer: "@rlx-ui/mcp",
1037
621
  stats: {
1038
- widgets: t.length,
622
+ widgets: n.length,
1039
623
  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
624
+ animates: t.length,
625
+ hooks: r.length,
626
+ utils: i.length,
627
+ total: n.length + e.length + t.length + r.length + i.length
1044
628
  }
1045
629
  },
1046
630
  null,
@@ -1051,9 +635,9 @@ async function H() {
1051
635
  };
1052
636
  }
1053
637
  );
1054
- const i = new U();
1055
- await s.connect(i), console.error("RLX UI MCP Server running on stdio");
638
+ const s = new C();
639
+ await o.connect(s), console.error("RLX UI MCP Server running on stdio");
1056
640
  }
1057
- H().catch((s) => {
1058
- console.error("Fatal error in main():", s), process.exit(1);
641
+ G().catch((o) => {
642
+ console.error("Fatal error in main():", o), process.exit(1);
1059
643
  });