@nbakka/mcp-appium 2.0.52 → 2.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/lib/server.js +39 -18
- package/package.json +1 -1
package/lib/server.js
CHANGED
|
@@ -476,20 +476,33 @@ const createMcpServer = () => {
|
|
|
476
476
|
}
|
|
477
477
|
|
|
478
478
|
// ----------------------
|
|
479
|
-
// Helper: Extract File ID
|
|
479
|
+
// Helper: Extract File ID & Node ID
|
|
480
480
|
// ----------------------
|
|
481
|
-
function
|
|
481
|
+
function extractFileAndNodeId(url) {
|
|
482
482
|
const patterns = [
|
|
483
483
|
/figma\.com\/file\/([a-zA-Z0-9]+)/,
|
|
484
484
|
/figma\.com\/design\/([a-zA-Z0-9]+)/,
|
|
485
485
|
/figma\.com\/proto\/([a-zA-Z0-9]+)/
|
|
486
486
|
];
|
|
487
487
|
|
|
488
|
+
let fileId = null;
|
|
488
489
|
for (const pattern of patterns) {
|
|
489
490
|
const match = url.match(pattern);
|
|
490
|
-
if (match)
|
|
491
|
+
if (match) {
|
|
492
|
+
fileId = match[1];
|
|
493
|
+
break;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
// Extract node-id if present
|
|
498
|
+
const nodeMatch = url.match(/[?&]node-id=([^&]+)/);
|
|
499
|
+
let nodeId = null;
|
|
500
|
+
if (nodeMatch) {
|
|
501
|
+
// Replace dash with colon (Figma expects 13:5951 instead of 13-5951)
|
|
502
|
+
nodeId = decodeURIComponent(nodeMatch[1]).replace(/-/g, ":");
|
|
491
503
|
}
|
|
492
|
-
|
|
504
|
+
|
|
505
|
+
return { fileId, nodeId };
|
|
493
506
|
}
|
|
494
507
|
|
|
495
508
|
// ----------------------
|
|
@@ -510,31 +523,38 @@ tool(
|
|
|
510
523
|
|
|
511
524
|
if (!figmaToken) throw new Error("Figma API token missing in figma.json");
|
|
512
525
|
|
|
513
|
-
// Extract
|
|
514
|
-
const fileId =
|
|
526
|
+
// Extract fileId and nodeId from URL
|
|
527
|
+
const { fileId, nodeId } = extractFileAndNodeId(figmaUrl);
|
|
515
528
|
if (!fileId) throw new Error("Invalid Figma URL - cannot extract fileId");
|
|
516
529
|
|
|
517
|
-
|
|
518
|
-
const fileResponse = await axios.get(
|
|
519
|
-
`https://api.figma.com/v1/files/${fileId}`,
|
|
520
|
-
{ headers: { "X-Figma-Token": figmaToken } }
|
|
521
|
-
);
|
|
530
|
+
let idsToExport = [];
|
|
522
531
|
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
532
|
+
if (nodeId) {
|
|
533
|
+
// Use node-id directly from URL
|
|
534
|
+
idsToExport = [nodeId];
|
|
535
|
+
} else {
|
|
536
|
+
// Fallback: scan file to collect all top-level frames
|
|
537
|
+
const fileResponse = await axios.get(
|
|
538
|
+
`https://api.figma.com/v1/files/${fileId}`,
|
|
539
|
+
{ headers: { "X-Figma-Token": figmaToken } }
|
|
540
|
+
);
|
|
541
|
+
|
|
542
|
+
fileResponse.data.document.children?.forEach(page => {
|
|
543
|
+
page.children?.forEach(child => {
|
|
544
|
+
if (child.type === "FRAME") idsToExport.push(child.id);
|
|
545
|
+
});
|
|
527
546
|
});
|
|
528
|
-
});
|
|
529
547
|
|
|
530
|
-
|
|
548
|
+
if (idsToExport.length === 0)
|
|
549
|
+
throw new Error("No frames found in Figma file");
|
|
550
|
+
}
|
|
531
551
|
|
|
532
552
|
// Request PDF export
|
|
533
553
|
const exportResponse = await axios.get(
|
|
534
554
|
`https://api.figma.com/v1/images/${fileId}`,
|
|
535
555
|
{
|
|
536
556
|
headers: { "X-Figma-Token": figmaToken },
|
|
537
|
-
params: { ids:
|
|
557
|
+
params: { ids: idsToExport.join(","), format: "pdf" }
|
|
538
558
|
}
|
|
539
559
|
);
|
|
540
560
|
|
|
@@ -558,6 +578,7 @@ tool(
|
|
|
558
578
|
}
|
|
559
579
|
);
|
|
560
580
|
|
|
581
|
+
|
|
561
582
|
// ----------------------
|
|
562
583
|
// TOOL 2: Upload PDF to OpenAI with Jira Info
|
|
563
584
|
// ----------------------
|