@db-ux/mcp-server 4.7.0-mcp-server-migrate-tool-test-2-0cf8204 → 4.7.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 +110 -165
- package/agent/_instructions.md +8 -27
- package/dist/index.js +292 -1054
- package/package.json +3 -6
- package/assets/migration/color-migration.md +0 -150
- package/assets/migration/component-migration.md +0 -105
- package/assets/migration/general-migration.md +0 -33
- package/assets/migration/icon-migration.md +0 -3
- package/assets/tokens/default-variables.scss +0 -1317
- package/assets/tokens/density-all.css +0 -1807
- package/assets/visuals/dashboard.png +0 -0
- package/assets/visuals/form.png +0 -0
- package/assets/visuals/landingpage.png +0 -0
- package/assets/visuals/table.png +0 -0
package/README.md
CHANGED
|
@@ -91,53 +91,22 @@ 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
|
-
|
|
121
94
|
---
|
|
122
95
|
|
|
123
96
|
## 🛠 Available AI Tools (Skills)
|
|
124
97
|
|
|
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`,
|
|
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, A11y, 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` | Saves generated code to a temp file and runs a compiler check (`tsc --noEmit`). Must be called after code generation and before showing code to the user. Returns diagnostics on failure so the AI can self-correct (max 3 attempts). |
|
|
138
|
-
| `get_component_visual` | Returns a downsampled screenshot (max 800×800 px, JPEG q75, bilinear interpolation) of a DB UX component or page layout as a Base64-encoded image. Use sparingly — only when visual context is needed for complex layouts, z-index dependencies, or visual hierarchies. |
|
|
139
|
-
| `analyze_v2_migration` | **Call FIRST when migrating a file.** Scans a source file for DB UI v2 patterns (`<cmp-*>`, `<elm-*>`, `<rea-*>` tags, `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. |
|
|
140
|
-
| `scaffold_component` | Generates a DB UX-conformant component skeleton for a specified framework (`react`, `angular`, `vue`, `web-components`, or `html`). Creates all boilerplate files (component, template, SCSS) with correct `@db-ux/*` imports and SCSS foundation `@use` directives. The developer only needs to fill in business logic. |
|
|
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. |
|
|
141
110
|
|
|
142
111
|
### Example: fetching a React button example
|
|
143
112
|
|
|
@@ -148,8 +117,6 @@ get_component_details → lists ["Density", "Variant", "Show Icon Leading", .
|
|
|
148
117
|
get_example_code → returns show-icon-leading.example.tsx source
|
|
149
118
|
list_icons → confirms "arrow_right" is a valid icon name
|
|
150
119
|
get_design_tokens → returns --db-spacing-fixed-md for layout
|
|
151
|
-
get_component_visual → (optional) returns a downsampled screenshot for visual reference
|
|
152
|
-
verify_migrated_code → runs tsc --noEmit on generated code, returns ✅ or diagnostics
|
|
153
120
|
```
|
|
154
121
|
|
|
155
122
|
---
|
|
@@ -174,78 +141,10 @@ Performs a strict multi-layered QA, accessibility, and DB UX compliance audit on
|
|
|
174
141
|
|
|
175
142
|
### `migrate_component` (Legacy Refactoring)
|
|
176
143
|
|
|
177
|
-
Transforms legacy UI code (e.g., Bootstrap, native HTML, DB UI v1/v2) into the modern DB UX v3 architecture.
|
|
178
|
-
|
|
179
|
-
**Parameters:**
|
|
180
|
-
|
|
181
|
-
| Parameter | Required | Description |
|
|
182
|
-
| ------------------ | -------- | ---------------------------------------------------------------------------------------------------------------------- |
|
|
183
|
-
| `legacy_code` | Yes | The outdated source code to migrate (DB UI, Bootstrap, raw HTML/CSS). Max 10,000 chars |
|
|
184
|
-
| `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` |
|
|
185
|
-
| `target_framework` | Yes | Target framework: `react`, `angular`, `vue`, `web-components`, or `html` |
|
|
186
|
-
|
|
187
|
-
**Full workflow (5 mandatory steps):**
|
|
188
|
-
|
|
189
|
-
```text
|
|
190
|
-
┌──────────────────────────────────────────────────────────────────┐
|
|
191
|
-
│ STEP 0: FILE SCAN (NEW — deterministic, no guessing) │
|
|
192
|
-
│ analyze_v2_migration → JSON report with line numbers, │
|
|
193
|
-
│ v2 patterns, and migration suggestions │
|
|
194
|
-
├──────────────────────────────────────────────────────────────────┤
|
|
195
|
-
│ STEP 1: MIGRATION ANALYSIS │
|
|
196
|
-
│ list_migration_guides → get_migration_guide → docs_search │
|
|
197
|
-
│ Output: Legacy Element → DB UX v3 Component mapping table │
|
|
198
|
-
├──────────────────────────────────────────────────────────────────┤
|
|
199
|
-
│ STEP 2: COMPONENT DISCOVERY & PROPS RETRIEVAL │
|
|
200
|
-
│ list_components → get_component_props → get_component_details │
|
|
201
|
-
│ → get_example_code → get_design_tokens → list_icons │
|
|
202
|
-
│ → get_component_visual (optional, for layout uncertainty) │
|
|
203
|
-
├──────────────────────────────────────────────────────────────────┤
|
|
204
|
-
│ STEP 3: CODE GENERATION │
|
|
205
|
-
│ Generates complete migrated code (NOT shown to user yet) │
|
|
206
|
-
├──────────────────────────────────────────────────────────────────┤
|
|
207
|
-
│ STEP 4: CODE VERIFICATION & SELF-CORRECTION (mandatory) │
|
|
208
|
-
│ verify_migrated_code → fix errors → retry (max 3 attempts) │
|
|
209
|
-
│ ⚠️ Only for react, angular, vue — skipped for html/wc │
|
|
210
|
-
├──────────────────────────────────────────────────────────────────┤
|
|
211
|
-
│ STEP 5: FINAL OUTPUT │
|
|
212
|
-
│ ✅ VERIFIED or ⚠️ WARNING with remaining diagnostics │
|
|
213
|
-
└──────────────────────────────────────────────────────────────────┘
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
**Step-by-step details:**
|
|
217
|
-
|
|
218
|
-
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.
|
|
219
|
-
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. Optionally calls `get_component_visual` when uncertain about layout structures.
|
|
220
|
-
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.**
|
|
221
|
-
4. **Code Verification & Self-Correction** — Passes the generated code to `verify_migrated_code` which runs `tsc --noEmit`. If compiler errors are returned, the AI analyzes diagnostics, fixes the code, and retries — up to **3 attempts maximum**. This step only applies to `react`, `angular`, and `vue` targets. For `web-components` and `html`, it is skipped.
|
|
222
|
-
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).
|
|
223
|
-
|
|
224
|
-
**Available migration guides:**
|
|
225
|
-
|
|
226
|
-
| Guide | Covers |
|
|
227
|
-
| --------------------- | ------------------------------------------------------------------ |
|
|
228
|
-
| `component-migration` | Component renames, prop changes, removed/planned components |
|
|
229
|
-
| `color-migration` | Full color token mapping (old → new `--db-*` tokens) |
|
|
230
|
-
| `icon-migration` | Icon name mapping (e.g. `account` → `person`, `delete` → `bin`) |
|
|
231
|
-
| `general-migration` | Typography tokens, spacing tokens, elevation, inline style removal |
|
|
232
|
-
|
|
233
|
-
**Example: migrating a DB UI v2 React component**
|
|
234
|
-
|
|
235
|
-
Trigger the prompt with these parameters:
|
|
236
|
-
|
|
237
|
-
- `legacy_code`: your old React component source code
|
|
238
|
-
- `source_context`: `db-ui-v2`
|
|
239
|
-
- `target_framework`: `react`
|
|
144
|
+
Transforms legacy UI code (e.g., Bootstrap, native HTML, DB UI v1/v2) into the modern DB UX v3/v4 architecture.
|
|
240
145
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
1. Load `component-migration`, `color-migration`, `icon-migration`, and `general-migration`
|
|
244
|
-
2. Map every legacy element (e.g. `variant="brand-primary"` → `variant="brand"`, `icon="search"` → `icon="magnifying_glass"`)
|
|
245
|
-
3. Fetch the exact generated React example code for each component and adapt it
|
|
246
|
-
4. Replace all hardcoded `#ec0016` / `margin: 15px` values with `--db-*` design tokens
|
|
247
|
-
5. Compile the result via `verify_migrated_code` and self-correct up to 3 times
|
|
248
|
-
6. Present the verified code with a migration analysis and accessibility statement
|
|
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.
|
|
249
148
|
|
|
250
149
|
### `audit_accessibility` (Deep A11y Scan)
|
|
251
150
|
|
|
@@ -271,7 +170,7 @@ Because `model.ts`, showcase files, and framework example source files are **not
|
|
|
271
170
|
```text
|
|
272
171
|
manifest.json
|
|
273
172
|
├── icons[] — icon names from packages/foundations/src/all-icons.ts
|
|
274
|
-
├── tokens{} — SCSS design tokens mapped by category
|
|
173
|
+
├── tokens{} — raw SCSS design tokens mapped by category
|
|
275
174
|
├── docs{} — conceptual markdown documentation
|
|
276
175
|
└── components{}
|
|
277
176
|
└── {componentName}
|
|
@@ -304,16 +203,10 @@ This means the same binary works for:
|
|
|
304
203
|
- **Design system developers** working inside the monorepo (always up-to-date, live files)
|
|
305
204
|
- **Consumer teams** running `npx @db-ux/mcp-server` (self-contained, no monorepo needed)
|
|
306
205
|
|
|
307
|
-
> **Note on compiled tokens:** For `spacing`, `elevation`, and `density`, the tool reads compiled CSS/SCSS files with concrete primitive values (not raw SCSS with `@each` loops). In the monorepo it reads directly from `packages/foundations/`; in standalone mode it falls back to `assets/tokens/` (populated by the `prebuild` step).
|
|
308
|
-
|
|
309
206
|
### Directory structure
|
|
310
207
|
|
|
311
208
|
```text
|
|
312
209
|
packages/mcp-server/
|
|
313
|
-
├── assets/
|
|
314
|
-
│ ├── migration/ # Migration guides (copied from docs/migration/db-ui/ by prebuild)
|
|
315
|
-
│ ├── tokens/ # Compiled token files (copied from foundations by prebuild)
|
|
316
|
-
│ └── visuals/ # Curated reference images (shipped with npm package)
|
|
317
210
|
├── src/
|
|
318
211
|
│ ├── index.ts # Bootstrap — connects transport, registers tools/prompts
|
|
319
212
|
│ ├── server.ts # McpServer singleton and lifecycle handlers
|
|
@@ -333,6 +226,67 @@ packages/mcp-server/
|
|
|
333
226
|
|
|
334
227
|
---
|
|
335
228
|
|
|
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
|
+
|
|
336
290
|
## 📦 Build Command
|
|
337
291
|
|
|
338
292
|
The server is built as part of the `@db-ux/mcp-server` package:
|
|
@@ -358,17 +312,42 @@ npm run dev # runs src/index.ts directly via tsx (monorepo mode, live files)
|
|
|
358
312
|
|
|
359
313
|
---
|
|
360
314
|
|
|
315
|
+
## ❓ Troubleshooting
|
|
316
|
+
|
|
317
|
+
### "Unknown Configuration Setting" in VS Code
|
|
318
|
+
|
|
319
|
+
If you see a yellow squiggle/warning in your `settings.json`, this is expected. Standard VS Code does not natively recognize the `mcp` key yet. As long as your MCP client (like the Claude extension or Cursor) is active, the server will work perfectly.
|
|
320
|
+
|
|
321
|
+
### Server fails to start from the monorepo root (Local Development)
|
|
322
|
+
|
|
323
|
+
If you are developing or testing the MCP server directly from within the DB UX monorepo, the global `npx` command might fail due to npm workspace resolution. In this case, bypass `npx` and point your IDE directly to the local built file.
|
|
324
|
+
|
|
325
|
+
**Fallback IDE Configuration (VS Code/IntelliJ):**
|
|
326
|
+
Instead of using `npx`, use `node` and point it to the local build path (ensure you have run `npm run build` in the `mcp-server` directory first):
|
|
327
|
+
|
|
328
|
+
```json
|
|
329
|
+
"db-ux": {
|
|
330
|
+
"command": "node",
|
|
331
|
+
"disabled": false,
|
|
332
|
+
"timeout": 60000,
|
|
333
|
+
"args": ["packages/mcp-server/dist/index.js"]
|
|
334
|
+
}
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
_Alternatively, you can change your IDE's working directory for the MCP server to `packages/mcp-server`._
|
|
338
|
+
|
|
339
|
+
---
|
|
340
|
+
|
|
361
341
|
## 🛡️ Security & Compliance
|
|
362
342
|
|
|
363
343
|
This MCP server operates under a strict, zero-trust security model to prevent malicious AI behavior or accidental system damage.
|
|
364
344
|
|
|
365
|
-
- **Strict Read-Only Sandbox:** The server has zero write-permissions
|
|
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.
|
|
366
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).
|
|
367
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:
|
|
368
348
|
- File reads are truncated at **20,000 characters**.
|
|
369
349
|
- JSON arrays (like component or icon lists) are truncated at **20,000 characters**.
|
|
370
350
|
- Directory scans are hard-limited to a maximum of **10 files**.
|
|
371
|
-
- **Image Downsampling (Token Optimization):** The `get_component_visual` tool downsamples images to a maximum of **800×800 px** and encodes them as **JPEG at quality 75** before Base64 encoding. This keeps the payload well under the 100 000-character MCP client limit. Images are served exclusively from the curated `assets/visuals/` directory — path traversal protection applies here as well.
|
|
372
351
|
|
|
373
352
|
---
|
|
374
353
|
|
|
@@ -389,52 +368,18 @@ npm run build
|
|
|
389
368
|
|
|
390
369
|
Run the following command from the `packages/mcp-server/` directory:
|
|
391
370
|
|
|
392
|
-
> **Note:**
|
|
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.
|
|
393
372
|
|
|
394
373
|
```bash
|
|
395
|
-
npx @modelcontextprotocol/inspector --
|
|
396
|
-
```
|
|
397
|
-
|
|
398
|
-
The Inspector prints a URL with a session token to the terminal, e.g.:
|
|
399
|
-
|
|
400
|
-
```text
|
|
401
|
-
🔍 MCP Inspector is up and running at http://localhost:6274/?MCP_PROXY_AUTH_TOKEN=<token>
|
|
374
|
+
npx @modelcontextprotocol/inspector --port 5178 node build/index.js
|
|
402
375
|
```
|
|
403
376
|
|
|
404
|
-
Open that **full URL including the token** in your browser — the token is required for authentication.
|
|
405
|
-
|
|
406
377
|
### Step-by-step workflow
|
|
407
378
|
|
|
408
379
|
1. Run the command above — the Inspector starts a local web server
|
|
409
|
-
2. Open the
|
|
410
|
-
3.
|
|
411
|
-
4. Navigate to the **"Tools"** tab to call individual tools (e.g. `list_components`, `
|
|
412
|
-
5.
|
|
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
|
|
413
384
|
|
|
414
385
|
> **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.
|
|
415
|
-
|
|
416
|
-
---
|
|
417
|
-
|
|
418
|
-
## ❓ Troubleshooting
|
|
419
|
-
|
|
420
|
-
### "Unknown Configuration Setting" in VS Code
|
|
421
|
-
|
|
422
|
-
If you see a yellow squiggle/warning in your `settings.json`, this is expected. Standard VS Code does not natively recognize the `mcp` key yet. As long as your MCP client (like the Claude extension or Cursor) is active, the server will work perfectly.
|
|
423
|
-
|
|
424
|
-
### Server fails to start from the monorepo root (Local Development)
|
|
425
|
-
|
|
426
|
-
If you are developing or testing the MCP server directly from within the DB UX monorepo, the global `npx` command might fail due to npm workspace resolution. In this case, bypass `npx` and point your IDE directly to the local built file.
|
|
427
|
-
|
|
428
|
-
**Fallback IDE Configuration (VS Code/IntelliJ):**
|
|
429
|
-
Instead of using `npx`, use `node` and point it to the local build path (ensure you have run `npm run build` in the `mcp-server` directory first):
|
|
430
|
-
|
|
431
|
-
```json
|
|
432
|
-
"db-ux": {
|
|
433
|
-
"command": "node",
|
|
434
|
-
"disabled": false,
|
|
435
|
-
"timeout": 60000,
|
|
436
|
-
"args": ["packages/mcp-server/dist/index.js"]
|
|
437
|
-
}
|
|
438
|
-
```
|
|
439
|
-
|
|
440
|
-
_Alternatively, you can change your IDE's working directory for the MCP server to `packages/mcp-server`._
|
package/agent/_instructions.md
CHANGED
|
@@ -29,14 +29,10 @@ 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,
|
|
32
|
+
7. `get_design_tokens` — retrieve spacing, 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_component_visual` — _(optional, use sparingly)_ if you need visual context for complex layouts, z-index dependencies, or visual hierarchies, call this tool with the component or layout name to receive a downsampled screenshot
|
|
38
|
-
13. `analyze_v2_migration` — **call FIRST when migrating a file.** Scans a source file for v2 patterns (`<cmp-*>`, `<elm-*>`, `db-color-*`, legacy icons) and returns a JSON report with line numbers and deterministic suggestions. Use this before any code generation.
|
|
39
|
-
14. `scaffold_component` — generates a DB UX-conformant component skeleton for a specified framework. Creates all boilerplate files with correct `@db-ux/*` imports and SCSS foundation `@use` directives.
|
|
40
36
|
|
|
41
37
|
### DON'Ts — these are hard violations:
|
|
42
38
|
|
|
@@ -45,8 +41,6 @@ Or add it to your MCP client config:
|
|
|
45
41
|
- **NEVER** hardcode color values (`#d40000`, `rgb(...)`) — use design tokens exclusively
|
|
46
42
|
- **NEVER** write inline styles (`style="margin: 15px"`)
|
|
47
43
|
- **NEVER** invent or guess icon names — always call `list_icons` first
|
|
48
|
-
- **NEVER** output migrated code to the user without calling `verify_migrated_code` first — the self-correction loop (max 3 attempts) is mandatory
|
|
49
|
-
- **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
|
|
50
44
|
|
|
51
45
|
### DOs:
|
|
52
46
|
|
|
@@ -59,17 +53,6 @@ Or add it to your MCP client config:
|
|
|
59
53
|
</div>
|
|
60
54
|
```
|
|
61
55
|
|
|
62
|
-
### Migration workflow (MANDATORY when the user asks to migrate, refactor, or upgrade legacy code):
|
|
63
|
-
|
|
64
|
-
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:
|
|
65
|
-
|
|
66
|
-
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.
|
|
67
|
-
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.
|
|
68
|
-
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.
|
|
69
|
-
4. **Code Generation** — Generate the complete migrated code. Do **NOT** show it to the user yet.
|
|
70
|
-
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.
|
|
71
|
-
6. **Final Output** — Present: "Migration Analysis" (mapping table), "Migrated Code" (✅ VERIFIED or ⚠️ WARNING with diagnostics), "Accessibility Statement".
|
|
72
|
-
|
|
73
56
|
---
|
|
74
57
|
|
|
75
58
|
## Available AI Workflows (Prompts)
|
|
@@ -94,7 +77,6 @@ Generates the initial structure of a complete web page or complex module. Enforc
|
|
|
94
77
|
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
|
|
95
78
|
3. **Props & Examples** — For each component: `get_component_props` → `get_component_details` → `get_example_code` with the target framework
|
|
96
79
|
4. **Token & Asset Validation** — `list_design_token_categories` → `get_design_tokens` for needed categories, `list_icons` for any icon props
|
|
97
|
-
5. **Visual Validation (optional)** — If uncertain about layout structure or visual hierarchy, call `get_component_visual` for a reference screenshot
|
|
98
80
|
|
|
99
81
|
**Output structure:**
|
|
100
82
|
|
|
@@ -131,7 +113,7 @@ Performs a strict multi-layered QA, accessibility, and DB UX compliance audit on
|
|
|
131
113
|
|
|
132
114
|
### `migrate_component` — Legacy Refactoring
|
|
133
115
|
|
|
134
|
-
Transforms legacy UI code (e.g. Bootstrap, native HTML, DB UI) into the modern DB UX architecture.
|
|
116
|
+
Transforms legacy UI code (e.g. Bootstrap, native HTML, DB UI) into the modern DB UX architecture.
|
|
135
117
|
|
|
136
118
|
**Parameters:**
|
|
137
119
|
|
|
@@ -143,17 +125,16 @@ Transforms legacy UI code (e.g. Bootstrap, native HTML, DB UI) into the modern D
|
|
|
143
125
|
|
|
144
126
|
**Workflow:**
|
|
145
127
|
|
|
146
|
-
1. **
|
|
147
|
-
2. **
|
|
148
|
-
3. **
|
|
149
|
-
4. **
|
|
150
|
-
5. **Final Output** — Presents the verified code (✅ on success, ⚠️ with diagnostics on failure)
|
|
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
|
|
151
132
|
|
|
152
133
|
**Output structure:**
|
|
153
134
|
|
|
154
135
|
1. "Migration Analysis" — Maps each legacy element to its modern replacement, referencing migration guide rules
|
|
155
|
-
2. "
|
|
156
|
-
3. "
|
|
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
|
|
157
138
|
|
|
158
139
|
### `audit_accessibility` — Deep A11y Scan
|
|
159
140
|
|