viewgate-mcp 1.0.59 → 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.
- package/dist/index.js +26 -44
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -398,38 +398,35 @@ function createMcpServer(apiKey, personalKey) {
|
|
|
398
398
|
const errorBody = await response.text();
|
|
399
399
|
throw new Error(`Backend responded with ${response.status}: ${errorBody}`);
|
|
400
400
|
}
|
|
401
|
-
const data = await response.json();
|
|
402
|
-
|
|
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) }] };
|
|
403
406
|
}
|
|
404
407
|
case "generate_ui_components": {
|
|
405
408
|
const args = argsAny;
|
|
406
409
|
const limit = Math.min(args.limit || 1, 10);
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
...(personalKey ? { 'x-personal-key': personalKey } : {})
|
|
416
|
-
}
|
|
417
|
-
});
|
|
418
|
-
if (configRes.ok) {
|
|
419
|
-
const configData = (await configRes.json());
|
|
420
|
-
const projectStyle = configData?.settings?.styleHandler;
|
|
421
|
-
if (!isOverridden && projectStyle) {
|
|
422
|
-
styleHandler = projectStyle;
|
|
423
|
-
}
|
|
424
|
-
console.error(`[MCP] Style handler identified: ${styleHandler} (Project: ${configData?.settings?.projectName || 'unknown'}, Overridden: ${isOverridden})`);
|
|
425
|
-
}
|
|
426
|
-
else {
|
|
427
|
-
console.error(`[MCP] Could not fetch project config, status: ${configRes.status}. Defaulting to: ${styleHandler}`);
|
|
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 } : {})
|
|
428
418
|
}
|
|
419
|
+
});
|
|
420
|
+
if (!response.ok) {
|
|
421
|
+
const errorBody = await response.text();
|
|
422
|
+
throw new Error(`Backend responded with ${response.status}: ${errorBody}`);
|
|
429
423
|
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
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;
|
|
433
430
|
const styleHandlerLabels = {
|
|
434
431
|
'css': 'Plain CSS (vanilla, no framework dependencies)',
|
|
435
432
|
'sass': 'SASS/SCSS (use .scss syntax conventions in comments, output as CSS-in-string or inline styles for compatibility)',
|
|
@@ -451,22 +448,6 @@ function createMcpServer(apiKey, personalKey) {
|
|
|
451
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.`,
|
|
452
449
|
};
|
|
453
450
|
const themingInstruction = themingByHandler[styleHandler] ?? themingByHandler['css'];
|
|
454
|
-
const fetchUrl = new URL(`${BACKEND_URL}/api/mcp/components`);
|
|
455
|
-
fetchUrl.searchParams.append("limit", limit.toString());
|
|
456
|
-
fetchUrl.searchParams.append("status", "pending");
|
|
457
|
-
const response = await fetch(fetchUrl, {
|
|
458
|
-
headers: {
|
|
459
|
-
'x-api-key': apiKey,
|
|
460
|
-
'x-mcp-tool-name': toolName,
|
|
461
|
-
...(personalKey ? { 'x-personal-key': personalKey } : {})
|
|
462
|
-
}
|
|
463
|
-
});
|
|
464
|
-
if (!response.ok) {
|
|
465
|
-
const errorBody = await response.text();
|
|
466
|
-
throw new Error(`Backend responded with ${response.status}: ${errorBody}`);
|
|
467
|
-
}
|
|
468
|
-
const payload = (await response.json());
|
|
469
|
-
const items = payload?.data || [];
|
|
470
451
|
if (!Array.isArray(items) || items.length === 0) {
|
|
471
452
|
return { content: [{ type: "text", text: JSON.stringify({ ok: true, generated: 0, message: "No pending UI components." }, null, 2) }] };
|
|
472
453
|
}
|
|
@@ -576,8 +557,9 @@ function createMcpServer(apiKey, personalKey) {
|
|
|
576
557
|
const errorBody = await response.text();
|
|
577
558
|
throw new Error(`Backend responded with ${response.status}: ${errorBody}`);
|
|
578
559
|
}
|
|
579
|
-
const data = await response.json();
|
|
580
|
-
|
|
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) }] };
|
|
581
563
|
}
|
|
582
564
|
case "get_annotations": {
|
|
583
565
|
const args = argsAny;
|