@recanica/mcp 0.0.0-stage → 0.2.0
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/LICENSE +9 -0
- package/README.md +25 -2
- package/data/recanica.json +1 -0
- package/package.json +47 -3
- package/src/index.js +213 -0
package/package.json
CHANGED
|
@@ -1,6 +1,50 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@recanica/mcp",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "MCP server for Recanica: gives AI tools the design rules, tokens, component source, patterns and setup guides.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Aturanica Labs",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/booyen/recanica.git",
|
|
10
|
+
"directory": "packages/mcp"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"mcp",
|
|
14
|
+
"model-context-protocol",
|
|
15
|
+
"design-system",
|
|
16
|
+
"recanica",
|
|
17
|
+
"claude",
|
|
18
|
+
"cursor"
|
|
19
|
+
],
|
|
20
|
+
"type": "module",
|
|
21
|
+
"bin": {
|
|
22
|
+
"recanica-mcp": "./src/index.js"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"src",
|
|
26
|
+
"data",
|
|
27
|
+
"README.md"
|
|
28
|
+
],
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
31
|
+
"zod": "^4.6.7"
|
|
32
|
+
},
|
|
33
|
+
"exports": {
|
|
34
|
+
".": "./src/index.js",
|
|
35
|
+
"./data": "./data/recanica.json",
|
|
36
|
+
"./package.json": "./package.json"
|
|
37
|
+
},
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@recanica/tokens": "0.2.0",
|
|
43
|
+
"@recanica/css": "0.2.0"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "node scripts/build-data.mjs",
|
|
47
|
+
"start": "node src/index.js",
|
|
48
|
+
"test": "node scripts/smoke.mjs"
|
|
49
|
+
}
|
|
6
50
|
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Recanica MCP server (stdio).
|
|
4
|
+
* claude mcp add recanica -- npx -y @recanica/mcp
|
|
5
|
+
* { "mcpServers": { "recanica": { "command": "npx", "args": ["-y", "@recanica/mcp"] } } }
|
|
6
|
+
*/
|
|
7
|
+
import { readFileSync } from "node:fs";
|
|
8
|
+
import { join } from "node:path";
|
|
9
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
10
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
|
|
13
|
+
const data = JSON.parse(readFileSync(join(import.meta.dirname, "../data/recanica.json"), "utf8"));
|
|
14
|
+
const text = (t) => ({ content: [{ type: "text", text: t }] });
|
|
15
|
+
const fence = (lang, code) => "```" + lang + "\n" + code + "\n```";
|
|
16
|
+
|
|
17
|
+
const STACKS = {
|
|
18
|
+
nextjs: "setup-nextjs", "vite-react": "setup-vite-react", "tailwind-v3": "setup-tailwind-v3", html: "setup-html",
|
|
19
|
+
flutter: "setup-flutter", swiftui: "setup-swiftui", compose: "setup-compose", figma: "setup-figma",
|
|
20
|
+
};
|
|
21
|
+
const TOKEN_FORMATS = ["json", "css", "tailwind-v4", "tailwind-v3", "flutter", "swiftui", "compose", "figma", "plain-css"];
|
|
22
|
+
|
|
23
|
+
// Sent to the AI tool when it connects, so every project starts at the same point however Recanica was shared.
|
|
24
|
+
const START = "Recanica is installed, not studied. In the user's project run `npx recanica start` first: it says the next step (init, kickoff, or build). " +
|
|
25
|
+
"Never copy components, CSS or pages from the Recanica repo or docs, and never write your own version of a part that exists: use @recanica/ui or the rc-* classes from @recanica/css. " +
|
|
26
|
+
"Call get_rules before writing UI. Show only what the reader needs: no badge, pill, label, eyebrow or button without information or an action. " +
|
|
27
|
+
"Spacing from the container and rhythm tokens, never pixels. No gradients, glass, glows or AI phrasing. Done means `npx recanica check` and `npx recanica slop` pass.";
|
|
28
|
+
const server = new McpServer({ name: "recanica", version: data.version }, { instructions: START });
|
|
29
|
+
|
|
30
|
+
server.registerTool("get_rules", {
|
|
31
|
+
title: "Recanica design rules",
|
|
32
|
+
description: "The complete Recanica brand and UI rules (identity, color tokens with hex values, surfaces, type, spacing, shape, components, do/don't). Read this before writing any UI.",
|
|
33
|
+
inputSchema: {},
|
|
34
|
+
}, async () => text(data.rules));
|
|
35
|
+
|
|
36
|
+
server.registerTool("get_tokens", {
|
|
37
|
+
title: "Design tokens",
|
|
38
|
+
description: "Recanica tokens in a platform format: json (resolved hex), css (variables), tailwind-v4, tailwind-v3 (preset), flutter, swiftui, compose, figma (Tokens Studio), plain-css (full rc-* component stylesheet).",
|
|
39
|
+
inputSchema: { format: z.enum(TOKEN_FORMATS).describe("Output format") },
|
|
40
|
+
}, async ({ format }) => {
|
|
41
|
+
const v = data.tokens[format];
|
|
42
|
+
if (!v) return text(`Format ${format} is not available in this build.`);
|
|
43
|
+
return text(typeof v === "string" ? v : JSON.stringify(v, null, 2));
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
server.registerTool("list_components", {
|
|
47
|
+
title: "List components",
|
|
48
|
+
description: "All @recanica/ui React components with category, description and import path.",
|
|
49
|
+
inputSchema: { category: z.string().optional().describe("Filter by category, e.g. Forms, Overlays") },
|
|
50
|
+
}, async ({ category }) => {
|
|
51
|
+
const list = data.components.filter((c) => !category || c.category.toLowerCase() === category.toLowerCase());
|
|
52
|
+
return text(list.map((c) => `- ${c.slug} (${c.category}): ${c.description} import from "${c.import}"`).join("\n"));
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
server.registerTool("get_component", {
|
|
56
|
+
title: "Get component",
|
|
57
|
+
description: "Source code and a usage example for one @recanica/ui component.",
|
|
58
|
+
inputSchema: { name: z.string().describe("Component slug, e.g. button, dialog, stat, data-table is a pattern") },
|
|
59
|
+
}, async ({ name }) => {
|
|
60
|
+
const c = data.components.find((x) => x.slug === name.toLowerCase() || x.title.toLowerCase() === name.toLowerCase());
|
|
61
|
+
if (!c) return text(`No component "${name}". Use list_components or search.`);
|
|
62
|
+
return text([`# ${c.title}`, c.description, `Import: \`${c.import}\``, "## Example", fence("tsx", c.example ?? "(none)"), "## Source", fence("tsx", c.source ?? "(source not bundled)")].join("\n\n"));
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
server.registerTool("list_patterns", {
|
|
66
|
+
title: "List patterns, blocks and web sections",
|
|
67
|
+
description: "App patterns (data table, list/detail, settings, auth…), app blocks (shell, invoices) and the web library (49 website sections in 42 categories: headers, heroes, blog, shop, property, careers, events, utility pages). Includes when-to-use notes.",
|
|
68
|
+
inputSchema: { kind: z.enum(["pattern", "block", "web", "all"]).default("all"), category: z.string().optional().describe("e.g. Hero, Pricing, Single product") },
|
|
69
|
+
}, async ({ kind, category }) => {
|
|
70
|
+
const list = data.patterns.filter((p) => (kind === "all" || p.kind === kind) && (!category || p.category.toLowerCase() === category.toLowerCase()));
|
|
71
|
+
return text(list.map((p) => `- ${p.slug} [${p.kind}/${p.category}]: ${p.description}${p.use ? ` When: ${p.use}` : ""}`).join("\n") || "No matches.");
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
server.registerTool("get_recipe", {
|
|
75
|
+
title: "Website page recipes",
|
|
76
|
+
description: "Ordered section lists for common website pages (SaaS landing, lead-gen, about, blog, shop, product, checkout, property, events, careers, contact, 404…). Use this to compose a page from web sections.",
|
|
77
|
+
inputSchema: { page: z.string().optional().describe("Page type, e.g. 'landing', 'product page'. Empty lists all.") },
|
|
78
|
+
}, async ({ page }) => {
|
|
79
|
+
const list = data.webRecipes.filter((r) => !page || r.page.toLowerCase().includes(page.toLowerCase()));
|
|
80
|
+
return text(list.map((r) => `## ${r.page}\n${r.sections.map((s, i) => `${i + 1}. ${s}`).join("\n")}${r.notes ? `\nNotes: ${r.notes}` : ""}`).join("\n\n") || "No recipe matches. Call without arguments to list all.");
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
server.registerTool("get_page_library", {
|
|
84
|
+
title: "Dashboard / portal page library",
|
|
85
|
+
description: "Common dashboard and customer-portal page types (auth, overview, reports, tables, detail, forms, settings, team & roles, notifications, audit log, developers, integrations, tasks, calendar, files, support, empty states, customer portal) and which Recanica patterns/components implement each.",
|
|
86
|
+
inputSchema: {},
|
|
87
|
+
}, async () => text(data.appLibrary.map((c) => `## ${c.category}\n${c.description}\n${c.items.map((i) => `- ${i.kind}: ${i.label} (${data.site}${i.href})`).join("\n")}`).join("\n\n")));
|
|
88
|
+
|
|
89
|
+
server.registerTool("get_page_anatomy", {
|
|
90
|
+
title: "How a page is built",
|
|
91
|
+
description: "For a page type (overview, list, detail, form, settings, sign-in, checkout, landing, article, docs): its shell, its regions in reading order and the exact part for each, plus the parts table (React component + rc-* class). Call before building any page.",
|
|
92
|
+
inputSchema: { type: z.string().optional().describe("Page type, e.g. 'list' or 'checkout'. Omit for all types.") },
|
|
93
|
+
}, async ({ type }) => {
|
|
94
|
+
const a = data.anatomy;
|
|
95
|
+
const types = type ? a.types.filter((t) => t.type.toLowerCase().includes(type.toLowerCase())) : a.types;
|
|
96
|
+
const out = [
|
|
97
|
+
"# Page anatomy", "", ...a.thinking, "",
|
|
98
|
+
...types.flatMap((t) => [`## ${t.type}`, t.use, `Shell: ${t.shell}`, ...t.regions.map((r) => `- ${r.region}: ${r.part}${r.note ? ` (${r.note})` : ""}`), ""]),
|
|
99
|
+
"## Parts (React · CSS)", ...data.parts.map((p) => `- ${p.part}: ${p.react} · .${p.css}`),
|
|
100
|
+
];
|
|
101
|
+
return { content: [{ type: "text", text: out.join("\n") }] };
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
server.registerTool("get_pattern", {
|
|
105
|
+
title: "Get pattern or block",
|
|
106
|
+
description: "Full source of a pattern or block, plus its install command. Adapt it rather than starting from scratch.",
|
|
107
|
+
inputSchema: { name: z.string().describe("Slug, e.g. data-table, invoices-01, hero-01") },
|
|
108
|
+
}, async ({ name }) => {
|
|
109
|
+
const p = data.patterns.find((x) => x.slug === name.toLowerCase());
|
|
110
|
+
if (!p) return text(`No pattern or block "${name}". Use list_patterns or search.`);
|
|
111
|
+
return text([`# ${p.title} (${p.kind})`, p.description, `Install: \`${p.install}\``, fence("tsx", p.source)].join("\n\n"));
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
server.registerTool("search", {
|
|
115
|
+
title: "Search Recanica",
|
|
116
|
+
description: "Keyword search across components, patterns, blocks and guides.",
|
|
117
|
+
inputSchema: { query: z.string() },
|
|
118
|
+
}, async ({ query }) => {
|
|
119
|
+
const q = query.toLowerCase().split(/\s+/).filter(Boolean);
|
|
120
|
+
const score = (s) => q.reduce((n, w) => n + (s.toLowerCase().includes(w) ? 1 : 0), 0);
|
|
121
|
+
const hits = [
|
|
122
|
+
...data.components.map((c) => ({ s: score(`${c.slug} ${c.title} ${c.description} ${c.category}`) * 2, line: `component ${c.slug}: ${c.description}` })),
|
|
123
|
+
...data.patterns.map((p) => ({ s: score(`${p.slug} ${p.title} ${p.description} ${p.category} ${p.use ?? ""}`) * 2, line: `${p.kind} ${p.slug}: ${p.description}` })),
|
|
124
|
+
...data.webRecipes.map((r) => ({ s: score(`${r.page} ${r.notes}`) * 2, line: `recipe "${r.page}": ${r.sections.join(" → ")}` })),
|
|
125
|
+
...Object.entries(data.guides).map(([k, v]) => ({ s: score(v), line: `guide ${k}` })),
|
|
126
|
+
].filter((h) => h.s > 0).sort((a, b) => b.s - a.s).slice(0, 15);
|
|
127
|
+
return text(hits.length ? hits.map((h) => `- ${h.line}`).join("\n") : "No matches.");
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
server.registerTool("get_setup", {
|
|
131
|
+
title: "Setup guide",
|
|
132
|
+
description: `How to install Recanica in a project. Stacks: ${Object.keys(STACKS).join(", ")}, ai.`,
|
|
133
|
+
inputSchema: { stack: z.enum([...Object.keys(STACKS), "ai", "overview"]) },
|
|
134
|
+
}, async ({ stack }) => {
|
|
135
|
+
const key = stack === "overview" ? "README" : stack === "ai" ? "ai" : STACKS[stack];
|
|
136
|
+
return text(data.guides[key] ?? `No guide for ${stack}.`);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
server.registerTool("get_kickoff_questions", {
|
|
140
|
+
title: "Kickoff questionnaire",
|
|
141
|
+
description: "The plain-language questions to ask the person at the start of every new project (who is building it, what it is, how it is built, how strict, when a page is done), each with fixed options. Ask them in these exact words, one group at a time, offer only the given options (never invent people or teams), then save the answers as JSON and run `npx recanica kickoff --answers <file>`.",
|
|
142
|
+
inputSchema: {},
|
|
143
|
+
}, async () => text([data.kickoffHowToAsk ?? "", ...(data.kickoff ?? []).map((q) => `\n- ${q.id} [${q.group}] ${q.q}${q.askIf ? ` (ask only if ${q.askIf})` : ""}\n why: ${q.why}${q.example ? `\n e.g. ${q.example}` : ""}${(q.options ?? []).map((o) => `\n · ${o.label}${o.free ? "" : ` → ${JSON.stringify(o.value)}`}`).join("")}\n default: ${JSON.stringify(q.default)}`)].join("\n")));
|
|
144
|
+
|
|
145
|
+
server.registerTool("check_copy", {
|
|
146
|
+
title: "Check copy for AI slop",
|
|
147
|
+
description: "Check a piece of UI copy (headline, button, empty state, PR text, decision entry) against Recanica's copy rules: AI jargon, hype, assistant voice, placeholder text. Run it on your own words before writing them.",
|
|
148
|
+
inputSchema: { text: z.string().describe("The copy to check") },
|
|
149
|
+
}, async ({ text: t }) => {
|
|
150
|
+
const hits = [];
|
|
151
|
+
for (const [src, flags, msg, level] of data.copyRules ?? []) { const m = t.match(new RegExp(src, flags)); if (m) hits.push(`${level === "error" ? "must-fix" : "should"}: "${m[0]}" ${msg}`); }
|
|
152
|
+
return text(hits.length ? hits.join("\n") : "No slop found. (This finds generic phrasing; it can't judge whether the copy is specific to the reader.)");
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
server.registerPrompt("apply-recanica", {
|
|
156
|
+
title: "Apply Recanica to this project",
|
|
157
|
+
description: "Adopt Recanica in an existing project: review busy pages, agree a rework plan, rebuild pages from Recanica patterns (not a reskin).",
|
|
158
|
+
argsSchema: {
|
|
159
|
+
stack: z.string().optional().describe("Known stack, e.g. nextjs, flutter. Leave empty to detect."),
|
|
160
|
+
mode: z.enum(["rework", "reskin"]).optional().describe("rework (default): restructure pages. reskin: tokens and colours only."),
|
|
161
|
+
},
|
|
162
|
+
}, ({ stack, mode }) => ({
|
|
163
|
+
messages: [{
|
|
164
|
+
role: "user",
|
|
165
|
+
content: {
|
|
166
|
+
type: "text",
|
|
167
|
+
text: (mode === "reskin" ? [
|
|
168
|
+
"Reskin this project with Recanica tokens only (colours, type, radius). Keep layouts and behaviour.",
|
|
169
|
+
stack ? `The stack is ${stack}.` : "First tell me the stack and where global styles live.",
|
|
170
|
+
"Install tokens (call get_setup), restyle shared components, run `npx recanica check`, list changed files.",
|
|
171
|
+
] : [
|
|
172
|
+
"Adopt Recanica in this project. This is a REWORK, not a reskin: pages should end up calmer and simpler, not just recoloured.",
|
|
173
|
+
stack ? `The stack is ${stack}.` : "First tell me the stack, styling approach and where global styles live.",
|
|
174
|
+
"1. Install tokens and components for this stack (call get_setup).",
|
|
175
|
+
"2. Start the dev server and run `npx recanica review <url> --crawl`. Read recanica-review.md.",
|
|
176
|
+
"3. For each page, busiest first: tell me what the page is for, the one action that matters, what you would keep, change, merge or remove, and which Recanica pattern it becomes (call get_page_library / get_pattern). Wait for my answer before changing that page.",
|
|
177
|
+
"4. Rebuild agreed pages from the pattern with Recanica components. Don't restyle the old markup. Remove what we agreed to remove.",
|
|
178
|
+
"5. After each page: `npx recanica review` (no busy signals), `npx recanica check`, `npx recanica audit`. Show me the before/after list of what changed.",
|
|
179
|
+
]).concat(["", "Follow these rules exactly:", "", data.rules]).join("\n"),
|
|
180
|
+
},
|
|
181
|
+
}],
|
|
182
|
+
}));
|
|
183
|
+
|
|
184
|
+
server.registerPrompt("recanica-page", {
|
|
185
|
+
title: "Design or explain a page the Recanica way",
|
|
186
|
+
description: "Write a page brief (purpose, reader, their questions in order, structure, alternatives rejected) before building; check the rendered page; or explain why an existing page is laid out as it is.",
|
|
187
|
+
argsSchema: {
|
|
188
|
+
route: z.string().describe("The page route, e.g. /dashboard/invoices"),
|
|
189
|
+
mode: z.enum(["build", "explain"]).optional().describe("build (default): new page, redesign or rework. explain: reconstruct the reasoning of an existing page."),
|
|
190
|
+
},
|
|
191
|
+
}, ({ route, mode }) => ({
|
|
192
|
+
messages: [{
|
|
193
|
+
role: "user",
|
|
194
|
+
content: {
|
|
195
|
+
type: "text",
|
|
196
|
+
text: [
|
|
197
|
+
mode === "explain"
|
|
198
|
+
? `Explain the page ${route}: follow step E of the skill below. Be honest where the reasoning is weak.`
|
|
199
|
+
: `Design the page ${route}: follow steps 1–6 of the skill below. Write the brief and show it to me before building.`,
|
|
200
|
+
"Brief template:",
|
|
201
|
+
"",
|
|
202
|
+
data.skills["recanica-page"]["brief-template.md"],
|
|
203
|
+
"",
|
|
204
|
+
data.skills["recanica-page"]["SKILL.md"],
|
|
205
|
+
"",
|
|
206
|
+
"Recanica rules:",
|
|
207
|
+
data.rules,
|
|
208
|
+
].join("\n"),
|
|
209
|
+
},
|
|
210
|
+
}],
|
|
211
|
+
}));
|
|
212
|
+
|
|
213
|
+
await server.connect(new StdioServerTransport());
|