@decantr/mcp-server 2.2.0 → 2.4.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/README.md +9 -3
- package/dist/bin.js +1 -1
- package/dist/{chunk-SVLMT45O.js → chunk-P2K3R43N.js} +131 -0
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ Design intelligence for AI-generated UI. Make Claude, Cursor, and Windsurf gener
|
|
|
12
12
|
|
|
13
13
|

|
|
14
14
|
|
|
15
|
-
- **Structured design context** -- gives your AI assistant patterns, layouts, component specs, and
|
|
15
|
+
- **Structured design context** -- gives your AI assistant patterns, layouts, component specs, Brownfield/Hybrid authority, local law, and task-time context instead of letting it guess
|
|
16
16
|
- **Evidence-backed repair loops** -- gives AI agents Project Health, Evidence Bundles, workspace health, and scoped repair prompts without uploading source
|
|
17
17
|
- **Drift detection** -- catches when generated code deviates from your design intent
|
|
18
18
|
- **Zero config** -- run with `npx`, no API keys or accounts required
|
|
@@ -136,7 +136,7 @@ The server exposes Decantr registry, context, benchmark, and verification tools.
|
|
|
136
136
|
| `decantr_suggest_patterns` | Given a page description plus optional route/source excerpt, get ranked pattern suggestions | `{ "description": "recipe feed with avatars and infinite scroll", "route": "/feed" }` |
|
|
137
137
|
| `decantr_check_drift` | Check if generated code violates the design intent in the Essence spec | `{ "page_id": "overview", "components_used": ["Card", "LineChart"], "theme_used": "auradecantism" }` |
|
|
138
138
|
| `decantr_get_execution_pack` | Read compiled scaffold, section, page, review, or mutation execution packs, with hosted fallback when local context is missing | `{ "pack_type": "page", "id": "overview", "format": "json" }` |
|
|
139
|
-
| `decantr_prepare_task_context` | Resolve compact route/task context before editing a Brownfield or Essence route | `{ "route": "/feed", "task": "improve recipe card loading" }` |
|
|
139
|
+
| `decantr_prepare_task_context` | Resolve compact route/task context, authority lane, local law, evidence, and changed-file impact before editing a Brownfield, Hybrid, or Essence route | `{ "route": "/feed", "task": "improve recipe card loading" }` |
|
|
140
140
|
| `decantr_compile_execution_packs` | Compile a hosted execution-pack bundle from a local or inline essence document | `{ "path": "./decantr.essence.json", "namespace": "@official" }` |
|
|
141
141
|
| `decantr_audit_project` | Run the schema-backed Decantr project audit against essence and compiled packs, with hosted fallback when local pack artifacts are missing | `{ "namespace": "@official" }` |
|
|
142
142
|
| `decantr_critique` | Critique a file against the compiled review contract, with hosted fallback when local review packs are missing | `{ "file_path": "./src/pages/Overview.tsx", "namespace": "@official" }` |
|
|
@@ -148,6 +148,12 @@ The server exposes Decantr registry, context, benchmark, and verification tools.
|
|
|
148
148
|
|
|
149
149
|
For the broader product surface and support policy, see the root Decantr docs and package support matrix.
|
|
150
150
|
|
|
151
|
+
## Security And Permissions
|
|
152
|
+
|
|
153
|
+
The MCP server reads Decantr files and selected project files from the active workspace. Write access is limited to explicit write tools such as `decantr_update_essence` and `decantr_accept_drift`, and paths are contained to the active workspace root.
|
|
154
|
+
|
|
155
|
+
Registry and pack-resolution tools may call the configured Decantr API. Source upload fallbacks for hosted critique/audit are disabled unless the tool call explicitly passes `allow_hosted_upload: true`. The MCP server does not emit Decantr telemetry. See [security permissions](https://decantr.ai/reference/security-permissions.md).
|
|
156
|
+
|
|
151
157
|
## Compatibility
|
|
152
158
|
|
|
153
159
|
`@decantr/mcp-server` is stable in the `2.x` line for the documented MCP tool surface.
|
|
@@ -171,7 +177,7 @@ The AI assistant calls these tools behind the scenes:
|
|
|
171
177
|
3. `decantr_suggest_patterns` -- recommends `kpi-grid`, `chart-grid`, `data-table`, and `form-sections` for the described pages
|
|
172
178
|
4. `decantr_resolve_pattern` -- fetches layout specs and component lists for each pattern
|
|
173
179
|
5. `decantr_get_execution_pack` -- loads the compiled scaffold/page/review packs as the task contract, falling back to hosted compilation when local pack artifacts are missing
|
|
174
|
-
6. `decantr_prepare_task_context` -- resolves route-local Brownfield context, visual evidence, and theme inventory before editing an existing app
|
|
180
|
+
6. `decantr_prepare_task_context` -- resolves route-local Brownfield/Hybrid context, active authority, accepted local law, changed-file impact, visual evidence, and theme inventory before editing an existing app
|
|
175
181
|
7. `decantr_compile_execution_packs` -- compiles the hosted pack bundle when the task needs a fresh remote contract from the essence document
|
|
176
182
|
8. `decantr_check_drift` -- validates the generated code against the Essence spec before presenting it
|
|
177
183
|
9. `decantr_critique` -- critiques a specific file, falling back to the hosted verifier when the local review pack is missing
|
package/dist/bin.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import "./chunk-
|
|
2
|
+
import "./chunk-P2K3R43N.js";
|
|
@@ -4,6 +4,7 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
|
|
|
4
4
|
import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
5
5
|
|
|
6
6
|
// src/tools.ts
|
|
7
|
+
import { execFileSync } from "child_process";
|
|
7
8
|
import { existsSync, readdirSync, readFileSync } from "fs";
|
|
8
9
|
import { readFile as readFile2 } from "fs/promises";
|
|
9
10
|
import { basename as basename2, dirname as dirname2, join as join2, relative as relative2 } from "path";
|
|
@@ -137,6 +138,116 @@ function readJsonIfExists(path) {
|
|
|
137
138
|
return null;
|
|
138
139
|
}
|
|
139
140
|
}
|
|
141
|
+
function changedFilesForTask(projectRoot) {
|
|
142
|
+
const changed = /* @__PURE__ */ new Set();
|
|
143
|
+
try {
|
|
144
|
+
for (const args of [
|
|
145
|
+
["diff", "--name-only"],
|
|
146
|
+
["diff", "--name-only", "--cached"]
|
|
147
|
+
]) {
|
|
148
|
+
const output = execFileSync("git", args, {
|
|
149
|
+
cwd: projectRoot,
|
|
150
|
+
encoding: "utf-8",
|
|
151
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
152
|
+
});
|
|
153
|
+
for (const entry of output.split(/\r?\n/)) {
|
|
154
|
+
const file = entry.trim();
|
|
155
|
+
if (file) changed.add(file);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
} catch {
|
|
159
|
+
}
|
|
160
|
+
return [...changed].sort();
|
|
161
|
+
}
|
|
162
|
+
function impactedRoutesForFiles(projectRoot, files) {
|
|
163
|
+
const analysis = readJsonIfExists(join2(projectRoot, ".decantr", "analysis.json"));
|
|
164
|
+
const routeEntries = analysis?.routes?.routes ?? [];
|
|
165
|
+
const impacted = /* @__PURE__ */ new Set();
|
|
166
|
+
for (const file of files) {
|
|
167
|
+
for (const route of routeEntries) {
|
|
168
|
+
if (route.file && (file === route.file || file.endsWith(route.file))) {
|
|
169
|
+
if (route.path) impacted.add(route.path);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return [...impacted].sort();
|
|
174
|
+
}
|
|
175
|
+
function localLawSummary(projectRoot) {
|
|
176
|
+
const patterns = readJsonIfExists(join2(projectRoot, ".decantr", "local-patterns.json"));
|
|
177
|
+
const rules = readJsonIfExists(join2(projectRoot, ".decantr", "rules.json"));
|
|
178
|
+
return {
|
|
179
|
+
patterns_path: patterns ? ".decantr/local-patterns.json" : null,
|
|
180
|
+
rules_path: rules ? ".decantr/rules.json" : null,
|
|
181
|
+
patterns: patterns?.patterns?.map((pattern) => ({
|
|
182
|
+
id: pattern.id ?? "unknown",
|
|
183
|
+
role: pattern.role ?? null,
|
|
184
|
+
component_paths: pattern.componentPaths ?? []
|
|
185
|
+
})) ?? [],
|
|
186
|
+
rules: rules?.rules?.map((rule) => ({
|
|
187
|
+
id: rule.id ?? "unknown",
|
|
188
|
+
enabled: rule.enabled ?? false,
|
|
189
|
+
severity: rule.severity ?? "warn",
|
|
190
|
+
description: rule.description ?? null
|
|
191
|
+
})) ?? []
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
function mentionsWord(text, term) {
|
|
195
|
+
const escaped = term.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
196
|
+
return new RegExp(`\\b${escaped}\\b`, "i").test(text);
|
|
197
|
+
}
|
|
198
|
+
function taskAuthoritySummary(input) {
|
|
199
|
+
const hasLocalLaw = input.localLaw.patterns.length > 0 || input.localLaw.rules.length > 0;
|
|
200
|
+
let lane = "Brownfield contract-only";
|
|
201
|
+
let sourceAuthority = "Existing app is authoritative; Decantr supplies contract context.";
|
|
202
|
+
let styleAuthority = "Use the existing styling system.";
|
|
203
|
+
const activeAuthorities = ["existing source", "Essence V4 contract"];
|
|
204
|
+
if (input.workflowMode === "hybrid-compose") {
|
|
205
|
+
lane = "Hybrid composition";
|
|
206
|
+
sourceAuthority = "Existing app plus selected Decantr/local law are authoritative.";
|
|
207
|
+
} else if (input.workflowMode === "brownfield-attach" && input.adoptionMode === "decantr-css") {
|
|
208
|
+
lane = "Hybrid with Decantr CSS";
|
|
209
|
+
sourceAuthority = "Existing app remains authoritative except where Decantr CSS is explicitly adopted.";
|
|
210
|
+
styleAuthority = "Decantr CSS runtime is active where adopted.";
|
|
211
|
+
activeAuthorities.push("Decantr CSS runtime");
|
|
212
|
+
} else if (input.workflowMode === "brownfield-attach" && input.adoptionMode === "style-bridge") {
|
|
213
|
+
lane = "Hybrid style bridge";
|
|
214
|
+
sourceAuthority = "Existing app remains authoritative; Decantr intent maps through the style bridge.";
|
|
215
|
+
styleAuthority = "Use bridge tokens/classes as a mapping layer onto the app styling system.";
|
|
216
|
+
activeAuthorities.push("style bridge");
|
|
217
|
+
} else if (input.workflowMode === "brownfield-attach" && hasLocalLaw) {
|
|
218
|
+
lane = "Hybrid local law";
|
|
219
|
+
sourceAuthority = "Existing app plus accepted project-owned UI law are authoritative.";
|
|
220
|
+
styleAuthority = "Use project-owned components, tokens, classes, and accepted local rules.";
|
|
221
|
+
} else if (input.workflowMode?.startsWith("greenfield")) {
|
|
222
|
+
lane = input.workflowMode === "greenfield-contract-only" ? "Greenfield contract-only" : "Greenfield scaffold";
|
|
223
|
+
sourceAuthority = "Essence V4 and generated context are authoritative.";
|
|
224
|
+
styleAuthority = input.adoptionMode === "contract-only" ? "Use the project-chosen styling system." : "Use Decantr CSS where generated by the adapter.";
|
|
225
|
+
}
|
|
226
|
+
if (hasLocalLaw) activeAuthorities.push("accepted local patterns/rules");
|
|
227
|
+
if (input.hasPackManifest) activeAuthorities.push("hosted execution packs as guidance");
|
|
228
|
+
const warnings = [];
|
|
229
|
+
const task = input.task;
|
|
230
|
+
for (const term of ["angular", "vue", "svelte", "solid", "bootstrap", "shadcn"]) {
|
|
231
|
+
if (mentionsWord(task, term)) {
|
|
232
|
+
warnings.push(
|
|
233
|
+
`Task mentions ${term}; treat it as optional Hybrid guidance unless this workspace already owns that runtime/library or the user explicitly asks for a reviewed adoption plan.`
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
if (input.adoptionMode !== "decantr-css" && (/@decantr\/css/i.test(task) || /\bdecantr css\b/i.test(task) || /\bd-[a-z0-9-]+/i.test(task))) {
|
|
238
|
+
warnings.push(
|
|
239
|
+
"This project is not in decantr-css adoption mode. Do not add @decantr/css or d-* classes unless the user explicitly changes adoption mode."
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
return {
|
|
243
|
+
lane,
|
|
244
|
+
source_authority: sourceAuthority,
|
|
245
|
+
style_authority: styleAuthority,
|
|
246
|
+
active_authorities: activeAuthorities,
|
|
247
|
+
runtime_boundary: "Preserve the current workspace runtime unless the task is explicitly a reviewed migration or isolated integration plan.",
|
|
248
|
+
warnings
|
|
249
|
+
};
|
|
250
|
+
}
|
|
140
251
|
function extractPatternIdsFromLayoutItem(item, ids) {
|
|
141
252
|
if (typeof item === "string") {
|
|
142
253
|
ids.add(item);
|
|
@@ -2371,6 +2482,10 @@ async function handleTool(name, args) {
|
|
|
2371
2482
|
const themeInventory = readJsonIfExists(
|
|
2372
2483
|
join2(process.cwd(), ".decantr", "theme-inventory.json")
|
|
2373
2484
|
);
|
|
2485
|
+
const localLaw = localLawSummary(process.cwd());
|
|
2486
|
+
const projectJson = readJsonIfExists(join2(process.cwd(), ".decantr", "project.json"));
|
|
2487
|
+
const changedFiles = changedFilesForTask(process.cwd());
|
|
2488
|
+
const changedRoutes = impactedRoutesForFiles(process.cwd(), changedFiles);
|
|
2374
2489
|
const patternIds = extractPagePatternIds(page);
|
|
2375
2490
|
const ranked = rankPatternCandidates(
|
|
2376
2491
|
{
|
|
@@ -2419,10 +2534,26 @@ async function handleTool(name, args) {
|
|
|
2419
2534
|
variants: themeInventory.variants,
|
|
2420
2535
|
path: ".decantr/theme-inventory.json"
|
|
2421
2536
|
} : null,
|
|
2537
|
+
local_law: localLaw,
|
|
2538
|
+
authority: taskAuthoritySummary({
|
|
2539
|
+
workflowMode: projectJson?.initialized?.workflowMode ?? null,
|
|
2540
|
+
adoptionMode: projectJson?.initialized?.adoptionMode ?? null,
|
|
2541
|
+
localLaw,
|
|
2542
|
+
hasPackManifest: Boolean(manifest),
|
|
2543
|
+
task
|
|
2544
|
+
}),
|
|
2545
|
+
change_impact: {
|
|
2546
|
+
changed_files: changedFiles.slice(0, 40),
|
|
2547
|
+
changed_file_count: changedFiles.length,
|
|
2548
|
+
impacted_routes: changedRoutes
|
|
2549
|
+
},
|
|
2550
|
+
verify_command: "decantr verify --brownfield --local-patterns",
|
|
2422
2551
|
local_files: {
|
|
2423
2552
|
page_pack: pageManifest?.markdown ?? null,
|
|
2424
2553
|
section_pack: sectionManifest?.markdown ?? null,
|
|
2425
2554
|
section_context: existsSync(sectionContextPath) ? `.decantr/context/section-${section.id}.md` : null,
|
|
2555
|
+
local_patterns: localLaw.patterns_path,
|
|
2556
|
+
local_rules: localLaw.rules_path,
|
|
2426
2557
|
visual_manifest: existsSync(
|
|
2427
2558
|
join2(process.cwd(), ".decantr", "evidence", "visual-manifest.json")
|
|
2428
2559
|
) ? ".decantr/evidence/visual-manifest.json" : null
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import "./chunk-
|
|
1
|
+
import "./chunk-P2K3R43N.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decantr/mcp-server",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"mcpName": "io.github.decantr-ai/mcp-server",
|
|
5
5
|
"description": "MCP server for Decantr — exposes design intelligence, packs, and verification to AI coding assistants",
|
|
6
6
|
"keywords": [
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
52
52
|
"@decantr/essence-spec": "2.0.1",
|
|
53
|
-
"@decantr/verifier": "2.
|
|
53
|
+
"@decantr/verifier": "2.3.3",
|
|
54
54
|
"@decantr/registry": "2.2.0"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|