@plankui/mcp 0.1.1 → 0.1.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/server.mjs CHANGED
@@ -21,11 +21,17 @@ function closure(slug, seen = new Set()) {
21
21
  return seen;
22
22
  }
23
23
 
24
- function componentDoc(c, withSource = true) {
24
+ /** "base" serves the Base UI version of each file that has one; everything else is shared. */
25
+ const libOf = (v) => (String(v ?? "").toLowerCase().startsWith("base") ? "base" : "radix");
26
+
27
+ function componentDoc(c, withSource = true, lib = "radix") {
25
28
  const files = [...closure(c.slug)];
26
- const deps = [...new Set(files.flatMap((s) => bySlug(reg.components, s)?.deps ?? []))];
29
+ const useBase = (f) => lib === "base" && Boolean(bySlug(reg.components, f)?.baseSource);
30
+ const deps = [...new Set(files.flatMap((f) => (bySlug(reg.components, f)?.deps ?? []).map((d) => (d === "radix-ui" && useBase(f) ? "@base-ui/react" : d))))];
27
31
  const props = c.props.map(([n, t, d, desc]) => `| \`${n}\` | \`${t}\` | ${d ? `\`${d}\`` : ""} | ${desc} |`).join("\n");
28
- let out = `# ${c.name}${c.pro ? " (Pro)" : ""}\n\n${c.description}\n\nCategory: ${c.category}\n\n## Install\n\n`;
32
+ let out = `# ${c.name}${c.pro ? " (Pro)" : ""}\n\n${c.description}\n\nCategory: ${c.category}\n\n`;
33
+ if (c.baseSource) out += lib === "base" ? "Primitives: Base UI. The same component on Radix UI: call again with primitives \"radix\".\n\n" : "Primitives: Radix UI. A Base UI version exists: call again with primitives \"base\".\n\n";
34
+ out += "## Install\n\n";
29
35
  out += deps.length ? `\`\`\`bash\nnpm i ${deps.join(" ")}\n\`\`\`\n\n` : "No extra dependencies.\n\n";
30
36
  out += `Copy into \`src/components/ui/\`: ${files.map((f) => `\`${f}.tsx\``).join(", ")}.\n\n`;
31
37
  out += `## Usage\n\n\`\`\`tsx\nimport { ${pascal(c.slug)} } from "@/components/ui/${c.slug}";\n\n${c.usage}\n\`\`\`\n\n`;
@@ -34,7 +40,8 @@ function componentDoc(c, withSource = true) {
34
40
  for (const f of files) {
35
41
  const dep = bySlug(reg.components, f);
36
42
  out += `## src/components/ui/${f}.tsx\n\n`;
37
- out += dep?.source ? `\`\`\`tsx\n${dep.source}\n\`\`\`\n\n` : `${PRO_NOTE}\n\n`;
43
+ const src = useBase(f) ? dep.baseSource : dep?.source;
44
+ out += src ? `\`\`\`tsx\n${src}\n\`\`\`\n\n` : `${PRO_NOTE}\n\n`;
38
45
  }
39
46
  }
40
47
  return out;
@@ -61,19 +68,19 @@ const tools = {
61
68
  },
62
69
  },
63
70
  get_component: {
64
- description: "Get one component: install command, every file it needs with full source, usage example and props.",
65
- inputSchema: { type: "object", properties: { slug: { type: "string", description: "Component slug, such as button or dialog." } }, required: ["slug"] },
66
- run: ({ slug }) => {
71
+ description: "Get one component: install command, every file it needs with full source, usage example and props. Pass primitives \"base\" for the Base UI version.",
72
+ inputSchema: { type: "object", properties: { slug: { type: "string", description: "Component slug, such as button or dialog." }, primitives: { type: "string", enum: ["radix", "base"], description: "Optional: \"radix\" (default) or \"base\" for the Base UI version, where one exists." } }, required: ["slug"] },
73
+ run: ({ slug, primitives }) => {
67
74
  const c = bySlug(reg.components, slug);
68
- return c ? componentDoc(c) : `No component "${slug}". Call list_components to see the slugs.`;
75
+ return c ? componentDoc(c, true, libOf(primitives)) : `No component "${slug}". Call list_components to see the slugs.`;
69
76
  },
70
77
  },
71
78
  get_component_usage: {
72
79
  description: "Get a component's usage example and props without the source. Lighter than get_component.",
73
- inputSchema: { type: "object", properties: { slug: { type: "string" } }, required: ["slug"] },
74
- run: ({ slug }) => {
80
+ inputSchema: { type: "object", properties: { slug: { type: "string" }, primitives: { type: "string", enum: ["radix", "base"], description: "Optional: \"radix\" (default) or \"base\" for the Base UI version, where one exists." } }, required: ["slug"] },
81
+ run: ({ slug, primitives }) => {
75
82
  const c = bySlug(reg.components, slug);
76
- return c ? componentDoc(c, false) : `No component "${slug}".`;
83
+ return c ? componentDoc(c, false, libOf(primitives)) : `No component "${slug}".`;
77
84
  },
78
85
  },
79
86
  list_templates: {