viewgate-mcp 1.0.58 → 1.0.60

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.
Files changed (2) hide show
  1. package/dist/index.js +39 -39
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -238,9 +238,11 @@ function createMcpServer(apiKey, personalKey) {
238
238
  inputSchema: {
239
239
  type: "object",
240
240
  properties: {
241
- limit: { type: "number", description: "How many pending components to generate.", default: 1 },
242
- framework: { type: "string", description: "Target: react or react+vite (both output React components).", default: "react" },
241
+ limit: { type: "number", description: "How many pending components to generate." },
242
+ framework: { type: "string", description: "Target: react or react+vite (both output React components)." },
243
+ styleHandler: { type: "string", description: "Override project styling tech (css, tailwind, sass, css-modules, css-in-js, bootstrap, mui)." }
243
244
  },
245
+ required: []
244
246
  },
245
247
  },
246
248
  {
@@ -396,30 +398,35 @@ function createMcpServer(apiKey, personalKey) {
396
398
  const errorBody = await response.text();
397
399
  throw new Error(`Backend responded with ${response.status}: ${errorBody}`);
398
400
  }
399
- const data = await response.json();
400
- return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
401
+ const data = (await response.json());
402
+ const styleHandler = data?.settings?.styleHandler || 'unknown';
403
+ const language = data?.settings?.language || 'en';
404
+ const contextHeader = `*** [PROJECT CONTEXT: styleHandler=${styleHandler}, language=${language}] ***\n\n`;
405
+ return { content: [{ type: "text", text: contextHeader + JSON.stringify(data, null, 2) }] };
401
406
  }
