@nbakka/mcp-appium 2.0.41 → 2.0.42

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/lib/server.js +53 -41
  2. package/package.json +1 -1
package/lib/server.js CHANGED
@@ -521,11 +521,10 @@ const createMcpServer = () => {
521
521
  }
522
522
  } catch (cleanupError) {
523
523
  // Continue if cleanup fails
524
- console.log('Could not clean existing files:', cleanupError.message);
525
524
  }
526
525
 
527
526
  // Get file information
528
- console.log('Fetching Figma file information...');
527
+ // Get file information
529
528
  const fileResponse = await axios.get(
530
529
  `https://api.figma.com/v1/files/${fileId}`,
531
530
  {
@@ -544,55 +543,68 @@ const createMcpServer = () => {
544
543
  return `No frames found in Figma file.`;
545
544
  }
546
545
 
547
- console.log(`Found ${frameIds.length} frames. Starting export...`);
548
-
549
- // Request image exports for frames only
550
- const exportResponse = await axios.get(
551
- `https://api.figma.com/v1/images/${fileId}`,
552
- {
553
- headers: {
554
- 'X-Figma-Token': figmaToken
555
- },
556
- params: {
557
- ids: frameIds.join(','),
558
- format: 'png',
559
- scale: 2
560
- }
561
- }
562
- );
546
+ // Limit to first 50 frames to avoid URI too long error
547
+ const limitedFrameIds = frameIds.slice(0, 50);
563
548
 
564
- const imageUrls = exportResponse.data.images;
565
549
  let successCount = 0;
550
+ const batchSize = 20; // Process in smaller batches to avoid 414 error
566
551
 
567
- // Download and save each image with sequential naming
568
- for (let i = 0; i < frameIds.length; i++) {
569
- const nodeId = frameIds[i];
570
- const imageUrl = imageUrls[nodeId];
571
-
572
- if (imageUrl) {
573
- try {
574
- const filename = `${i + 1}.png`;
575
- const filepath = path.join(exportPath, filename);
576
-
577
- // Download image
578
- const imageResponse = await axios.get(imageUrl, {
579
- responseType: 'arraybuffer'
580
- });
581
-
582
- // Save image to file
583
- await fs.writeFile(filepath, imageResponse.data);
584
- successCount++;
552
+ // Process frames in batches
553
+ for (let batchStart = 0; batchStart < limitedFrameIds.length; batchStart += batchSize) {
554
+ const batchEnd = Math.min(batchStart + batchSize, limitedFrameIds.length);
555
+ const batchIds = limitedFrameIds.slice(batchStart, batchEnd);
585
556
 
586
- console.log(`Exported: ${filename}`);
587
- } catch (downloadError) {
588
- console.error(`Failed to download frame ${i + 1}:`, downloadError.message);
557
+ try {
558
+ // Request image exports for current batch
559
+ const exportResponse = await axios.get(
560
+ `https://api.figma.com/v1/images/${fileId}`,
561
+ {
562
+ headers: {
563
+ 'X-Figma-Token': figmaToken
564
+ },
565
+ params: {
566
+ ids: batchIds.join(','),
567
+ format: 'png',
568
+ scale: 2
569
+ }
570
+ }
571
+ );
572
+
573
+ const imageUrls = exportResponse.data.images;
574
+
575
+ // Download and save each image in the batch
576
+ for (let i = 0; i < batchIds.length; i++) {
577
+ const nodeId = batchIds[i];
578
+ const imageUrl = imageUrls[nodeId];
579
+
580
+ if (imageUrl) {
581
+ try {
582
+ const frameNumber = batchStart + i + 1;
583
+ const filename = `${frameNumber}.png`;
584
+ const filepath = path.join(exportPath, filename);
585
+
586
+ // Download image
587
+ const imageResponse = await axios.get(imageUrl, {
588
+ responseType: 'arraybuffer'
589
+ });
590
+
591
+ // Save image to file
592
+ await fs.writeFile(filepath, imageResponse.data);
593
+ successCount++;
594
+ } catch (downloadError) {
595
+ // Continue with next image if one fails
596
+ }
597
+ }
589
598
  }
599
+ } catch (batchError) {
600
+ // Continue with next batch if one fails
590
601
  }
591
602
  }
592
603
 
593
604
  return `Figma Export Complete!
594
605
  Export Path: ${exportPath}
595
- Successfully exported: ${successCount}/${frameIds.length} frames as PNG files
606
+ Total frames in file: ${frameIds.length}
607
+ Exported first: ${successCount} frames as PNG files (limited to 50 max)
596
608
  Files: ${Array.from({length: successCount}, (_, i) => `${i + 1}.png`).join(', ')}`;
597
609
 
598
610
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nbakka/mcp-appium",
3
- "version": "2.0.41",
3
+ "version": "2.0.42",
4
4
  "description": "Appium MCP",
5
5
  "engines": {
6
6
  "node": ">=18"