viewgate-mcp 1.0.51 → 1.0.53
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/dist/index.js +73 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -401,6 +401,45 @@ function createMcpServer(apiKey, personalKey) {
|
|
|
401
401
|
case "generate_ui_components": {
|
|
402
402
|
const args = argsAny;
|
|
403
403
|
const limit = Math.min(args.limit || 1, 10);
|
|
404
|
+
// Fetch project styleHandler from config
|
|
405
|
+
let styleHandler = 'css';
|
|
406
|
+
try {
|
|
407
|
+
const configRes = await fetch(`${BACKEND_URL}/api/mcp/config`, {
|
|
408
|
+
headers: {
|
|
409
|
+
'x-api-key': apiKey,
|
|
410
|
+
'x-mcp-tool-name': 'generate_ui_components',
|
|
411
|
+
...(personalKey ? { 'x-personal-key': personalKey } : {})
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
if (configRes.ok) {
|
|
415
|
+
const configData = (await configRes.json());
|
|
416
|
+
styleHandler = configData?.settings?.styleHandler || 'css';
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
catch (e) {
|
|
420
|
+
console.error('[MCP] Could not fetch project config for styleHandler:', e);
|
|
421
|
+
}
|
|
422
|
+
const styleHandlerLabels = {
|
|
423
|
+
'css': 'Plain CSS (vanilla, no framework dependencies)',
|
|
424
|
+
'sass': 'SASS/SCSS (use .scss syntax conventions in comments, output as CSS-in-string or inline styles for compatibility)',
|
|
425
|
+
'tailwind': 'Tailwind CSS (use Tailwind utility classes exclusively for all styling)',
|
|
426
|
+
'css-modules': 'CSS Modules (import styles from a separate .module.css file; use styles.className pattern)',
|
|
427
|
+
'css-in-js': 'CSS-in-JS / styled-components (define all styles as JS template literals using styled.div`...` pattern)',
|
|
428
|
+
'bootstrap': 'Bootstrap 5 (use Bootstrap class names exclusively; no custom CSS unless necessary)',
|
|
429
|
+
'mui': 'Material UI / MUI v5 (use @mui/material components and sx prop for styling; avoid raw CSS)',
|
|
430
|
+
};
|
|
431
|
+
const styleLabel = styleHandlerLabels[styleHandler] ?? styleHandler;
|
|
432
|
+
// Per-handler theming guidance so the LLM generates theme-aware components
|
|
433
|
+
const themingByHandler = {
|
|
434
|
+
'css': `Use CSS custom properties for all colors. Read theme values like: const primary = theme?.primary || 'var(--vg-primary)'. Apply them inline or inject a <style> block using these variables. Never hardcode colors.`,
|
|
435
|
+
'sass': `Use CSS custom properties as values. Resolve theme at runtime: const primary = theme?.primary || 'var(--vg-primary)'. Apply via inline style or injected <style>.`,
|
|
436
|
+
'css-modules': `CSS Modules can use CSS vars. In JS: const primary = theme?.primary || 'var(--vg-primary)'. Pass primary as CSS var via style={{ '--component-primary': primary }} on the root element and reference it inside the .module.css.`,
|
|
437
|
+
'tailwind': `Use Tailwind's arbitrary value syntax for theme colors: className={\`bg-[\${theme?.primary || 'var(--vg-primary)'}]\`}. For text and borders follow the same pattern. Never use fixed Tailwind color classes like text-blue-500.`,
|
|
438
|
+
'css-in-js': `In styled-components template literals, read the theme prop: color: \${({ theme: t }) => t?.primary || 'var(--vg-primary)'}. Accept the full theme object via props and propagate it through styled-components ThemeProvider if needed.`,
|
|
439
|
+
'bootstrap': `Override Bootstrap CSS vars on the root element: style={{ '--bs-primary': theme?.primary || 'var(--vg-primary)' }}. Use btn-primary, text-primary etc. classes which will inherit the overridden variable.`,
|
|
440
|
+
'mui': `Use createTheme({ palette: { primary: { main: theme?.primary || 'var(--vg-primary)' } } }) inside the component and wrap with ThemeProvider. Accept the theme prop and recreate the MUI theme from it.`,
|
|
441
|
+
};
|
|
442
|
+
const themingInstruction = themingByHandler[styleHandler] ?? themingByHandler['css'];
|
|
404
443
|
const fetchUrl = new URL(`${BACKEND_URL}/api/mcp/components`);
|
|
405
444
|
fetchUrl.searchParams.append("limit", limit.toString());
|
|
406
445
|
fetchUrl.searchParams.append("status", "pending");
|
|
@@ -433,12 +472,42 @@ function createMcpServer(apiKey, personalKey) {
|
|
|
433
472
|
htmlContent: item.htmlContent,
|
|
434
473
|
cssContent: item.cssContent,
|
|
435
474
|
sourceType: item.sourceType,
|
|
475
|
+
stylingTechnology: {
|
|
476
|
+
handler: styleHandler,
|
|
477
|
+
instruction: `You MUST use ${styleLabel} for ALL styling. Do not mix or use any other styling approach. The component must be fully styled using this technology and be production-ready.`
|
|
478
|
+
},
|
|
479
|
+
themingTokens: {
|
|
480
|
+
description: 'The component MUST accept an optional `theme` prop for color customization. This is the primary mechanism for users to apply their own brand colors via a JSON file in their project.',
|
|
481
|
+
propInterface: {
|
|
482
|
+
primary: 'string — main brand/accent color (buttons, links, active states)',
|
|
483
|
+
primaryHover: 'string — hover state of primary, slightly darker',
|
|
484
|
+
primaryLight: 'string — light tint of primary for backgrounds (10% opacity)',
|
|
485
|
+
surface: 'string — card/panel background color',
|
|
486
|
+
surfaceAlt: 'string — alternative surface for inputs/hover states',
|
|
487
|
+
border: 'string — border and divider color',
|
|
488
|
+
text: 'string — primary text color',
|
|
489
|
+
textMuted: 'string — secondary/muted text color',
|
|
490
|
+
radius: 'string — base border radius (e.g. "8px", "12px")',
|
|
491
|
+
},
|
|
492
|
+
fallbackMechanism: 'When theme prop is not provided, fall back to CSS custom properties: var(--vg-primary), var(--vg-surface), etc. This allows the ViewGate dashboard preview (which injects CSS vars) and custom ThemeProviders to work without explicit props.',
|
|
493
|
+
handlerSpecificInstruction: themingInstruction,
|
|
494
|
+
criticalRules: [
|
|
495
|
+
'NEVER hardcode any color value (no #hex, no rgb(), no named colors like blue/red)',
|
|
496
|
+
'ALWAYS prefer theme prop values first, then var(--vg-*) CSS vars as fallback',
|
|
497
|
+
'The theme prop must be optional — component must work without it using CSS var fallbacks',
|
|
498
|
+
'Expose the theme prop explicitly in the component TypeScript/PropTypes interface',
|
|
499
|
+
]
|
|
500
|
+
},
|
|
436
501
|
constraints: {
|
|
437
502
|
mustBeFunctional: true,
|
|
438
503
|
mustSupportRequiredProps: true,
|
|
439
504
|
mustSupportCommonProps: true,
|
|
440
505
|
avoidBreakingChanges: true,
|
|
441
|
-
useProvidedHtmlAndCssIfAvailable: true
|
|
506
|
+
useProvidedHtmlAndCssIfAvailable: true,
|
|
507
|
+
mustBeGeneric: true,
|
|
508
|
+
mustBeProductionReady: true,
|
|
509
|
+
mustUseFramerMotionForAnimations: true,
|
|
510
|
+
stylingHandlerIsStrict: true
|
|
442
511
|
}
|
|
443
512
|
};
|
|
444
513
|
results.push({
|
|
@@ -447,6 +516,7 @@ function createMcpServer(apiKey, personalKey) {
|
|
|
447
516
|
requiredProps,
|
|
448
517
|
commonProps,
|
|
449
518
|
db: item._id,
|
|
519
|
+
styleHandler,
|
|
450
520
|
llmInstruction
|
|
451
521
|
});
|
|
452
522
|
}
|
|
@@ -456,7 +526,8 @@ function createMcpServer(apiKey, personalKey) {
|
|
|
456
526
|
text: JSON.stringify({
|
|
457
527
|
ok: true,
|
|
458
528
|
generated: 0,
|
|
459
|
-
|
|
529
|
+
styleHandler,
|
|
530
|
+
instruction: `IMPORTANTE: Este tool NO debe generar código ni escribir archivos. Solo entrega al LLM la especificación (componentType + props + stylingTechnology) para que el LLM implemente un componente GENÉRICO, reutilizable y listo para producción. OBLIGATORIO: usar ${styleLabel} para todos los estilos.`,
|
|
460
531
|
results
|
|
461
532
|
}, null, 2)
|
|
462
533
|
}]
|