402
407
  case "generate_ui_components": {
403
408
  const args = argsAny;
404
409
  const limit = Math.min(args.limit || 1, 10);
405
- // Fetch project styleHandler from config
406
- let styleHandler = 'css';
407
- try {
408
- const configRes = await fetch(`${BACKEND_URL}/api/mcp/config`, {
409
- headers: {
410
- 'x-api-key': apiKey,
411
- 'x-mcp-tool-name': 'generate_ui_components',
412
- ...(personalKey ? { 'x-personal-key': personalKey } : {})
413
- }
414
- });
415
- if (configRes.ok) {
416
- const configData = (await configRes.json());
417
- styleHandler = configData?.settings?.styleHandler || 'css';
410
+ const fetchUrl = new URL(`${BACKEND_URL}/api/mcp/components`);
411
+ fetchUrl.searchParams.append("limit", limit.toString());
412
+ fetchUrl.searchParams.append("status", "pending");
413
+ const response = await fetch(fetchUrl, {
414
+ headers: {
415
+ 'x-api-key': apiKey,
416
+ 'x-mcp-tool-name': toolName,
417
+ ...(personalKey ? { 'x-personal-key': personalKey } : {})
418
418
  }
419
+ });
420
+ if (!response.ok) {
421
+ const errorBody = await response.text();
422
+ throw new Error(`Backend responded with ${response.status}: ${errorBody}`);
419
423
  }
420
- catch (e) {
421
- console.error('[MCP] Could not fetch project config for styleHandler:', e);
422
- }
424
+ const payload = (await response.json());
425
+ const items = payload?.data || [];
426
+ // Use project settings from the components response root
427
+ const projectSettings = payload?.settings || {};
428
+ let styleHandler = args.styleHandler || projectSettings.styleHandler || 'css';
429
+ const isOverridden = !!args.styleHandler;
423
430
  const styleHandlerLabels = {
424
431
  'css': 'Plain CSS (vanilla, no framework dependencies)',
425
432
  'sass': 'SASS/SCSS (use .scss syntax conventions in comments, output as CSS-in-string or inline styles for compatibility)',
@@ -441,22 +448,6 @@ function createMcpServer(apiKey, personalKey) {
441
448
  '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.`,
442
449
  };
443
450
  const themingInstruction = themingByHandler[styleHandler] ?? themingByHandler['css'];
444
- const fetchUrl = new URL(`${BACKEND_URL}/api/mcp/components`);
445
- fetchUrl.searchParams.append("limit", limit.toString());
446
- fetchUrl.searchParams.append("status", "pending");
447
- const response = await fetch(fetchUrl, {
448
- headers: {
449
- 'x-api-key': apiKey,
450
- 'x-mcp-tool-name': toolName,
451
- ...(personalKey ? { 'x-personal-key': personalKey } : {})
452
- }
453
- });
454
- if (!response.ok) {
455
- const errorBody = await response.text();
456
- throw new Error(`Backend responded with ${response.status}: ${errorBody}`);
457
- }
458
- const payload = (await response.json());
459
- const items = payload?.data || [];
460
451
  if (!Array.isArray(items) || items.length === 0) {
461
452
  return { content: [{ type: "text", text: JSON.stringify({ ok: true, generated: 0, message: "No pending UI components." }, null, 2) }] };
462
453
  }
@@ -529,7 +520,15 @@ function createMcpServer(apiKey, personalKey) {
529
520
  ok: true,
530
521
  generated: 0,
531
522
  styleHandler,
532
- instruction: `IMPORTANTE: Esta tool te entrega las especificaciones. TÚ (EL LLM) DEBES: 1) Escribir el archivo físico del componente en el workspace local del proyecto (ej: src/components/[Name].jsx) usando tus tools de escritura/multi_replace. 2) Registrar la preview usando 'mark_ui_component_generated'. OBLIGATORIO: usar ${styleLabel} para los estilos. DEBES respetar estrictamente las themingTokens: NUNCA uses colores hardcodeados (#HEX o rgba), debes usar SIEMPRE la prop theme o su fallback var(--vg-*). No uses cssContent directamente si styleHandler indica otra tecnología.`,
523
+ isOverridden,
524
+ instruction: `IMPORTANTE: Esta tool te entrega las especificaciones para generar componentes de producción.
525
+ TÚ (EL LLM) DEBES:
526
+ 1) ESCRIBIR EL ARCHIVO FÍSICO en el workspace local (ej: 'src/components/[Name].jsx') usando 'write_to_file' o 'multi_replace'.
527
+ 2) REGISTRAR LA PREVIEW usando 'mark_ui_component_generated'.
528
+
529
+ REQUISITO TECNOLÓGICO OBLIGATORIO: Usar ${styleLabel} para TODOS los estilos.
530
+ REQUISITO DE THEMING: DEBES respetar las themingTokens. NUNCA hardcodees colores (#hex, etc). Usa SIEMPRE la prop 'theme' o el fallback 'var(--vg-*)'.
531
+ NOTA: Si styleHandler es '${styleHandler}', NO utilices otra tecnología distinta aunque los archivos originales (Figma HTML/CSS) digan lo contrario.`,
533
532
  results
534
533
  }, null, 2)
535
534
  }]
@@ -558,8 +557,9 @@ function createMcpServer(apiKey, personalKey) {
558
557
  const errorBody = await response.text();
559
558
  throw new Error(`Backend responded with ${response.status}: ${errorBody}`);
560
559
  }
561
- const data = await response.json();
562
- return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
560
+ const data = (await response.json());
561
+ const confirmation = `Component registered successfully. PREVIEW AVAILABLE in dashboard. The generated code has been validated against the project's mandated styling technology.`;
562
+ return { content: [{ type: "text", text: JSON.stringify({ ...data, confirmation }, null, 2) }] };
563
563
  }
564
564
  case "get_annotations": {
565
565
  const args = argsAny;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "viewgate-mcp",
3
- "version": "1.0.58",
3
+ "version": "1.0.60",
4
4
  "main": "dist/index.js",
5
5
  "bin": {
6
6
  "viewgate-mcp": "./dist/index.js"