@rlx-ui/mcp 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +300 -320
- package/dist/data/registry.json +168 -78
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,270 +1,253 @@
|
|
|
1
|
-
import { McpServer as
|
|
2
|
-
import { StdioServerTransport as
|
|
3
|
-
import { z as
|
|
4
|
-
import {
|
|
5
|
-
import { fileURLToPath as
|
|
6
|
-
import { join as
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
const
|
|
14
|
-
|
|
40
|
+
const s = [
|
|
41
|
+
p(f, "data/registry.json"),
|
|
15
42
|
// From dist/ to dist/data/ (copied during build)
|
|
16
|
-
|
|
43
|
+
p(f, "../src/data/registry.json"),
|
|
17
44
|
// From dist/ to src/data/ (development)
|
|
18
|
-
|
|
45
|
+
p(f, "../data/registry.json"),
|
|
19
46
|
// Fallback
|
|
20
|
-
|
|
47
|
+
p(process.cwd(), "src/data/registry.json"),
|
|
21
48
|
// From package root (published)
|
|
22
|
-
|
|
49
|
+
p(process.cwd(), "libs/rlx-ui/mcp/src/data/registry.json")
|
|
23
50
|
// Development
|
|
24
51
|
];
|
|
25
|
-
let
|
|
26
|
-
for (const
|
|
52
|
+
let t = null;
|
|
53
|
+
for (const i of s)
|
|
27
54
|
try {
|
|
28
|
-
|
|
55
|
+
t = j(i, "utf-8");
|
|
29
56
|
break;
|
|
30
57
|
} catch {
|
|
31
58
|
continue;
|
|
32
59
|
}
|
|
33
|
-
if (!
|
|
60
|
+
if (!t)
|
|
34
61
|
throw new Error("Could not find registry.json in any expected location");
|
|
35
|
-
return
|
|
36
|
-
} catch (
|
|
37
|
-
return console.error("Warning: Could not load component registry:",
|
|
62
|
+
return m = JSON.parse(t), m;
|
|
63
|
+
} catch (s) {
|
|
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
|
-
},
|
|
71
|
+
}, m;
|
|
45
72
|
}
|
|
46
73
|
}
|
|
47
|
-
function
|
|
48
|
-
return
|
|
74
|
+
function _() {
|
|
75
|
+
return u().widgets;
|
|
49
76
|
}
|
|
50
|
-
function
|
|
51
|
-
return
|
|
77
|
+
function O() {
|
|
78
|
+
return u().components;
|
|
52
79
|
}
|
|
53
|
-
function
|
|
54
|
-
return
|
|
80
|
+
function X() {
|
|
81
|
+
return u().animates;
|
|
55
82
|
}
|
|
56
|
-
function
|
|
57
|
-
return
|
|
83
|
+
function F() {
|
|
84
|
+
return u().hooks;
|
|
58
85
|
}
|
|
59
|
-
function
|
|
60
|
-
return
|
|
86
|
+
function N() {
|
|
87
|
+
return u().utils;
|
|
61
88
|
}
|
|
62
|
-
function
|
|
63
|
-
const
|
|
64
|
-
if (
|
|
65
|
-
const e =
|
|
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 (
|
|
69
|
-
const e =
|
|
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 (
|
|
73
|
-
const e =
|
|
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 (
|
|
77
|
-
const e =
|
|
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 (
|
|
81
|
-
const e =
|
|
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
|
|
86
|
-
const
|
|
87
|
-
...
|
|
88
|
-
...
|
|
89
|
-
...
|
|
90
|
-
...
|
|
91
|
-
...
|
|
92
|
-
], e =
|
|
93
|
-
return
|
|
94
|
-
(
|
|
112
|
+
function J(s) {
|
|
113
|
+
const t = u(), i = [
|
|
114
|
+
...t.widgets,
|
|
115
|
+
...t.components,
|
|
116
|
+
...t.animates,
|
|
117
|
+
...t.hooks,
|
|
118
|
+
...t.utils
|
|
119
|
+
], e = s.toLowerCase();
|
|
120
|
+
return i.filter(
|
|
121
|
+
(n) => n.name.toLowerCase().includes(e) || n.slug.toLowerCase().includes(e)
|
|
95
122
|
);
|
|
96
123
|
}
|
|
97
124
|
function h() {
|
|
98
|
-
return
|
|
125
|
+
return _();
|
|
99
126
|
}
|
|
100
127
|
function y() {
|
|
101
|
-
return
|
|
128
|
+
return O();
|
|
102
129
|
}
|
|
103
130
|
function b() {
|
|
104
|
-
return
|
|
131
|
+
return X();
|
|
105
132
|
}
|
|
106
133
|
function k() {
|
|
107
|
-
return
|
|
134
|
+
return F();
|
|
108
135
|
}
|
|
109
136
|
function w() {
|
|
110
|
-
return
|
|
137
|
+
return N();
|
|
111
138
|
}
|
|
112
|
-
function
|
|
113
|
-
return
|
|
139
|
+
function $(s) {
|
|
140
|
+
return J(s);
|
|
114
141
|
}
|
|
115
|
-
function
|
|
116
|
-
return
|
|
142
|
+
function M(s, t) {
|
|
143
|
+
return g(s, t) || null;
|
|
117
144
|
}
|
|
118
|
-
function
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
return { found: !1 };
|
|
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(
|
|
130
|
-
/(?:export\s+)?(?:interface|type)\s+(\w+Props?)\s*[=:]\s*\{[\s\S]*?\}/g
|
|
131
|
-
);
|
|
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.");
|
|
133
|
-
} else
|
|
134
|
-
t = "Source code not available in registry.";
|
|
135
|
-
return {
|
|
136
|
-
found: !0,
|
|
137
|
-
component: n,
|
|
138
|
-
props: e,
|
|
139
|
-
note: t
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
function $(o, s, n) {
|
|
143
|
-
var r;
|
|
144
|
-
const e = d(o, s);
|
|
145
|
+
function q(s, t, i) {
|
|
146
|
+
var o;
|
|
147
|
+
const e = g(s, t);
|
|
145
148
|
if (!e)
|
|
146
149
|
return { found: !1 };
|
|
147
|
-
const
|
|
148
|
-
if (e.demos && e.demos.forEach((
|
|
149
|
-
|
|
150
|
-
}),
|
|
151
|
-
const
|
|
152
|
-
return
|
|
150
|
+
const n = [];
|
|
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 ? {
|
|
153
156
|
found: !0,
|
|
154
157
|
component: e,
|
|
155
158
|
example: {
|
|
156
|
-
name:
|
|
157
|
-
code:
|
|
159
|
+
name: r.name,
|
|
160
|
+
code: r.code
|
|
158
161
|
},
|
|
159
|
-
availableDemos:
|
|
162
|
+
availableDemos: n
|
|
160
163
|
} : {
|
|
161
164
|
found: !0,
|
|
162
165
|
component: e,
|
|
163
|
-
availableDemos:
|
|
166
|
+
availableDemos: n
|
|
164
167
|
};
|
|
165
168
|
}
|
|
166
169
|
if (e.demos && e.demos.length > 0) {
|
|
167
|
-
const
|
|
168
|
-
if (
|
|
170
|
+
const r = e.demos[0];
|
|
171
|
+
if (r.code)
|
|
169
172
|
return {
|
|
170
173
|
found: !0,
|
|
171
174
|
component: e,
|
|
172
175
|
example: {
|
|
173
|
-
name:
|
|
174
|
-
code:
|
|
176
|
+
name: r.name,
|
|
177
|
+
code: r.code
|
|
175
178
|
},
|
|
176
|
-
availableDemos:
|
|
179
|
+
availableDemos: n
|
|
177
180
|
};
|
|
178
181
|
}
|
|
179
182
|
return {
|
|
180
183
|
found: !0,
|
|
181
184
|
component: e,
|
|
182
|
-
availableDemos:
|
|
185
|
+
availableDemos: n
|
|
183
186
|
};
|
|
184
187
|
}
|
|
185
|
-
function
|
|
186
|
-
const e =
|
|
188
|
+
function A(s, t, i = "pnpm") {
|
|
189
|
+
const e = g(s, t);
|
|
187
190
|
if (!e)
|
|
188
191
|
return { found: !1 };
|
|
189
|
-
let
|
|
192
|
+
let n;
|
|
190
193
|
switch (e.category) {
|
|
191
194
|
case "widget":
|
|
192
|
-
|
|
195
|
+
n = `@rlx-widgets/${e.slug}`;
|
|
193
196
|
break;
|
|
194
197
|
case "component":
|
|
195
|
-
|
|
198
|
+
n = `@rlx-components/${e.slug}`;
|
|
196
199
|
break;
|
|
197
200
|
case "hook":
|
|
198
|
-
|
|
201
|
+
n = `@rlx-hooks/${e.slug}`;
|
|
199
202
|
break;
|
|
200
203
|
case "util":
|
|
201
|
-
|
|
204
|
+
n = `@rlx-utils/${e.slug}`;
|
|
202
205
|
break;
|
|
203
206
|
case "animate":
|
|
204
|
-
|
|
207
|
+
n = `@rlx-animates/${e.slug}`;
|
|
205
208
|
break;
|
|
206
209
|
default:
|
|
207
210
|
return { found: !1 };
|
|
208
211
|
}
|
|
209
|
-
let
|
|
210
|
-
switch (
|
|
212
|
+
let o;
|
|
213
|
+
switch (i) {
|
|
211
214
|
case "npm":
|
|
212
|
-
|
|
215
|
+
o = `npm install ${n}`;
|
|
213
216
|
break;
|
|
214
217
|
case "pnpm":
|
|
215
|
-
|
|
218
|
+
o = `pnpm add ${n}`;
|
|
216
219
|
break;
|
|
217
220
|
case "yarn":
|
|
218
|
-
|
|
221
|
+
o = `yarn add ${n}`;
|
|
219
222
|
break;
|
|
220
223
|
default:
|
|
221
|
-
|
|
224
|
+
o = `pnpm add ${n}`;
|
|
222
225
|
}
|
|
223
226
|
return {
|
|
224
227
|
found: !0,
|
|
225
|
-
command:
|
|
226
|
-
packageName:
|
|
228
|
+
command: o,
|
|
229
|
+
packageName: n,
|
|
227
230
|
category: e.category
|
|
228
231
|
};
|
|
229
232
|
}
|
|
230
|
-
function
|
|
231
|
-
const
|
|
232
|
-
return
|
|
233
|
+
function D(s, t) {
|
|
234
|
+
const i = g(s, t);
|
|
235
|
+
return i ? i.sourceCode && typeof i.sourceCode == "string" ? {
|
|
233
236
|
found: !0,
|
|
234
|
-
component:
|
|
235
|
-
sourceCode:
|
|
236
|
-
sourceFiles:
|
|
237
|
+
component: i,
|
|
238
|
+
sourceCode: i.sourceCode,
|
|
239
|
+
sourceFiles: i.sourceFiles || {}
|
|
237
240
|
} : {
|
|
238
241
|
found: !0,
|
|
239
|
-
component:
|
|
240
|
-
sourceFiles:
|
|
242
|
+
component: i,
|
|
243
|
+
sourceFiles: i.sourceFiles || {}
|
|
241
244
|
} : { found: !1 };
|
|
242
245
|
}
|
|
243
|
-
function
|
|
244
|
-
|
|
245
|
-
content: [
|
|
246
|
-
{
|
|
247
|
-
type: "text",
|
|
248
|
-
text: JSON.stringify(o, null, 2)
|
|
249
|
-
}
|
|
250
|
-
]
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
function M(o, s, n) {
|
|
254
|
-
return c({
|
|
255
|
-
error: o,
|
|
256
|
-
...s && { slug: s },
|
|
257
|
-
...n && { category: n }
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
function p(o, s) {
|
|
261
|
-
return M("Component not found", o, s);
|
|
262
|
-
}
|
|
263
|
-
async function G() {
|
|
264
|
-
const o = new x(
|
|
246
|
+
async function E() {
|
|
247
|
+
const s = await G(), t = new L(
|
|
265
248
|
{
|
|
266
249
|
name: "@rlx-ui/mcp",
|
|
267
|
-
version:
|
|
250
|
+
version: s
|
|
268
251
|
},
|
|
269
252
|
{
|
|
270
253
|
capabilities: {
|
|
@@ -273,237 +256,223 @@ async function G() {
|
|
|
273
256
|
}
|
|
274
257
|
}
|
|
275
258
|
);
|
|
276
|
-
|
|
259
|
+
t.registerTool(
|
|
277
260
|
"list_widgets",
|
|
278
261
|
{
|
|
279
262
|
description: "List all available widgets in the RLX UI library"
|
|
280
263
|
},
|
|
281
264
|
async () => {
|
|
282
|
-
const
|
|
283
|
-
return
|
|
284
|
-
count:
|
|
285
|
-
widgets:
|
|
286
|
-
var
|
|
265
|
+
const e = h();
|
|
266
|
+
return l({
|
|
267
|
+
count: e.length,
|
|
268
|
+
widgets: e.map((n) => {
|
|
269
|
+
var o;
|
|
287
270
|
return {
|
|
288
|
-
name:
|
|
289
|
-
slug:
|
|
290
|
-
demosCount: ((
|
|
271
|
+
name: n.name,
|
|
272
|
+
slug: n.slug,
|
|
273
|
+
demosCount: ((o = n.demos) == null ? void 0 : o.length) ?? 0
|
|
291
274
|
};
|
|
292
275
|
})
|
|
293
276
|
});
|
|
294
277
|
}
|
|
295
|
-
),
|
|
278
|
+
), t.registerTool(
|
|
296
279
|
"list_components",
|
|
297
280
|
{
|
|
298
281
|
description: "List all available components in the RLX UI library"
|
|
299
282
|
},
|
|
300
283
|
async () => {
|
|
301
|
-
const
|
|
302
|
-
return
|
|
303
|
-
count:
|
|
304
|
-
components:
|
|
305
|
-
var
|
|
284
|
+
const e = y();
|
|
285
|
+
return l({
|
|
286
|
+
count: e.length,
|
|
287
|
+
components: e.map((n) => {
|
|
288
|
+
var o;
|
|
306
289
|
return {
|
|
307
|
-
name:
|
|
308
|
-
slug:
|
|
309
|
-
demosCount: ((
|
|
290
|
+
name: n.name,
|
|
291
|
+
slug: n.slug,
|
|
292
|
+
demosCount: ((o = n.demos) == null ? void 0 : o.length) ?? 0
|
|
310
293
|
};
|
|
311
294
|
})
|
|
312
295
|
});
|
|
313
296
|
}
|
|
314
|
-
),
|
|
297
|
+
), t.registerTool(
|
|
315
298
|
"list_animates",
|
|
316
299
|
{
|
|
317
300
|
description: "List all available animations in the RLX UI library"
|
|
318
301
|
},
|
|
319
302
|
async () => {
|
|
320
|
-
const
|
|
321
|
-
return
|
|
322
|
-
count:
|
|
323
|
-
animates:
|
|
324
|
-
var
|
|
303
|
+
const e = b();
|
|
304
|
+
return l({
|
|
305
|
+
count: e.length,
|
|
306
|
+
animates: e.map((n) => {
|
|
307
|
+
var o;
|
|
325
308
|
return {
|
|
326
|
-
name:
|
|
327
|
-
slug:
|
|
328
|
-
demosCount: ((
|
|
309
|
+
name: n.name,
|
|
310
|
+
slug: n.slug,
|
|
311
|
+
demosCount: ((o = n.demos) == null ? void 0 : o.length) ?? 0
|
|
329
312
|
};
|
|
330
313
|
})
|
|
331
314
|
});
|
|
332
315
|
}
|
|
333
|
-
),
|
|
316
|
+
), t.registerTool(
|
|
334
317
|
"list_hooks",
|
|
335
318
|
{
|
|
336
319
|
description: "List all available React hooks in the RLX UI library"
|
|
337
320
|
},
|
|
338
321
|
async () => {
|
|
339
|
-
const
|
|
340
|
-
return
|
|
341
|
-
count:
|
|
342
|
-
hooks:
|
|
343
|
-
var
|
|
322
|
+
const e = k();
|
|
323
|
+
return l({
|
|
324
|
+
count: e.length,
|
|
325
|
+
hooks: e.map((n) => {
|
|
326
|
+
var o;
|
|
344
327
|
return {
|
|
345
|
-
name:
|
|
346
|
-
slug:
|
|
347
|
-
demosCount: ((
|
|
328
|
+
name: n.name,
|
|
329
|
+
slug: n.slug,
|
|
330
|
+
demosCount: ((o = n.demos) == null ? void 0 : o.length) ?? 0
|
|
348
331
|
};
|
|
349
332
|
})
|
|
350
333
|
});
|
|
351
334
|
}
|
|
352
|
-
),
|
|
335
|
+
), t.registerTool(
|
|
353
336
|
"list_utils",
|
|
354
337
|
{
|
|
355
338
|
description: "List all available utility functions in the RLX UI library"
|
|
356
339
|
},
|
|
357
340
|
async () => {
|
|
358
|
-
const
|
|
359
|
-
return
|
|
360
|
-
count:
|
|
361
|
-
utils:
|
|
362
|
-
var
|
|
341
|
+
const e = w();
|
|
342
|
+
return l({
|
|
343
|
+
count: e.length,
|
|
344
|
+
utils: e.map((n) => {
|
|
345
|
+
var o;
|
|
363
346
|
return {
|
|
364
|
-
name:
|
|
365
|
-
slug:
|
|
366
|
-
demosCount: ((
|
|
347
|
+
name: n.name,
|
|
348
|
+
slug: n.slug,
|
|
349
|
+
demosCount: ((o = n.demos) == null ? void 0 : o.length) ?? 0
|
|
367
350
|
};
|
|
368
351
|
})
|
|
369
352
|
});
|
|
370
353
|
}
|
|
371
|
-
),
|
|
354
|
+
), t.registerTool(
|
|
372
355
|
"search_component",
|
|
373
356
|
{
|
|
374
357
|
description: "Search for components, widgets, hooks, utils, or animates by name or slug",
|
|
375
358
|
inputSchema: {
|
|
376
|
-
query:
|
|
359
|
+
query: c.string().describe("Search query to find components")
|
|
377
360
|
}
|
|
378
361
|
},
|
|
379
|
-
async (
|
|
380
|
-
const
|
|
381
|
-
return
|
|
382
|
-
query:
|
|
383
|
-
count:
|
|
384
|
-
results:
|
|
385
|
-
name:
|
|
386
|
-
slug:
|
|
387
|
-
category:
|
|
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
|
|
388
371
|
}))
|
|
389
372
|
});
|
|
390
373
|
}
|
|
391
|
-
),
|
|
374
|
+
), t.registerTool(
|
|
392
375
|
"get_component_info",
|
|
393
376
|
{
|
|
394
377
|
description: "Get detailed information about a specific component, widget, hook, util, or animate",
|
|
395
378
|
inputSchema: {
|
|
396
|
-
slug:
|
|
397
|
-
|
|
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")
|
|
398
383
|
}
|
|
399
384
|
},
|
|
400
|
-
async (
|
|
401
|
-
var
|
|
402
|
-
const
|
|
403
|
-
return
|
|
404
|
-
name:
|
|
405
|
-
slug:
|
|
406
|
-
category:
|
|
407
|
-
hasSourceCode: !!
|
|
408
|
-
demosCount: ((
|
|
409
|
-
demos: (r =
|
|
410
|
-
name:
|
|
411
|
-
hasCode: !!
|
|
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
|
|
412
397
|
}))
|
|
413
|
-
}) :
|
|
398
|
+
}) : d(e.slug, e.category);
|
|
414
399
|
}
|
|
415
|
-
),
|
|
416
|
-
"get_component_props",
|
|
417
|
-
{
|
|
418
|
-
description: "Get TypeScript props/interface definition for a component",
|
|
419
|
-
inputSchema: {
|
|
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")
|
|
422
|
-
}
|
|
423
|
-
},
|
|
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);
|
|
436
|
-
}
|
|
437
|
-
), o.registerTool(
|
|
400
|
+
), t.registerTool(
|
|
438
401
|
"get_component_example",
|
|
439
402
|
{
|
|
440
403
|
description: "Get code examples (demos) for a component",
|
|
441
404
|
inputSchema: {
|
|
442
|
-
slug:
|
|
443
|
-
category:
|
|
444
|
-
exampleName:
|
|
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
|
+
)
|
|
445
410
|
}
|
|
446
411
|
},
|
|
447
|
-
async (
|
|
448
|
-
var
|
|
449
|
-
const
|
|
450
|
-
|
|
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({
|
|
451
420
|
component: {
|
|
452
|
-
name: (
|
|
453
|
-
slug: (r =
|
|
454
|
-
category: (
|
|
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
|
|
455
424
|
},
|
|
456
|
-
example:
|
|
457
|
-
availableDemos:
|
|
458
|
-
}) :
|
|
425
|
+
example: n.example,
|
|
426
|
+
availableDemos: n.availableDemos
|
|
427
|
+
}) : d(e.slug, e.category);
|
|
459
428
|
}
|
|
460
|
-
),
|
|
429
|
+
), t.registerTool(
|
|
461
430
|
"get_component_source",
|
|
462
431
|
{
|
|
463
432
|
description: "Get the complete source code for a component, including main file and all related files (utils, types, etc.)",
|
|
464
433
|
inputSchema: {
|
|
465
|
-
slug:
|
|
466
|
-
category:
|
|
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")
|
|
467
436
|
}
|
|
468
437
|
},
|
|
469
|
-
async (
|
|
470
|
-
var
|
|
471
|
-
const
|
|
472
|
-
return
|
|
438
|
+
async (e) => {
|
|
439
|
+
var o, r, a;
|
|
440
|
+
const n = D(e.slug, e.category);
|
|
441
|
+
return n.found ? l({
|
|
473
442
|
component: {
|
|
474
|
-
name: (
|
|
475
|
-
slug: (r =
|
|
476
|
-
category: (
|
|
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
|
|
477
446
|
},
|
|
478
|
-
sourceCode:
|
|
479
|
-
sourceFiles:
|
|
480
|
-
note:
|
|
481
|
-
}) :
|
|
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);
|
|
482
451
|
}
|
|
483
|
-
),
|
|
452
|
+
), t.registerTool(
|
|
484
453
|
"get_installation_command",
|
|
485
454
|
{
|
|
486
455
|
description: "Get npm/pnpm/yarn installation command for a component",
|
|
487
456
|
inputSchema: {
|
|
488
|
-
slug:
|
|
489
|
-
category:
|
|
490
|
-
packageManager:
|
|
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)")
|
|
491
460
|
}
|
|
492
461
|
},
|
|
493
|
-
async (
|
|
494
|
-
const
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
462
|
+
async (e) => {
|
|
463
|
+
const n = A(
|
|
464
|
+
e.slug,
|
|
465
|
+
e.category,
|
|
466
|
+
e.packageManager || "pnpm"
|
|
498
467
|
);
|
|
499
|
-
return
|
|
500
|
-
command:
|
|
501
|
-
packageName:
|
|
502
|
-
category:
|
|
503
|
-
packageManager:
|
|
504
|
-
}) :
|
|
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);
|
|
505
474
|
}
|
|
506
|
-
),
|
|
475
|
+
), t.registerResource(
|
|
507
476
|
"RLX UI Widgets",
|
|
508
477
|
"rlx-ui://widgets",
|
|
509
478
|
{
|
|
@@ -511,18 +480,18 @@ async function G() {
|
|
|
511
480
|
mimeType: "application/json"
|
|
512
481
|
},
|
|
513
482
|
async () => {
|
|
514
|
-
const
|
|
483
|
+
const e = h();
|
|
515
484
|
return {
|
|
516
485
|
contents: [
|
|
517
486
|
{
|
|
518
487
|
uri: "rlx-ui://widgets",
|
|
519
488
|
mimeType: "application/json",
|
|
520
|
-
text: JSON.stringify(
|
|
489
|
+
text: JSON.stringify(e, null, 2)
|
|
521
490
|
}
|
|
522
491
|
]
|
|
523
492
|
};
|
|
524
493
|
}
|
|
525
|
-
),
|
|
494
|
+
), t.registerResource(
|
|
526
495
|
"RLX UI Components",
|
|
527
496
|
"rlx-ui://components",
|
|
528
497
|
{
|
|
@@ -530,18 +499,18 @@ async function G() {
|
|
|
530
499
|
mimeType: "application/json"
|
|
531
500
|
},
|
|
532
501
|
async () => {
|
|
533
|
-
const
|
|
502
|
+
const e = y();
|
|
534
503
|
return {
|
|
535
504
|
contents: [
|
|
536
505
|
{
|
|
537
506
|
uri: "rlx-ui://components",
|
|
538
507
|
mimeType: "application/json",
|
|
539
|
-
text: JSON.stringify(
|
|
508
|
+
text: JSON.stringify(e, null, 2)
|
|
540
509
|
}
|
|
541
510
|
]
|
|
542
511
|
};
|
|
543
512
|
}
|
|
544
|
-
),
|
|
513
|
+
), t.registerResource(
|
|
545
514
|
"RLX UI Animates",
|
|
546
515
|
"rlx-ui://animates",
|
|
547
516
|
{
|
|
@@ -549,18 +518,18 @@ async function G() {
|
|
|
549
518
|
mimeType: "application/json"
|
|
550
519
|
},
|
|
551
520
|
async () => {
|
|
552
|
-
const
|
|
521
|
+
const e = b();
|
|
553
522
|
return {
|
|
554
523
|
contents: [
|
|
555
524
|
{
|
|
556
525
|
uri: "rlx-ui://animates",
|
|
557
526
|
mimeType: "application/json",
|
|
558
|
-
text: JSON.stringify(
|
|
527
|
+
text: JSON.stringify(e, null, 2)
|
|
559
528
|
}
|
|
560
529
|
]
|
|
561
530
|
};
|
|
562
531
|
}
|
|
563
|
-
),
|
|
532
|
+
), t.registerResource(
|
|
564
533
|
"RLX UI Hooks",
|
|
565
534
|
"rlx-ui://hooks",
|
|
566
535
|
{
|
|
@@ -568,18 +537,18 @@ async function G() {
|
|
|
568
537
|
mimeType: "application/json"
|
|
569
538
|
},
|
|
570
539
|
async () => {
|
|
571
|
-
const
|
|
540
|
+
const e = k();
|
|
572
541
|
return {
|
|
573
542
|
contents: [
|
|
574
543
|
{
|
|
575
544
|
uri: "rlx-ui://hooks",
|
|
576
545
|
mimeType: "application/json",
|
|
577
|
-
text: JSON.stringify(
|
|
546
|
+
text: JSON.stringify(e, null, 2)
|
|
578
547
|
}
|
|
579
548
|
]
|
|
580
549
|
};
|
|
581
550
|
}
|
|
582
|
-
),
|
|
551
|
+
), t.registerResource(
|
|
583
552
|
"RLX UI Utils",
|
|
584
553
|
"rlx-ui://utils",
|
|
585
554
|
{
|
|
@@ -587,18 +556,18 @@ async function G() {
|
|
|
587
556
|
mimeType: "application/json"
|
|
588
557
|
},
|
|
589
558
|
async () => {
|
|
590
|
-
const
|
|
559
|
+
const e = w();
|
|
591
560
|
return {
|
|
592
561
|
contents: [
|
|
593
562
|
{
|
|
594
563
|
uri: "rlx-ui://utils",
|
|
595
564
|
mimeType: "application/json",
|
|
596
|
-
text: JSON.stringify(
|
|
565
|
+
text: JSON.stringify(e, null, 2)
|
|
597
566
|
}
|
|
598
567
|
]
|
|
599
568
|
};
|
|
600
569
|
}
|
|
601
|
-
),
|
|
570
|
+
), t.registerResource(
|
|
602
571
|
"RLX UI Information",
|
|
603
572
|
"rlx-ui://info",
|
|
604
573
|
{
|
|
@@ -606,7 +575,7 @@ async function G() {
|
|
|
606
575
|
mimeType: "application/json"
|
|
607
576
|
},
|
|
608
577
|
async () => {
|
|
609
|
-
const
|
|
578
|
+
const e = h(), n = y(), o = b(), r = k(), a = w();
|
|
610
579
|
return {
|
|
611
580
|
contents: [
|
|
612
581
|
{
|
|
@@ -616,15 +585,15 @@ async function G() {
|
|
|
616
585
|
{
|
|
617
586
|
name: "RLX UI",
|
|
618
587
|
description: "A comprehensive UI component library",
|
|
619
|
-
version:
|
|
588
|
+
version: s,
|
|
620
589
|
mcpServer: "@rlx-ui/mcp",
|
|
621
590
|
stats: {
|
|
622
|
-
widgets:
|
|
623
|
-
components:
|
|
624
|
-
animates:
|
|
591
|
+
widgets: e.length,
|
|
592
|
+
components: n.length,
|
|
593
|
+
animates: o.length,
|
|
625
594
|
hooks: r.length,
|
|
626
|
-
utils:
|
|
627
|
-
total:
|
|
595
|
+
utils: a.length,
|
|
596
|
+
total: e.length + n.length + o.length + r.length + a.length
|
|
628
597
|
}
|
|
629
598
|
},
|
|
630
599
|
null,
|
|
@@ -635,9 +604,20 @@ async function G() {
|
|
|
635
604
|
};
|
|
636
605
|
}
|
|
637
606
|
);
|
|
638
|
-
const
|
|
639
|
-
await
|
|
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;
|
|
640
620
|
}
|
|
641
|
-
|
|
642
|
-
console.error("Fatal error in main():",
|
|
621
|
+
E().catch((s) => {
|
|
622
|
+
console.error("Fatal error in main():", s), process.exit(1);
|
|
643
623
|
});
|