@db-ux/mcp-server 4.7.3 → 4.8.1-fix-publish-f7808e2

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 CHANGED
@@ -91,22 +91,53 @@ This will copy the correct rules for DB UX component usage and design token refe
91
91
  - **Check Status:** Look for a green indicator or "db-ux" in your IDE's MCP server list.
92
92
  - **Check Logs:** If it doesn't appear, check the MCP output logs in your IDE (e.g., in VS Code: _Output Panel_ → _MCP_ or _MCP Servers_).
93
93
 
94
+ ### 5. Optimize Amazon Q for this Project (Recommended)
95
+
96
+ Amazon Q can automatically load the project's `CONTEXT.md` as a persistent system prompt ("Rules") for every session. This means the agent **already knows** the MCP server architecture, all available tools, design token sources, migration workflows, and the v3 component API — without any manual onboarding or repeated context-setting by the developer.
97
+
98
+ **Why this matters:**
99
+
100
+ - ✅ Eliminates hallucinations about component names, prop signatures, and token values
101
+ - ✅ The agent follows the correct 6-step migration workflow from the first message
102
+ - ✅ New team members get a fully context-aware AI assistant on day one
103
+
104
+ **Setup:**
105
+
106
+ 1. Open (or create) the file `~/.aws/amazonq/agents/default.json`
107
+ 2. Add the following configuration:
108
+
109
+ ```json
110
+ {
111
+ "agentInstruction": {
112
+ "paths": ["CONTEXT.md"]
113
+ }
114
+ }
115
+ ```
116
+
117
+ 3. Place the `CONTEXT.md` file in your project root (it ships with `@db-ux/mcp-server` and is copied by `npx @db-ux/agent-cli`)
118
+
119
+ > **Note:** The path is resolved relative to the workspace root. Amazon Q / Kiro will read this file at the start of every session and inject it as system-level context for the agent.
120
+
94
121
  ---
95
122
 
96
123
  ## 🛠 Available AI Tools (Skills)
97
124
 
98
- | Tool | Description |
99
- | ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
100
- | `list_components` | Returns all available DB UX component names (e.g. `button`, `input`, `tag`). Call this first to confirm a component exists before using it. |
101
- | `get_component_props` | Returns the raw TypeScript `model.ts` for a component — all interfaces, prop types, and JSDoc comments. |
102
- | `get_component_details` | Returns the list of available example names for a component (e.g. `"Variant"`, `"Show Icon Leading"`). |
103
- | `get_example_code` | Fetches the exact generated source code for a component example in a specific framework (`react`, `angular`, `vue`, `web-components`, or `html`). This is the code the AI adapts — not invents. |
104
- | `get_design_tokens` | Returns CSS custom properties (`--db-*`) and SCSS variables (`$db-*`) for a token category (`colors`, `spacing`, `typography`, …). Prevents hardcoded hex values and magic numbers. |
105
- | `list_design_token_categories` | Lists all available token categories to pass to `get_design_tokens`. |
106
- | `list_icons` | Returns all valid DB UX icon names (e.g. `arrow_down`, `chevron_right`, `x_placeholder`). Always call this before using any `icon` prop — never guess a name. |
107
- | `docs_search` | Searches the DB UX conceptual documentation (guidelines, A11y, migration, ADRs) or component-specific markdown docs. Acts as our Retrieval-Augmented Generation (RAG) engine. |
108
- | `list_migration_guides` | Returns all available migration guide names (e.g. `db-ui-color-migration`, `db-ui-component-migration`). Call this first before any migration task. |
109
- | `get_migration_guide` | Returns the full markdown content of a specific migration guide. Use this to load official package renames, prop changes, and component workarounds before refactoring legacy code. |
125
+ | Tool | Description |
126
+ | ------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
127
+ | `list_components` | Returns all available DB UX component names (e.g. `button`, `input`, `tag`). Call this first to confirm a component exists before using it. |
128
+ | `get_component_props` | Returns the raw TypeScript `model.ts` for a component — all interfaces, prop types, and JSDoc comments. |
129
+ | `get_component_details` | Returns the list of available example names for a component (e.g. `"Variant"`, `"Show Icon Leading"`). |
130
+ | `get_example_code` | Fetches the exact generated source code for a component example in a specific framework (`react`, `angular`, `vue`, `web-components`, or `html`). This is the code the AI adapts — not invents. |
131
+ | `get_design_tokens` | Returns CSS custom properties (`--db-*`) for a token category (`colors`, `spacing`, `typography`, `elevation`, `density`, …). Reads from a structured `tokens.json` generated at build time with concrete primitive values (e.g. `0.75rem`, box-shadow strings). Falls back to SCSS from the manifest for categories not in JSON (e.g. animation, transitions). Prevents hardcoded hex values and magic numbers. |
132
+ | `list_design_token_categories` | Lists all available token categories to pass to `get_design_tokens`. |
133
+ | `list_icons` | Returns all valid DB UX icon names (e.g. `arrow_down`, `chevron_right`, `x_placeholder`). Always call this before using any `icon` prop — never guess a name. |
134
+ | `docs_search` | Searches the DB UX conceptual documentation (guidelines, Accessibility, migration, ADRs) or component-specific markdown docs. Acts as our Retrieval-Augmented Generation (RAG) engine. |
135
+ | `list_migration_guides` | Returns all available migration guide names (e.g. `color-migration`, `component-migration`). Call this first before any migration task. |
136
+ | `get_migration_guide` | Returns the full markdown content of a specific migration guide. Use this to load official package renames, prop changes, and component workarounds before refactoring legacy code. |
137
+ | `verify_migrated_code` | Instructs the AI to verify its changes using the project's own scripts (`typecheck`, `lint`, `build`) from `package.json`. No temp files or hardcoded compilers — works with any toolchain (JS, TS, Vite, Angular CLI). |
138
+ | `scan_v2_migration` | **Call FIRST when migrating a file.** Scans a source file for DB UI v2 patterns (v2 CSS classes (`cmp-*`, `elm-*`, `rea-*`) and v2 Web Components (`<db-*>`), `db-color-*` tokens, legacy icon names) and returns a JSON report with exact line numbers and deterministic migration suggestions from the official guides. No LLM guessing needed. |
139
+ | `list_visuals` | Returns all available visual reference names (e.g. `dashboard`, `form`, `table`). Call this to discover which visuals exist before requesting one. |
140
+ | `get_visual_reference` | Returns a pre-optimised static visual reference image (JPEG) as a Base64-encoded MCP image block. No build-time or runtime image processing dependencies — images are committed as pre-optimised assets. |
110
141
 
