@metacells/mcellui-mcp-server 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/index.js +70 -7
  2. package/package.json +7 -5
  3. package/registry/registry.json +717 -0
  4. package/registry/ui/accordion.tsx +416 -0
  5. package/registry/ui/action-sheet.tsx +396 -0
  6. package/registry/ui/alert-dialog.tsx +355 -0
  7. package/registry/ui/avatar-stack.tsx +278 -0
  8. package/registry/ui/avatar.tsx +116 -0
  9. package/registry/ui/badge.tsx +125 -0
  10. package/registry/ui/button.tsx +240 -0
  11. package/registry/ui/card.tsx +675 -0
  12. package/registry/ui/carousel.tsx +431 -0
  13. package/registry/ui/checkbox.tsx +252 -0
  14. package/registry/ui/chip.tsx +271 -0
  15. package/registry/ui/column.tsx +133 -0
  16. package/registry/ui/datetime-picker.tsx +578 -0
  17. package/registry/ui/dialog.tsx +292 -0
  18. package/registry/ui/fab.tsx +225 -0
  19. package/registry/ui/form.tsx +323 -0
  20. package/registry/ui/horizontal-list.tsx +200 -0
  21. package/registry/ui/icon-button.tsx +244 -0
  22. package/registry/ui/image-gallery.tsx +455 -0
  23. package/registry/ui/image.tsx +283 -0
  24. package/registry/ui/input.tsx +242 -0
  25. package/registry/ui/label.tsx +99 -0
  26. package/registry/ui/list.tsx +519 -0
  27. package/registry/ui/progress.tsx +168 -0
  28. package/registry/ui/pull-to-refresh.tsx +231 -0
  29. package/registry/ui/radio-group.tsx +294 -0
  30. package/registry/ui/rating.tsx +311 -0
  31. package/registry/ui/row.tsx +136 -0
  32. package/registry/ui/screen.tsx +153 -0
  33. package/registry/ui/search-input.tsx +281 -0
  34. package/registry/ui/section-header.tsx +258 -0
  35. package/registry/ui/segmented-control.tsx +229 -0
  36. package/registry/ui/select.tsx +311 -0
  37. package/registry/ui/separator.tsx +74 -0
  38. package/registry/ui/sheet.tsx +362 -0
  39. package/registry/ui/skeleton.tsx +156 -0
  40. package/registry/ui/slider.tsx +307 -0
  41. package/registry/ui/spinner.tsx +100 -0
  42. package/registry/ui/stepper.tsx +314 -0
  43. package/registry/ui/stories.tsx +463 -0
  44. package/registry/ui/swipeable-row.tsx +362 -0
  45. package/registry/ui/switch.tsx +246 -0
  46. package/registry/ui/tabs.tsx +348 -0
  47. package/registry/ui/textarea.tsx +265 -0
  48. package/registry/ui/toast.tsx +316 -0
  49. package/registry/ui/tooltip.tsx +369 -0
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 loadRegistry() {
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 loadComponentCode(item) {
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: "Error: Could not load component registry."
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: [
@@ -852,10 +909,16 @@ import { fileURLToPath as fileURLToPath2 } from "url";
852
909
  var __filename2 = fileURLToPath2(import.meta.url);
853
910
  var __dirname2 = path2.dirname(__filename2);
854
911
  function getRegistryPath2() {
855
- return path2.resolve(__dirname2, "..", "..", "registry");
912
+ const bundledPath = path2.resolve(__dirname2, "..", "registry");
913
+ const monorepoPath = path2.resolve(__dirname2, "..", "..", "registry");
914
+ if (fs2.existsSync(path2.join(bundledPath, "registry.json"))) {
915
+ return bundledPath;
916
+ }
917
+ return monorepoPath;
856
918
  }
857
919
  function getCorePath() {
858
- return path2.resolve(__dirname2, "..", "..", "core", "src");
920
+ const monorepoPath = path2.resolve(__dirname2, "..", "..", "core", "src");
921
+ return monorepoPath;
859
922
  }
860
923
  var resources = [
861
924
  {
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@metacells/mcellui-mcp-server",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
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",
@@ -29,10 +29,12 @@
29
29
  "mcellui-mcp": "./dist/index.js"
30
30
  },
31
31
  "files": [
32
- "dist"
32
+ "dist",
33
+ "registry"
33
34
  ],
34
35
  "scripts": {
35
- "build": "tsup",
36
+ "build": "tsup && npm run copy-registry",
37
+ "copy-registry": "cp -r ../registry/registry.json ../registry/ui ./registry/ 2>/dev/null || mkdir -p registry && cp ../registry/registry.json registry/ && cp -r ../registry/ui registry/",
36
38
  "dev": "tsup --watch",
37
39
  "type-check": "tsc --noEmit",
38
40
  "lint": "eslint src/"