viewgate-mcp 1.0.13 → 1.0.15

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 +94 -1
  2. package/package.json +40 -40
package/dist/index.js CHANGED
@@ -142,6 +142,17 @@ 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
+ }
145
156
  }
146
157
  ],
147
158
  };
@@ -214,8 +225,12 @@ function createMcpServer(apiKey, personalKey) {
214
225
  componentPath: ann.reference?.componentPath,
215
226
  selector: ann.reference?.selector,
216
227
  tag: ann.reference?.tag,
228
+ figmaReference: ann.figmaReference,
217
229
  backendEndpoints: ann.backendEndpoints || [ann.backendEndpoint].filter(Boolean),
218
- _ia_fix_instruction: `### 🔬 SURGICAL FIX PROTOCOL (Language: ${data.preferredLanguage || 'en'})
230
+ _ia_fix_instruction: `### 🎨 DESIGN CONTEXT (Figma)
231
+ ${ann.figmaReference ? `A design reference is available: ${ann.figmaReference}. Use the 'get_figma_preview' tool to fetch design details and image previews before implementing.` : 'No explicit figma design linked.'}
232
+
233
+ ### 🔬 SURGICAL FIX PROTOCOL (Language: ${data.preferredLanguage || 'en'})
219
234
  1. **PRIMARY**: Search for \`data-vg-id="${ann.reference?.vgId}"\`.
220
235
  2. **SECONDARY**: Check \`${file}\` L${line} (Fiber Source).
221
236
  3. **TERTIARY**: Match Tag(\`${ann.reference?.tag}\`) + Role(\`${ann.reference?.fingerprint?.role}\`) + Text("${ann.reference?.text?.slice(0, 30)}").
@@ -390,6 +405,84 @@ Instruction: ${ann.message}`
390
405
  };
391
406
  }
392
407
  }
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[2];
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].replace('%3A', ':');
444
+ }
445
+ // 3. Fetch Data from Figma
446
+ // First get file info
447
+ const figmaApiUrl = `https://api.figma.com/v1/files/${fileKey}${nodeId ? `?ids=${nodeId}` : ''}`;
448
+ const figmaResponse = await fetch(figmaApiUrl, {
449
+ headers: { 'X-Figma-Token': figmaToken }
450
+ });
451
+ if (!figmaResponse.ok) {
452
+ throw new Error(`Figma API returned ${figmaResponse.status}: ${await figmaResponse.text()}`);
453
+ }
454
+ const figmaData = (await figmaResponse.json());
455
+ // 4. Optionally fetch image preview if a node is specified
456
+ let imageUrl = null;
457
+ if (nodeId) {
458
+ const imageResponse = await fetch(`https://api.figma.com/v1/images/${fileKey}?ids=${nodeId}&scale=2&format=png`, {
459
+ headers: { 'X-Figma-Token': figmaToken }
460
+ });
461
+ if (imageResponse.ok) {
462
+ const imageData = await imageResponse.json();
463
+ imageUrl = imageData.images?.[nodeId];
464
+ }
465
+ }
466
+ return {
467
+ content: [{
468
+ type: "text",
469
+ text: JSON.stringify({
470
+ fileName: figmaData.name,
471
+ lastModified: figmaData.lastModified,
472
+ previewUrl: imageUrl,
473
+ nodeName: nodeId ? (figmaData.nodes?.[nodeId]?.document?.name || 'Selected Component') : 'Full File',
474
+ note: "Design context successfully retrieved from Figma."
475
+ }, null, 2)
476
+ }]
477
+ };
478
+ }
479
+ catch (error) {
480
+ return {
481
+ content: [{ type: "text", text: `Error fetching Figma preview: ${error.message}` }],
482
+ isError: true
483
+ };
484
+ }
485
+ }
393
486
  default:
394
487
  throw new Error("Unknown tool");
395
488
  }
package/package.json CHANGED
@@ -1,40 +1,40 @@
1
- {
2
- "name": "viewgate-mcp",
3
- "version": "1.0.13",
4
- "main": "dist/index.js",
5
- "bin": {
6
- "viewgate-mcp": "./dist/index.js"
7
- },
8
- "files": [
9
- "dist"
10
- ],
11
- "type": "module",
12
- "scripts": {
13
- "build": "tsc",
14
- "watch": "tsc -w",
15
- "start": "node dist/index.js",
16
- "dev": "tsx watch src/index.ts",
17
- "test": "echo \"Error: no test specified\" && exit 1"
18
- },
19
- "keywords": [],
20
- "author": "",
21
- "license": "ISC",
22
- "description": "",
23
- "dependencies": {
24
- "@modelcontextprotocol/sdk": "^1.27.1",
25
- "cors": "^2.8.6",
26
- "dotenv": "^17.3.1",
27
- "express": "^5.2.1",
28
- "node-fetch": "^3.3.2"
29
- },
30
- "devDependencies": {
31
- "@types/cors": "^2.8.19",
32
- "@types/express": "^5.0.6",
33
- "@types/node": "^25.5.0",
34
- "@types/node-fetch": "^2.6.13",
35
- "nodemon": "^3.1.14",
36
- "ts-node": "^10.9.2",
37
- "tsx": "^4.21.0",
38
- "typescript": "^5.9.3"
39
- }
40
- }
1
+ {
2
+ "name": "viewgate-mcp",
3
+ "version": "1.0.15",
4
+ "main": "dist/index.js",
5
+ "bin": {
6
+ "viewgate-mcp": "./dist/index.js"
7
+ },
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "type": "module",
12
+ "scripts": {
13
+ "build": "tsc",
14
+ "watch": "tsc -w",
15
+ "start": "node dist/index.js",
16
+ "dev": "tsx watch src/index.ts",
17
+ "test": "echo \"Error: no test specified\" && exit 1"
18
+ },
19
+ "keywords": [],
20
+ "author": "",
21
+ "license": "ISC",
22
+ "description": "",
23
+ "dependencies": {
24
+ "@modelcontextprotocol/sdk": "^1.27.1",
25
+ "cors": "^2.8.6",
26
+ "dotenv": "^17.3.1",
27
+ "express": "^5.2.1",
28
+ "node-fetch": "^3.3.2"
29
+ },
30
+ "devDependencies": {
31
+ "@types/cors": "^2.8.19",
32
+ "@types/express": "^5.0.6",
33
+ "@types/node": "^25.5.0",
34
+ "@types/node-fetch": "^2.6.13",
35
+ "nodemon": "^3.1.14",
36
+ "ts-node": "^10.9.2",
37
+ "tsx": "^4.21.0",
38
+ "typescript": "^5.9.3"
39
+ }
40
+ }