111
142
  ### Example: fetching a React button example
112
143
 
@@ -117,6 +148,7 @@ get_component_details → lists ["Density", "Variant", "Show Icon Leading", .
117
148
  get_example_code → returns show-icon-leading.example.tsx source
118
149
  list_icons → confirms "arrow_right" is a valid icon name
119
150
  get_design_tokens → returns --db-spacing-fixed-md for layout
151
+ verify_migrated_code → instructs AI to run project's own typecheck/lint/build scripts
120
152
  ```
121
153
 
122
154
  ---
@@ -141,10 +173,76 @@ Performs a strict multi-layered QA, accessibility, and DB UX compliance audit on
141
173
 
142
174
  ### `migrate_component` (Legacy Refactoring)
143
175
 
144
- Transforms legacy UI code (e.g., Bootstrap, native HTML, DB UI v1/v2) into the modern DB UX v3/v4 architecture.
176
+ Transforms legacy UI code (e.g., Bootstrap, native HTML, DB UI v1/v2) into the modern DB UX v3 architecture. This is the most complex prompt — it orchestrates **10 different MCP tools** across 5 mandatory steps, including a verification loop.
177
+
178
+ **Parameters:**
179
+
180
+ | Parameter | Required | Description |
181
+ | ------------------ | -------- | ---------------------------------------------------------------------------------------------------------------------- |
182
+ | `legacy_code` | Yes | The outdated source code to migrate (DB UI, Bootstrap, raw HTML/CSS). Max 10,000 chars |
183
+ | `source_context` | Yes | Origin of the legacy code: `db-ui-v1`, `db-ui-v2`, `db-ux-v1`, `db-ux-v2`, `db-ux-v3`, `bootstrap-4`, or `native-html` |
184
+ | `target_framework` | Yes | Target framework: `react`, `angular`, `vue`, `web-components`, or `html` |
185
+
186
+ **Full workflow (5 mandatory steps):**
187
+
188
+ ```text
189
+ ┌──────────────────────────────────────────────────────────────────┐
190
+ │ STEP 0: FILE SCAN (NEW — deterministic, no guessing) │
191
+ │ scan_v2_migration → JSON report with line numbers, │
192
+ │ v2 patterns, and migration suggestions │
193
+ ├──────────────────────────────────────────────────────────────────┤
194
+ │ STEP 1: MIGRATION ANALYSIS │
195
+ │ list_migration_guides → get_migration_guide → docs_search │
196
+ │ Output: Legacy Element → DB UX v3 Component mapping table │
197
+ ├──────────────────────────────────────────────────────────────────┤
198
+ │ STEP 2: COMPONENT DISCOVERY & PROPS RETRIEVAL │
199
+ │ list_components → get_component_props → get_component_details │
200
+ │ → get_example_code → get_design_tokens → list_icons │
201
+ ├──────────────────────────────────────────────────────────────────┤
202
+ │ STEP 3: CODE GENERATION │
203
+ │ Generates complete migrated code (NOT shown to user yet) │
204
+ ├──────────────────────────────────────────────────────────────────┤
205
+ │ STEP 4: CODE VERIFICATION & SELF-CORRECTION (mandatory) │
206
+ │ verify_migrated_code → run project scripts → retry (max 3) │
207
+ ├──────────────────────────────────────────────────────────────────┤
208
+ │ STEP 5: FINAL OUTPUT │
209
+ │ ✅ VERIFIED or ⚠️ WARNING with remaining diagnostics │
210
+ └──────────────────────────────────────────────────────────────────┘
211
+ ```
212
+
213
+ **Step-by-step details:**
214
+
215
+ 1. **Migration Analysis** — Calls `list_migration_guides` then `get_migration_guide` to load official migration rules (package renames, prop changes, removed components). Calls `docs_search` for component-specific migration docs. Produces a mapping table: Legacy Element → DB UX v3 Component → Rationale.
216
+ 2. **Component Discovery & Props Retrieval** — Calls `list_components` to verify every mapped component exists. For each: `get_component_props` (TypeScript API), `get_component_details` (examples), `get_example_code` (canonical source to adapt). Calls `get_design_tokens` to replace hardcoded colors/spacing. Calls `list_icons` to verify icon names.
217
+ 3. **Code Generation** — Generates the complete migrated code with correct `@db-ux/*` imports, verified design tokens, and verified icon names. **Does NOT output this to the user yet.**
218
+ 4. **Code Verification & Self-Correction** — Calls `verify_migrated_code` which instructs the AI to run the project's own verification scripts (typecheck, lint, build from package.json). If errors are found, the AI fixes the code and retries — up to **3 attempts maximum**. This step applies to all framework targets.
219
+ 5. **Final Output** — Presents the result in three sections: "Migration Analysis" (mapping table + guide references), "Migrated Code" (marked ✅ VERIFIED on success, or ⚠️ WARNING with remaining diagnostics), and "Accessibility Statement" (WCAG 2.2 AA compliance confirmation).
220
+
221
+ **Available migration guides:**
222
+
223
+ | Guide | Covers |
224
+ | --------------------- | ------------------------------------------------------------------ |
225
+ | `component-migration` | Component renames, prop changes, removed/planned components |
226
+ | `color-migration` | Full color token mapping (old → new `--db-*` tokens) |
227
+ | `icon-migration` | Icon name mapping (e.g. `account` → `person`, `delete` → `bin`) |
228
+ | `general-migration` | Typography tokens, spacing tokens, elevation, inline style removal |
229
+
230
+ **Example: migrating a DB UI v2 React component**
231
+
232
+ Trigger the prompt with these parameters:
145
233
 
146
- - **Parameters:** `legacy_code`, `source_context`, `target_framework`.
147
- - **Behavior:** Calls `list_migration_guides` and `get_migration_guide` to dynamically load the relevant migration docs before mapping any component. This ensures all package renames, prop changes, and missing-component workarounds are sourced from the official guides rather than hardcoded knowledge.
234
+ - `legacy_code`: your old React component source code
235
+ - `source_context`: `db-ui-v2`
236
+ - `target_framework`: `react`
237
+
238
+ The AI will then autonomously:
239
+
240
+ 1. Load `component-migration`, `color-migration`, `icon-migration`, and `general-migration`
241
+ 2. Map every legacy element (e.g. `variant="brand-primary"` → `variant="brand"`, `icon="search"` → `icon="magnifying_glass"`)
242
+ 3. Fetch the exact generated React example code for each component and adapt it
243
+ 4. Replace all hardcoded `#ec0016` / `margin: 15px` values with `--db-*` design tokens
244
+ 5. Verify the result via `verify_migrated_code` (runs project's own scripts) and self-correct up to 3 times
245
+ 6. Present the verified code with a migration analysis and accessibility statement
148
246
 
149
247
  ### `audit_accessibility` (Deep A11y Scan)
150
248
 
@@ -155,6 +253,19 @@ Specialized deep scan exclusively for inclusion and accessibility standards (WCA
155
253
 
156
254
  ---
157
255
 
256
+ ## 🛡️ Security & Compliance
257
+
258
+ This MCP server operates under a strict, zero-trust security model to prevent malicious AI behavior or accidental system damage.
259
+
260
+ - **Strict Read-Only Sandbox:** The server has zero write-permissions for design system files. All imports from `node:fs` for component data are strictly read-only (`readFile`, `readdir`). The `verify_migrated_code` tool does not execute shell commands — it returns instructions for the LLM to run the project's own verification scripts.
261
+ - **Path Traversal Protection (Jailbreak Prevention):** All file and directory accesses (e.g., resolving component names) pass through a path resolver with traversal protection (`resolveSafePath`). The server guarantees that no file reads can escape the allowed base directories (blocking `../../etc/passwd` attacks).
262
+ - **DoS & Context Window Protection:** To prevent LLMs from crashing or generating massive API billing spikes due to context window overflows, strict token limiters are enforced:
263
+ - File reads are truncated at **20,000 characters**.
264
+ - JSON arrays (like component or icon lists) are truncated at **20,000 characters**.
265
+ - Directory scans are hard-limited to a maximum of **10 files**.
266
+
267
+ ---
268
+
158
269
  ## 📐 Architecture & Manifest
159
270
 
160
271
  ### How it works
@@ -165,12 +276,12 @@ The server is a single Node.js process communicating over **stdio** using the [M
165
276
 
166
277
  Because `model.ts`, showcase files, and framework example source files are **not** included in the published npm packages (only compiled `dist/` is shipped), the server embeds all necessary data at build time.
167
278
 
168
- `src/build-manifest.ts` runs during the build and produces `src/manifest.json` containing:
279
+ `scripts/build-manifest.ts` is called by the `prebuild.ts` orchestrator and produces `src/manifest.json` containing:
169
280
 
170
281
  ```text
171
282
  manifest.json
172
283
  ├── icons[] — icon names from packages/foundations/src/all-icons.ts
173
- ├── tokens{} — raw SCSS design tokens mapped by category
284
+ ├── tokens{} — SCSS design tokens mapped by category (colors, typography, animation, transitions — categories with raw SCSS; spacing/elevation/density served from tokens.json instead)
174
285
  ├── docs{} — conceptual markdown documentation
175
286
  └── components{}
176
287
  └── {componentName}
@@ -203,22 +314,32 @@ This means the same binary works for:
203
314
  - **Design system developers** working inside the monorepo (always up-to-date, live files)
204
315
  - **Consumer teams** running `npx @db-ux/mcp-server` (self-contained, no monorepo needed)
205
316
 
317
+ > **Note on design tokens:** For most categories (spacing, elevation, density, colors, etc.), the tool reads from a structured `assets/tokens/tokens.json` generated by the `prebuild` step from `@db-ux/db-theme` and the foundations build output. Categories not covered by the JSON (e.g. animation, transitions) fall back to raw SCSS from the manifest.
318
+ >
319
+ > **Note on visual references:** The `get_visual_reference` tool serves pre-optimised static JPEG images from `assets/visuals/`. These files are committed directly to the repository — no build-time image processing or native dependencies required.
320
+
206
321
  ### Directory structure
207
322
 
208
323
  ```text
209
324
  packages/mcp-server/
325
+ ├── assets/
326
+ │ ├── migration/ # Migration guides (copied from docs/migration/db-ui/ by prebuild)
327
+ │ ├── tokens/ # Prebuild-generated tokens.json (structured design tokens)
328
+ │ └── visuals/ # Pre-optimised static reference images (JPEG, committed to Git)
329
+ ├── scripts/
330
+ │ ├── prebuild.ts # Central orchestrator: migration assets, tokens, manifest (runs via tsx)
331
+ │ └── build-manifest.ts # Build-time script — generates src/manifest.json
210
332
  ├── src/
211
333
  │ ├── index.ts # Bootstrap — connects transport, registers tools/prompts
212
334
  │ ├── server.ts # McpServer singleton and lifecycle handlers
213
335
  │ ├── types.ts # Framework type and FRAMEWORK_PKG mapping
214
- │ ├── build-manifest.ts # Build-time script — generates manifest.json
215
336
  │ ├── tools/ # Tool handler implementations
216
337
  │ ├── prompts/ # Prompt handler implementations
217
- └── utils/ # Shared utilities (path, manifest, formatting, async)
338
+ ├── utils/ # Shared utilities (path, manifest, formatting, async)
218
339
  │ └── manifest.json # Generated — do not edit manually
219
340
  ├── build/
220
341
  │ └── index.js # Compiled standalone bundle (gitignored)
221
- ├── esbuild.js # Build script: runs build-manifest, then bundles
342
+ ├── esbuild.js # Build script: bundles src/index.ts into standalone dist/index.js
222
343
  ├── package.json
223
344
  ├── tsconfig.json
224
345
  └── CONTEXT.md # Architecture notes
@@ -226,92 +347,6 @@ packages/mcp-server/
226
347
 
227
348
  ---
228
349
 
229
- ## ⚠️ Defensive Rules for AI
230
-
231
- These are the **Golden Rules** the AI agent must follow when using this server. They are enforced by the workflow rules file and should be treated as hard constraints, not suggestions.
232
-
233
- ### NEVER use native HTML elements when a DB UX component exists
234
-
235
- ```tsx
236
- // ❌ WRONG
237
- <button style="background: #d40000; padding: 8px 16px">Save</button>
238
- <input type="text" placeholder="Search..." />
239
- <div style="display: flex; gap: 16px">...</div>
240
-
241
- // ✅ CORRECT
242
- <DBButton variant="brand">Save</DBButton>
243
- <DBInput placeholder="Search..." />
244
- <DBStack>...</DBStack>
245
- ```
246
-
247
- | Native element | DB UX replacement |
248
- | ---------------- | -------------------------------- |
249
- | `<button>` | `DBButton` |
250
- | `<input>` | `DBInput` |
251
- | `<select>` | `DBSelect` |
252
- | `<a>` | `DBLink` |
253
- | `<textarea>` | `DBTextarea` |
254
- | `<div>` (layout) | `DBStack`, `DBSection`, `DBCard` |
255
-
256
- ### NEVER use hardcoded colors or magic spacing values
257
-
258
- ```scss
259
- // ❌ WRONG
260
- .my-element {
261
- color: #ec0016;
262
- margin: 15px;
263
- gap: 8px;
264
- }
265
-
266
- // ✅ CORRECT — values retrieved via get_design_tokens
267
- .my-element {
268
- color: var(--db-color-red-500);
269
- margin: var(--db-spacing-fixed-sm);
270
- gap: var(--db-spacing-fixed-xs);
271
- }
272
- ```
273
-
274
- ### ALWAYS verify props and icon names via MCP tools
275
-
276
- ```tsx
277
- // ❌ WRONG — icon name invented, prop API assumed
278
- <DBButton icon="chevronRight" size="large">Next</DBButton>
279
-
280
- // ✅ CORRECT — icon name from list_icons, props from get_component_props
281
- <DBButton icon="chevron_right" size="small">Next</DBButton>
282
- ```
283
-
284
- ### ALWAYS call get_example_code before writing component usage
285
-
286
- The generated examples are the canonical reference. Adapt them — do not rewrite component usage from scratch.
287
-
288
- ---
289
-
290
- ## 📦 Build Command
291
-
292
- The server is built as part of the `@db-ux/mcp-server` package:
293
-
294
- ```bash
295
- # from the monorepo root
296
- npm run build --workspace=@db-ux/mcp-server
297
- ```
298
-
299
- This runs `packages/mcp-server/esbuild.js` which:
300
-
301
- 1. Executes `src/build-manifest.ts` — collects all component data from the live monorepo into `src/manifest.json`
302
- 2. Bundles `src/index.ts` + `manifest.json` via esbuild into a single `build/index.js` with `#!/usr/bin/env node` shebang
303
- 3. Copies the bundle to `packages/mcp-server/dist/index.js` for inclusion in the published `@db-ux/mcp-server` npm package
304
-
305
- To build and test the server in isolation during development:
306
-
307
- ```bash
308
- # from packages/mcp-server/
309
- npm run build # generates manifest + bundle
310
- npm run dev # runs src/index.ts directly via tsx (monorepo mode, live files). The server communicates over stdio and produces no terminal output by itself — this is expected.
311
- ```
312
-
313
- ---
314
-
315
350
  ## ❓ Troubleshooting
316
351
 
317
352
  ### "Unknown Configuration Setting" in VS Code
@@ -338,24 +373,21 @@ _Alternatively, you can change your IDE's working directory for the MCP server t
338
373
 
339
374
  ---
340
375
 
341
- ## 🛡️ Security & Compliance
342
-
343
- This MCP server operates under a strict, zero-trust security model to prevent malicious AI behavior or accidental system damage.
376
+ ## 🧪 Development & Testing
344
377
 
345
- - **Strict Read-Only Sandbox:** The server has zero write-permissions. All imports from `node:fs` are strictly read-only (`readFile`, `readdir`). Modules like `child_process` (for shell execution) or file mutation methods (`writeFile`, `unlink`) are completely banned.
346
- - **Path Traversal Protection (Jailbreak Prevention):** All file and directory accesses (e.g., resolving component names) pass through a cryptographic-style path resolver. The server mathematically guarantees that no file reads can escape the allowed `REPO_ROOT` or `COMPONENTS_DIR` (blocking `../../etc/passwd` attacks).
347
- - **DoS & Context Window Protection:** To prevent LLMs from crashing or generating massive API billing spikes due to context window overflows, strict token limiters are enforced:
348
- - File reads are truncated at **20,000 characters**.
349
- - JSON arrays (like component or icon lists) are truncated at **20,000 characters**.
350
- - Directory scans are hard-limited to a maximum of **10 files**.
378
+ To build and test the server in isolation during development:
351
379
 
352
- ---
380
+ ```bash
381
+ # from packages/mcp-server/
382
+ npm run build # generates manifest + bundle
383
+ npm run dev # runs src/index.ts directly via tsx (monorepo mode, live files). The server communicates over stdio and produces no terminal output by itself — this is expected.
384
+ ```
353
385
 
354
- ## 🧪 Development & Testing
386
+ ### MCP Inspector
355
387
 
356
388
  The **MCP Inspector** is the official tool to validate MCP tools and prompts (e.g. `scaffold_page`) independently of any IDE (VS Code, IntelliJ, etc.). Use it to inspect the server's capabilities, test tool calls interactively, and verify prompt outputs before relying on them in an AI agent workflow.
357
389
 
358
- ### Prerequisites
390
+ #### Prerequisites
359
391
 
360
392
  Build the server bundle first (if not already done):
361
393
 
@@ -364,22 +396,49 @@ Build the server bundle first (if not already done):
364
396
  npm run build
365
397
  ```
366
398
 
367
- ### Starting the Inspector
399
+ #### Starting the Inspector
368
400
 
369
401
  Run the following command from the `packages/mcp-server/` directory:
370
402
 
371
- > **Note:** Port 5173 is the default for Vite and Playwright. To avoid conflicts if those are already running, you can specify a different port using the `--port` flag.
403
+ > **Note:** The Inspector UI runs on **port 6274**, the proxy on **port 6277**. If either port is already in use, free it first: `lsof -ti :6274 -ti :6277 | xargs kill -9`
372
404
 
373
405
  ```bash
374
- npx @modelcontextprotocol/inspector --port 5178 node build/index.js
406
+ npx @modelcontextprotocol/inspector --transport stdio node dist/index.js
407
+ ```
408
+
409
+ The Inspector prints a URL with a session token to the terminal, e.g.:
410
+
411
+ ```text
412
+ 🔍 MCP Inspector is up and running at http://localhost:6274/?MCP_PROXY_AUTH_TOKEN=<token>
375
413
  ```
376
414
 
377
- ### Step-by-step workflow
415
+ Open that **full URL including the token** in your browser — the token is required for authentication.
416
+
417
+ #### Step-by-step workflow
378
418
 
379
419
  1. Run the command above — the Inspector starts a local web server
380
- 2. Open the browser tab it prints (e.g., **<http://localhost:5178>**)
381
- 3. Navigate to the **"Prompts"** tab to browse and execute interactive prompts like `scaffold_page`
382
- 4. Navigate to the **"Tools"** tab to call individual tools (e.g. `list_components`, `get_example_code`) and inspect their responses
383
- 5. Use the **"Resources"** tab to verify any static resources exposed by the server
420
+ 2. Open the **full URL with token** printed in the terminal (e.g. `http://localhost:6274/?MCP_PROXY_AUTH_TOKEN=...`)
421
+ 3. Click **"Connect"** to establish the stdio connection to the server
422
+ 4. Navigate to the **"Tools"** tab to call individual tools (e.g. `list_components`, `scan_v2_migration`) and inspect their responses
423
+ 5. Navigate to the **"Prompts"** tab to browse and execute interactive prompts like `scaffold_page`
384
424
 
385
425
  > **Tip:** The Inspector is framework- and IDE-agnostic. It communicates with the server over stdio exactly as a real MCP client would, making it the most reliable way to catch issues before they surface in an AI agent session.
426
+
427
+ ---
428
+
429
+ ## ⚠️ Development Constraints
430
+
431
+ > **These rules are critical for contributors working on the MCP server package.**
432
+
433
+ | Rule | Details |
434
+ | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
435
+ | **ESM only** | This package is `"type": "module"`. Never use `require()` — use `import` exclusively. |
436
+ | **tsx for TS scripts** | Build scripts (e.g. `prebuild.ts`) run via `tsx`. This ensures compatibility with Node.js 22+. |
437
+ | **No lifecycle hooks** | NPM lifecycle scripts (`prebuild`, `preinstall`) are disabled in this monorepo. Build steps must be chained via `&&` in the `build` script. |
438
+ | **No committed build artifacts** | Files in `assets/migration/` and `assets/tokens/` are generated at build time. They are git-ignored and must never be committed. `assets/visuals/` contains static JPEGs that **are** committed. |
439
+ | **Strict assets-only reading** | The server must never fall back to monorepo source paths at runtime. Read strictly from `assets/` to avoid masking build failures. |
440
+ | **Hard CI failures** | Build scripts must `throw new Error()` when required sources are missing — never fail silently. Exception: density CSS (build artifact, soft-fail allowed). |
441
+ | **File system safety** | Always call `stats.isFile()` after `stat()` before `readFile()` to prevent `EISDIR` crashes on directories. |
442
+ | **Cross-platform paths** | Normalize backslashes to forward slashes before path comparisons. Windows manifest keys contain `\`. |
443
+
444
+ > **Note:** AI-specific behavioral rules (gentle migration, v2/v3 terminology, icon verification, etc.) are maintained in `CONTEXT.md` (shipped with the package for consumer AI agents) and in `.github/copilot-instructions.md` (for agents working inside this monorepo). They are intentionally not duplicated here.
@@ -29,10 +29,13 @@ Or add it to your MCP client config:
29
29
  4. `docs_search` — search guidelines, accessibility docs, or component-specific documentation if needed
30
30
  5. `get_example_code` — fetch the real generated code for the target framework
31
31
  6. `list_design_token_categories` — get available token categories if unsure which to query
32
- 7. `get_design_tokens` — retrieve spacing, color, and typography tokens
32
+ 7. `get_design_tokens` — retrieve spacing, elevation, density, color, and typography tokens
33
33
  8. `list_icons` — look up the exact icon name before using any icon prop
34
34
  9. `list_migration_guides` — list all available migration guides before any migration task
35
35
  10. `get_migration_guide` — load the full content of a specific migration guide
36
+ 11. `verify_migrated_code` — after generating migrated code, pass the full code string and framework to this tool for a compiler check. Fix errors and retry (max 3 attempts) before presenting code to the user
37
+ 12. `get_visual_reference` — _(optional, use sparingly)_ if you need visual context for complex layouts, call this tool with the visual name to receive a pre-optimised static JPEG reference image
38
+ 13. `scan_v2_migration` — **call FIRST when migrating a file.** Scans a source file for v2 patterns (CSS classes `cmp-*`, `elm-*`, `rea-*`, Web Components `<db-*>`, `db-color-*`, legacy icons) and returns a JSON report with line numbers and deterministic suggestions. Use this before any code generation.
36
39
 
37
40
  ### DON'Ts — these are hard violations:
38
41
 
@@ -41,6 +44,8 @@ Or add it to your MCP client config:
41
44
  - **NEVER** hardcode color values (`#d40000`, `rgb(...)`) — use design tokens exclusively
42
45
  - **NEVER** write inline styles (`style="margin: 15px"`)
43
46
  - **NEVER** invent or guess icon names — always call `list_icons` first
47
+ - **NEVER** output migrated code to the user without calling `verify_migrated_code` first — the self-correction loop (max 3 attempts) is mandatory
48
+ - **NEVER** use `// @ts-nocheck`, `// @ts-ignore`, `// @ts-expect-error`, `eslint-disable`, or any other compiler/linter bypass directive to "fix" errors — solve the underlying issue instead
44
49
 
45
50
  ### DOs:
46
51
 
@@ -53,6 +58,17 @@ Or add it to your MCP client config:
53
58
  </div>
54
59
  ```
55
60
 
61
+ ### Migration workflow (MANDATORY when the user asks to migrate, refactor, or upgrade legacy code):
62
+
63
+ When the user asks you to migrate, refactor, or upgrade code from DB UI, Bootstrap, native HTML, or any older version to DB UX v3, you **MUST** follow this exact 5-step workflow — do NOT skip any step:
64
+
65
+ 1. **File Scan** — Call `analyze_v2_migration` with the file path. This returns a deterministic JSON report of all v2 patterns (components, colors, icons) with line numbers and suggestions. Use this as your migration checklist.
66
+ 2. **Migration Analysis** — Call `list_migration_guides`, then `get_migration_guide` for each relevant guide. Call `docs_search` for component-specific migration docs. Produce a mapping table: Legacy Element → DB UX v3 Component → Rationale.
67
+ 3. **Component Discovery & Props Retrieval** — Call `list_components` to verify every mapped component. For each: `get_component_props`, `get_component_details`, `get_example_code`. Call `get_design_tokens` to replace hardcoded values. Call `list_icons` to verify icon names. Optionally call `get_component_visual` for layout uncertainty.
68
+ 4. **Code Generation** — Generate the complete migrated code. Do **NOT** show it to the user yet.
69
+ 5. **Code Verification (MANDATORY for react/angular/vue)** — Call `verify_migrated_code`. If errors are returned, fix and retry (max 3 attempts). For `web-components` and `html` targets, skip this step, as they lack a strict compilation/type-checking step for automated verification in our sandbox.
70
+ 6. **Final Output** — Present: "Migration Analysis" (mapping table), "Migrated Code" (✅ VERIFIED or ⚠️ WARNING with diagnostics), "Accessibility Statement".
71
+
56
72
  ---
57
73
 
58
74
  ## Available AI Workflows (Prompts)
@@ -77,6 +93,7 @@ Generates the initial structure of a complete web page or complex module. Enforc
77
93
  2. **Component Discovery** — Calls `list_components` to verify every planned block maps to a DB UX component. Reports missing components instead of falling back to native HTML
78
94
  3. **Props & Examples** — For each component: `get_component_props` → `get_component_details` → `get_example_code` with the target framework
79
95
  4. **Token & Asset Validation** — `list_design_token_categories` → `get_design_tokens` for needed categories, `list_icons` for any icon props
96
+ 5. **Visual Validation (optional)** — If uncertain about layout structure or visual hierarchy, call `get_component_visual` for a reference screenshot
80
97
 
81
98
  **Output structure:**
82
99
 
@@ -113,7 +130,7 @@ Performs a strict multi-layered QA, accessibility, and DB UX compliance audit on
113
130
 
114
131
  ### `migrate_component` — Legacy Refactoring
115
132
 
116
- Transforms legacy UI code (e.g. Bootstrap, native HTML, DB UI) into the modern DB UX architecture.
133
+ Transforms legacy UI code (e.g. Bootstrap, native HTML, DB UI) into the modern DB UX architecture. Includes a **mandatory code verification step** before presenting results.
117
134
 
118
135
  **Parameters:**
119
136
 
@@ -125,16 +142,17 @@ Transforms legacy UI code (e.g. Bootstrap, native HTML, DB UI) into the modern D
125
142
 
126
143
  **Workflow:**
127
144
 
128
- 1. **Knowledge Acquisition** — Calls `list_migration_guides` then `get_migration_guide` for relevant versions. Studies package renames, missing components, prop changes
129
- 2. **Asset Scanning** — Scans for color references (CSS classes, hex values, legacy `--db-color-*` variables) and icon references. Loads `color-migration` and `icon-migration` guides as sole source of truth. Flags any values not found in the tables
130
- 3. **DB UX Mapping** — Calls `list_components`, `get_component_props`, and `get_example_code` to verify modern equivalents
131
- 4. **Token Migration** — Calls `get_design_tokens` to replace legacy CSS variables, utility classes, or hardcoded values
145
+ 1. **Migration Analysis** — Calls `list_migration_guides` then `get_migration_guide` for relevant versions. Studies package renames, missing components, prop changes
146
+ 2. **Component Discovery & Props Retrieval** — Calls `list_components`, `get_component_props`, `get_component_details`, and `get_example_code` to verify modern equivalents. Calls `get_design_tokens` to replace legacy CSS variables or hardcoded values. Calls `list_icons` for any icon references. Optionally calls `get_component_visual` when uncertain about layout structures or visual hierarchies
147
+ 3. **Code Generation** — Generates the complete migrated component code. **Does NOT output this to the user yet**
148
+ 4. **Code Verification & Self-Correction (MANDATORY)** — Calls `verify_migrated_code` with the generated code and framework. If the tool returns compiler errors, the AI analyzes the diagnostics, fixes the code, and retries. This loop runs for a **maximum of 3 attempts**. If verification still fails after 3 attempts, the AI presents the code with a prominent ⚠️ warning block containing the remaining errors
149
+ 5. **Final Output** — Presents the verified code (✅ on success, ⚠️ with diagnostics on failure)
132
150
 
133
151
  **Output structure:**
134
152
 
135
153
  1. "Migration Analysis" — Maps each legacy element to its modern replacement, referencing migration guide rules
136
- 2. "Refactored Code" — Fully migrated, production-ready code with correct `@db-ux/*` imports
137
- 3. "Actionable Post-Migration Notes" — Behavioral shifts, ARIA states to verify, colors/icons not found in migration tables
154
+ 2. "Migrated Code" — Fully migrated, production-ready code with correct `@db-ux/*` imports. Marked ✅ VERIFIED or ⚠️ WARNING with remaining diagnostics
155
+ 3. "Accessibility Statement" — Confirmation of WCAG 2.2 AA compliance through the selected DB UX components
138
156
 
139
157
  ### `audit_accessibility` — Deep A11y Scan
140
158
 
Binary file
Binary file
Binary file
Binary file