@metacells/mcellui-mcp-server 0.1.0 → 0.1.1
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/index.js +62 -5
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -16,10 +16,22 @@ import path from "path";
|
|
|
16
16
|
import { fileURLToPath } from "url";
|
|
17
17
|
var __filename = fileURLToPath(import.meta.url);
|
|
18
18
|
var __dirname = path.dirname(__filename);
|
|
19
|
+
var DEFAULT_REGISTRY_URL = "https://raw.githubusercontent.com/metacells-development/mcellui/main/packages/registry";
|
|
20
|
+
var REGISTRY_URL = process.env.MCELLUI_REGISTRY_URL || process.env.NATIVEUI_REGISTRY_URL || DEFAULT_REGISTRY_URL;
|
|
21
|
+
var registryCache = null;
|
|
22
|
+
var componentCodeCache = /* @__PURE__ */ new Map();
|
|
19
23
|
function getRegistryPath() {
|
|
20
24
|
return path.resolve(__dirname, "..", "..", "registry");
|
|
21
25
|
}
|
|
22
|
-
function
|
|
26
|
+
function isLocalMode() {
|
|
27
|
+
const localPath = getRegistryPath();
|
|
28
|
+
try {
|
|
29
|
+
return fs.existsSync(path.join(localPath, "registry.json"));
|
|
30
|
+
} catch {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function loadLocalRegistry() {
|
|
23
35
|
try {
|
|
24
36
|
const registryPath = path.join(getRegistryPath(), "registry.json");
|
|
25
37
|
const data = fs.readFileSync(registryPath, "utf-8");
|
|
@@ -28,7 +40,25 @@ function loadRegistry() {
|
|
|
28
40
|
return null;
|
|
29
41
|
}
|
|
30
42
|
}
|
|
31
|
-
function
|
|
43
|
+
async function loadRemoteRegistry() {
|
|
44
|
+
try {
|
|
45
|
+
const response = await fetch(`${REGISTRY_URL}/registry.json`);
|
|
46
|
+
if (!response.ok) return null;
|
|
47
|
+
return await response.json();
|
|
48
|
+
} catch {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
async function loadRegistry() {
|
|
53
|
+
if (registryCache) return registryCache;
|
|
54
|
+
if (isLocalMode()) {
|
|
55
|
+
registryCache = loadLocalRegistry();
|
|
56
|
+
if (registryCache) return registryCache;
|
|
57
|
+
}
|
|
58
|
+
registryCache = await loadRemoteRegistry();
|
|
59
|
+
return registryCache;
|
|
60
|
+
}
|
|
61
|
+
function loadLocalComponentCode(item) {
|
|
32
62
|
try {
|
|
33
63
|
const registryPath = getRegistryPath();
|
|
34
64
|
const file = item.files[0];
|
|
@@ -39,6 +69,33 @@ function loadComponentCode(item) {
|
|
|
39
69
|
return null;
|
|
40
70
|
}
|
|
41
71
|
}
|
|
72
|
+
async function loadRemoteComponentCode(item) {
|
|
73
|
+
try {
|
|
74
|
+
const file = item.files[0];
|
|
75
|
+
if (!file) return null;
|
|
76
|
+
const response = await fetch(`${REGISTRY_URL}/${file}`);
|
|
77
|
+
if (!response.ok) return null;
|
|
78
|
+
return await response.text();
|
|
79
|
+
} catch {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
async function loadComponentCode(item) {
|
|
84
|
+
if (componentCodeCache.has(item.name)) {
|
|
85
|
+
return componentCodeCache.get(item.name);
|
|
86
|
+
}
|
|
87
|
+
let code = null;
|
|
88
|
+
if (isLocalMode()) {
|
|
89
|
+
code = loadLocalComponentCode(item);
|
|
90
|
+
}
|
|
91
|
+
if (!code) {
|
|
92
|
+
code = await loadRemoteComponentCode(item);
|
|
93
|
+
}
|
|
94
|
+
if (code) {
|
|
95
|
+
componentCodeCache.set(item.name, code);
|
|
96
|
+
}
|
|
97
|
+
return code;
|
|
98
|
+
}
|
|
42
99
|
var tools = [
|
|
43
100
|
{
|
|
44
101
|
name: "nativeui_list_components",
|
|
@@ -235,13 +292,13 @@ var componentKeywords = {
|
|
|
235
292
|
"onboarding-screen": ["onboarding", "intro", "welcome", "tutorial"]
|
|
236
293
|
};
|
|
237
294
|
async function handleToolCall(name, args) {
|
|
238
|
-
const registry = loadRegistry();
|
|
295
|
+
const registry = await loadRegistry();
|
|
239
296
|
if (!registry && !["nativeui_doctor", "nativeui_create_component", "nativeui_customize_theme"].includes(name)) {
|
|
240
297
|
return {
|
|
241
298
|
content: [
|
|
242
299
|
{
|
|
243
300
|
type: "text",
|
|
244
|
-
text:
|
|
301
|
+
text: `Error: Could not load component registry. Tried: ${REGISTRY_URL}/registry.json`
|
|
245
302
|
}
|
|
246
303
|
]
|
|
247
304
|
};
|
|
@@ -300,7 +357,7 @@ Available: ${registry.components.map((c) => c.name).join(", ")}`
|
|
|
300
357
|
]
|
|
301
358
|
};
|
|
302
359
|
}
|
|
303
|
-
const code = loadComponentCode(component);
|
|
360
|
+
const code = await loadComponentCode(component);
|
|
304
361
|
if (!code) {
|
|
305
362
|
return {
|
|
306
363
|
content: [
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metacells/mcellui-mcp-server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "MCP server for mcellui - AI assistant integration for React Native development",
|
|
5
5
|
"author": "metacells",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://mcellui.dev/docs/mcp",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
|
-
"url": "git+https://github.com/metacells/mcellui.git",
|
|
10
|
+
"url": "git+https://github.com/metacells-development/mcellui.git",
|
|
11
11
|
"directory": "packages/mcp-server"
|
|
12
12
|
},
|
|
13
13
|
"bugs": {
|
|
14
|
-
"url": "https://github.com/metacells/mcellui/issues"
|
|
14
|
+
"url": "https://github.com/metacells-development/mcellui/issues"
|
|
15
15
|
},
|
|
16
16
|
"keywords": [
|
|
17
17
|
"mcp",
|