viewgate-mcp 1.0.16 → 1.0.18
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 +12 -105
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -142,17 +142,6 @@ function createMcpServer(apiKey, personalKey) {
|
|
|
142
142
|
type: "object",
|
|
143
143
|
properties: {},
|
|
144
144
|
},
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
name: "get_figma_preview",
|
|
148
|
-
description: "Fetches design metadata and image previews from a Figma URL using the project's centralized access token. Use this to understand the UX requirements without needing local Figma configuration. The Figma token must be configured in the ViewGate dashboard under Settings > Integrations.",
|
|
149
|
-
inputSchema: {
|
|
150
|
-
type: "object",
|
|
151
|
-
properties: {
|
|
152
|
-
url: { type: "string", description: "The Figma design or file URL" }
|
|
153
|
-
},
|
|
154
|
-
required: ["url"]
|
|
155
|
-
}
|
|
156
145
|
}
|
|
157
146
|
],
|
|
158
147
|
};
|
|
@@ -227,18 +216,18 @@ function createMcpServer(apiKey, personalKey) {
|
|
|
227
216
|
tag: ann.reference?.tag,
|
|
228
217
|
figmaReference: ann.figmaReference,
|
|
229
218
|
backendEndpoints: ann.backendEndpoints || [ann.backendEndpoint].filter(Boolean),
|
|
230
|
-
_ia_fix_instruction: `### 🎨 DESIGN CONTEXT (Figma)
|
|
231
|
-
${ann.figmaReference ? `A design reference is available: ${
|
|
232
|
-
|
|
233
|
-
### 🔬 SURGICAL FIX PROTOCOL (Language: ${data.preferredLanguage || 'en'})
|
|
234
|
-
1. **PRIMARY**: Search for \`data-vg-id="${ann.reference?.vgId}"\`.
|
|
235
|
-
2. **SECONDARY**: Check \`${file}\` L${line} (Fiber Source).
|
|
236
|
-
3. **TERTIARY**: Match Tag(\`${ann.reference?.tag}\`) + Role(\`${ann.reference?.fingerprint?.role}\`) + Text("${ann.reference?.text?.slice(0, 30)}").
|
|
237
|
-
4. **VALIDATE**: Confirm parent context matches \`${ann.reference?.parentContext?.slice(0, 50).replace(/`/g, "'")}...\`.
|
|
238
|
-
|
|
239
|
-
IMPORTANT: All your analysis and implementation comments MUST BE IN ${data.preferredLanguage === 'es' ? 'SPANISH' : 'ENGLISH'}.
|
|
240
|
-
|
|
241
|
-
Confidence: [vgId: ${ann.reference?.confidence?.vgId || 0}, Fiber: ${ann.reference?.confidence?.fiber || 0}, Fingerprint: ${ann.reference?.confidence?.fingerprint || 0}]
|
|
219
|
+
_ia_fix_instruction: `### 🎨 DESIGN CONTEXT (Figma)
|
|
220
|
+
${ann.figmaReference ? `A design reference is available: ${ann.figmaReference}. Use the Figma link to understand the UX requirements.` : 'No explicit figma design linked.'}
|
|
221
|
+
|
|
222
|
+
### 🔬 SURGICAL FIX PROTOCOL (Language: ${data.preferredLanguage || 'en'})
|
|
223
|
+
1. **PRIMARY**: Search for \`data-vg-id="${ann.reference?.vgId}"\`.
|
|
224
|
+
2. **SECONDARY**: Check \`${file}\` L${line} (Fiber Source).
|
|
225
|
+
3. **TERTIARY**: Match Tag(\`${ann.reference?.tag}\`) + Role(\`${ann.reference?.fingerprint?.role}\`) + Text("${ann.reference?.text?.slice(0, 30)}").
|
|
226
|
+
4. **VALIDATE**: Confirm parent context matches \`${ann.reference?.parentContext?.slice(0, 50).replace(/`/g, "'")}...\`.
|
|
227
|
+
|
|
228
|
+
IMPORTANT: All your analysis and implementation comments MUST BE IN ${data.preferredLanguage === 'es' ? 'SPANISH' : 'ENGLISH'}.
|
|
229
|
+
|
|
230
|
+
Confidence: [vgId: ${ann.reference?.confidence?.vgId || 0}, Fiber: ${ann.reference?.confidence?.fiber || 0}, Fingerprint: ${ann.reference?.confidence?.fingerprint || 0}]
|
|
242
231
|
Instruction: ${ann.message}`
|
|
243
232
|
};
|
|
244
233
|
});
|
|
@@ -405,88 +394,6 @@ Instruction: ${ann.message}`
|
|
|
405
394
|
};
|
|
406
395
|
}
|
|
407
396
|
}
|
|
408
|
-
case "get_figma_preview": {
|
|
409
|
-
try {
|
|
410
|
-
const args = request.params.arguments;
|
|
411
|
-
const url = args.url;
|
|
412
|
-
// 1. Get Figma Token from Backend Config
|
|
413
|
-
const configResponse = await fetch(`${BACKEND_URL}/api/mcp/config`, {
|
|
414
|
-
headers: {
|
|
415
|
-
'x-api-key': apiKey,
|
|
416
|
-
...(personalKey ? { 'x-personal-key': personalKey } : {})
|
|
417
|
-
}
|
|
418
|
-
});
|
|
419
|
-
if (!configResponse.ok) {
|
|
420
|
-
throw new Error(`Failed to fetch project configuration: ${configResponse.status}`);
|
|
421
|
-
}
|
|
422
|
-
const configData = (await configResponse.json());
|
|
423
|
-
const figmaToken = configData?.settings?.figmaToken;
|
|
424
|
-
if (!figmaToken) {
|
|
425
|
-
return {
|
|
426
|
-
content: [{
|
|
427
|
-
type: "text",
|
|
428
|
-
text: "Figma integration is not fully configured. Please add a Figma Access Token in the ViewGate Dashboard (Settings > Integrations)."
|
|
429
|
-
}],
|
|
430
|
-
isError: true
|
|
431
|
-
};
|
|
432
|
-
}
|
|
433
|
-
// 2. Parse Figma URL
|
|
434
|
-
const fileKeyMatch = url.match(/(?:file|design)\/([a-zA-Z0-9]+)/);
|
|
435
|
-
if (!fileKeyMatch) {
|
|
436
|
-
throw new Error("Invalid Figma URL format. File key not found.");
|
|
437
|
-
}
|
|
438
|
-
const fileKey = fileKeyMatch[1];
|
|
439
|
-
// Extract node-id if present
|
|
440
|
-
const urlObj = new URL(url.replace(/#/g, '?')); // Handle hash-based node-id
|
|
441
|
-
let nodeId = urlObj.searchParams.get('node-id') || urlObj.searchParams.get('m');
|
|
442
|
-
if (!nodeId && url.includes('node-id=')) {
|
|
443
|
-
nodeId = url.split('node-id=')[1].split('&')[0];
|
|
444
|
-
}
|
|
445
|
-
// Figma API expects node-id with : instead of - (which is used in browser URL)
|
|
446
|
-
if (nodeId) {
|
|
447
|
-
nodeId = nodeId.replace(/%3A/g, ':').replace(/-/g, ':');
|
|
448
|
-
}
|
|
449
|
-
// 3. Fetch Data from Figma
|
|
450
|
-
// First get file info
|
|
451
|
-
const figmaApiUrl = `https://api.figma.com/v1/files/${fileKey}${nodeId ? `?ids=${nodeId}` : ''}`;
|
|
452
|
-
const figmaResponse = await fetch(figmaApiUrl, {
|
|
453
|
-
headers: { 'X-Figma-Token': figmaToken }
|
|
454
|
-
});
|
|
455
|
-
if (!figmaResponse.ok) {
|
|
456
|
-
throw new Error(`Figma API returned ${figmaResponse.status}: ${await figmaResponse.text()}`);
|
|
457
|
-
}
|
|
458
|
-
const figmaData = (await figmaResponse.json());
|
|
459
|
-
// 4. Optionally fetch image preview if a node is specified
|
|
460
|
-
let imageUrl = null;
|
|
461
|
-
if (nodeId) {
|
|
462
|
-
const imageResponse = await fetch(`https://api.figma.com/v1/images/${fileKey}?ids=${nodeId}&scale=2&format=png`, {
|
|
463
|
-
headers: { 'X-Figma-Token': figmaToken }
|
|
464
|
-
});
|
|
465
|
-
if (imageResponse.ok) {
|
|
466
|
-
const imageData = await imageResponse.json();
|
|
467
|
-
imageUrl = imageData.images?.[nodeId];
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
return {
|
|
471
|
-
content: [{
|
|
472
|
-
type: "text",
|
|
473
|
-
text: JSON.stringify({
|
|
474
|
-
fileName: figmaData.name,
|
|
475
|
-
lastModified: figmaData.lastModified,
|
|
476
|
-
previewUrl: imageUrl,
|
|
477
|
-
nodeName: nodeId ? (figmaData.nodes?.[nodeId]?.document?.name || 'Selected Component') : 'Full File',
|
|
478
|
-
note: "Design context successfully retrieved from Figma."
|
|
479
|
-
}, null, 2)
|
|
480
|
-
}]
|
|
481
|
-
};
|
|
482
|
-
}
|
|
483
|
-
catch (error) {
|
|
484
|
-
return {
|
|
485
|
-
content: [{ type: "text", text: `Error fetching Figma preview: ${error.message}` }],
|
|
486
|
-
isError: true
|
|
487
|
-
};
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
397
|
default:
|
|
491
398
|
throw new Error("Unknown tool");
|
|
492
399
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "viewgate-mcp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.18",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"bin": {
|
|
6
6
|
"viewgate-mcp": "./dist/index.js"
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"license": "ISC",
|
|
22
22
|
"description": "",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
24
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
25
25
|
"cors": "^2.8.6",
|
|
26
26
|
"dotenv": "^17.3.1",
|
|
27
27
|
"express": "^5.2.1",
|
|
@@ -37,4 +37,4 @@
|
|
|
37
37
|
"tsx": "^4.21.0",
|
|
38
38
|
"typescript": "^5.9.3"
|
|
39
39
|
}
|
|
40
|
-
}
|
|
40
|
+
}
|