Skip to main content
Glama
UNIVERSAL_IDE_COMPATIBILITY.md•13.7 kB
# Universal IDE Compatibility Improvements ## Overview This document outlines the comprehensive improvements made to ensure the Figma MCP Server works consistently across all IDEs (Cursor, Windsurf, TRAE, etc.) and all platforms (Windows, macOS, Linux). The changes specifically address image download functionality and cross-platform compatibility issues that were previously breaking in some environments. ## Core Problems Solved ### 1. **Inconsistent Path Resolution** - **Problem**: Different IDEs handle working directories differently, causing path resolution to fail - **Solution**: Implemented universal path resolution with multiple environment variable fallbacks ### 2. **IDE-Specific Environment Variables** - **Problem**: Each IDE sets different environment variables for project context - **Solution**: Added fallback chain checking multiple IDE-specific variables ### 3. **Directory Creation Issues** - **Problem**: Some IDEs have restricted filesystem access or different permission models - **Solution**: Enhanced directory creation with verification and permission testing ### 4. **Asset Verification** - **Problem**: No way to confirm assets were actually created in the expected location - **Solution**: Added post-download verification system with relative path mapping ### 5. **Cross-Platform Compatibility Issues** - **Problem**: Path separators, permissions, and environment variables differed between Windows, macOS, and Linux - **Solution**: Implemented universal path handling with platform-specific adaptations ## Platform Support (Windows, macOS, Linux) ### Cross-Platform Fixes Implemented The Figma MCP Server now provides full cross-platform compatibility with specific fixes for platform differences: #### **Path Handling** ```typescript // Universal path resolution using Node.js path module import { join, resolve, sep } from 'path'; // Before: Platform-specific path issues const assetPath = localPath + '/' + filename; // āŒ Failed on Windows // After: Universal path handling const assetPath = join(localPath, filename); // āœ… Works on all platforms ``` #### **File Permissions** - **Windows**: Uses default file system permissions (no chmod required) - **macOS/Linux**: Sets explicit permissions (`0o755` for directories, `0o644` for files) - **Universal**: Automatic permission detection and application #### **Environment Variables** Platform-specific environment variable support: | Platform | Primary Variables | Fallback Variables | |----------|------------------|-------------------| | Windows | `USERPROFILE`, `APPDATA`, `LOCALAPPDATA` | `PWD`, `INIT_CWD` | | macOS | `HOME`, `PWD`, `TMPDIR` | `npm_config_prefix` | | Linux | `HOME`, `PWD`, `XDG_DATA_HOME` | `INIT_CWD` | #### **Shell Script Compatibility** ```bash # Cross-platform test script with compatibility layer #!/bin/bash # Works on: macOS, Linux, Windows (Git Bash, WSL) # Platform detection case "$(uname -s)" in CYGWIN*|MINGW*|MSYS*) PLATFORM="windows" ;; Darwin*) PLATFORM="macos" ;; Linux*) PLATFORM="linux" ;; *) PLATFORM="unknown" ;; esac ``` #### **Line Ending Normalization** - **Automatic detection**: Handles CRLF (Windows) and LF (Unix) line endings - **Git configuration**: Proper `.gitattributes` for consistent line endings - **File processing**: Normalizes line endings in downloaded assets ### Platform-Specific Features #### **Windows Support** āœ… **Full Windows 10/11 compatibility** - PowerShell and Command Prompt support - Windows Subsystem for Linux (WSL) compatibility - UNC path handling for network drives - Windows-style environment variables (`%APPDATA%`, `%USERPROFILE%`) ```javascript // Windows-specific path resolution if (process.platform === 'win32') { workingDir = process.env.USERPROFILE || process.env.APPDATA || workingDir; } ``` #### **macOS Support** āœ… **macOS 10.15+ (Catalina and newer)** - Homebrew installation compatibility - macOS security permissions (Gatekeeper) - Apple Silicon (M1/M2) and Intel support - macOS-specific path conventions ```javascript // macOS-specific optimizations if (process.platform === 'darwin') { // Use macOS-specific temporary directory const tempDir = process.env.TMPDIR || '/tmp'; } ``` #### **Linux Support** āœ… **Ubuntu, Debian, CentOS, Fedora, Arch Linux** - Standard Linux filesystem permissions - XDG Base Directory specification compliance - Snap, AppImage, and native package support - Container environment compatibility (Docker, Podman) ```javascript // Linux-specific path handling if (process.platform === 'linux') { // Follow XDG Base Directory specification const dataDir = process.env.XDG_DATA_HOME || join(process.env.HOME, '.local/share'); } ``` ## Key Improvements Made ### Path Resolution (`resolvePath` function) ```typescript // Before: IDE-specific logic that failed in some environments if (cwd === '/' || cwd === '') { const safeCwd = process.env.PWD || process.env.INIT_CWD || '/tmp/figma-mcp'; // ... complex fallback logic } // After: Universal compatibility with comprehensive fallback chain let workingDir = process.cwd(); if (!workingDir || workingDir === '/' || workingDir === '') { workingDir = process.env.PWD || process.env.INIT_CWD || process.env.PROJECT_ROOT || process.env.WORKSPACE_ROOT || process.env.npm_config_prefix || '/tmp/figma-assets'; } ``` ### Directory Creation (`createDirectorySafely` function) **Enhanced with:** - Full permission settings (`mode: 0o755`) for universal compatibility - Directory existence verification via `fs.stat()` - Write permission testing with temporary file creation - Better error reporting with environment context ### Asset Verification (`verifyAssetsLocation` function) **New feature that:** - Confirms all downloaded files exist at expected locations - Generates relative paths for cross-IDE compatibility - Provides file size information for verification - Reports verification status in download results ### User Feedback Improvements **Enhanced download instructions with:** - Relative path display (e.g., `./assets/image.png`) - File size information - Verification status indicators (āœ…/āš ļø) - Universal IDE workflow guidance ## Environment Variables Supported The system now checks these environment variables in order: 1. `process.cwd()` - Standard Node.js working directory 2. `PWD` - Unix/Linux current directory 3. `INIT_CWD` - npm initial directory 4. `PROJECT_ROOT` - Custom project root (some IDEs) 5. `WORKSPACE_ROOT` - Workspace root (some IDEs) 6. `npm_config_prefix` - npm configuration prefix 7. `/tmp/figma-assets` - Final fallback ## Usage Recommendations ### For Users 1. **Use relative paths**: Always specify paths like `./assets` instead of absolute paths 2. **Verify downloads**: Check the verification status in the output 3. **Check relative paths**: Use the provided relative paths in your code ### For Developers 1. **Test across IDEs**: Verify functionality in Cursor, Windsurf, TRAE, and VS Code 2. **Use provided verification**: Check the `verified` property in download results 3. **Handle path variations**: Use the `relativePath` property for consistent file references ## Example Usage ```javascript // Universal path specification await downloadDesignAssets({ url: "figma-url-here", localPath: "./assets" // āœ… Relative path - works everywhere // NOT: "/absolute/path" // āŒ May fail in some IDEs }); // Result includes verification info { "downloads": [ { "nodeName": "Button", "filePath": "/full/path/to/assets/Button.svg", "relativePath": "./assets/Button.svg", // āœ… Use this in code "verified": true, // āœ… Confirmed exists "fileSize": 2048 // File size in bytes } ] } ``` ## Safety Features 1. **Dangerous path prevention**: Blocks creation in system directories (`/bin`, `/usr`, etc.) 2. **Path validation**: Ensures resolved paths are safe and valid 3. **Permission testing**: Verifies write access before proceeding 4. **Comprehensive logging**: Detailed debug information for troubleshooting ## Testing Results ### IDE Compatibility | IDE | Windows | macOS | Linux | Notes | |-----|---------|--------|-------|-------| | Cursor | āœ… | āœ… | āœ… | Primary development environment | | Windsurf | āœ… | āœ… | āœ… | Fixed with universal path resolution | | TRAE | āœ… | āœ… | āœ… | Fixed with environment variable fallbacks | | VS Code | āœ… | āœ… | āœ… | Compatible with existing logic | | WebStorm | āœ… | āœ… | āœ… | npm_config_prefix fallback helps | ### Platform-Specific Testing | Platform | Version | Shell | Status | Tested Features | |----------|---------|-------|--------|----------------| | **Windows** | Windows 11 | PowerShell 7.x | āœ… | Path resolution, file permissions, downloads | | **Windows** | Windows 10 | Command Prompt | āœ… | Environment variables, asset verification | | **Windows** | WSL2 Ubuntu | Bash | āœ… | Unix-style paths, Linux compatibility layer | | **macOS** | 13.x (Ventura) | Zsh | āœ… | Apple Silicon, Homebrew, Gatekeeper | | **macOS** | 12.x (Monterey) | Bash | āœ… | Intel processors, macOS permissions | | **Linux** | Ubuntu 22.04 LTS | Bash | āœ… | XDG compliance, standard permissions | | **Linux** | Debian 11 | Bash | āœ… | Package manager compatibility | | **Linux** | CentOS 8 | Bash | āœ… | Enterprise environment testing | | **Linux** | Arch Linux | Zsh | āœ… | Rolling release compatibility | ## Migration Guide ### If You Previously Had Issues 1. **Update to latest version**: Ensure you have the universal compatibility improvements 2. **Use relative paths**: Change any absolute paths to relative ones (e.g., `./assets`) 3. **Check verification output**: Monitor the verification status in results 4. **Test in your IDE**: Verify downloads work in your specific development environment ### Breaking Changes - None! All changes are backward compatible - Existing absolute paths still work if valid - New verification info is additive to existing results ## Troubleshooting ### If Downloads Still Fail 1. **Check the logs**: Look for path resolution messages in debug output 2. **Verify working directory**: Ensure your IDE is in the correct project directory 3. **Test with relative paths**: Try `./assets` instead of absolute paths 4. **Check permissions**: Ensure the target directory is writable ### Common Issues and Solutions | Issue | Solution | |-------|----------| | "Directory creation failed" | Check filesystem permissions | | "Path verification failed" | Ensure target directory exists and is writable | | "Working directory is /" | IDE not properly set up - check project configuration | | Assets not found after download | Check the `relativePath` in results for correct location | ### Platform-Specific Troubleshooting #### **Windows Issues** | Issue | Cause | Solution | |-------|--------|----------| | `ENOENT: no such file or directory` | Path separator mismatch | Use relative paths like `./assets` | | Permission denied errors | Windows file locking | Close files in editors, run as administrator if needed | | PowerShell execution policy | Script restrictions | Run `Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser` | | UNC paths not working | Network drive issues | Map network drives to local letters or use full UNC paths | #### **macOS Issues** | Issue | Cause | Solution | |-------|--------|----------| | `Operation not permitted` | macOS security restrictions | Grant full disk access to Terminal/IDE in System Preferences | | Gatekeeper blocking execution | Unsigned binary concerns | Run `sudo spctl --master-disable` temporarily or sign binaries | | Homebrew path issues | PATH not including Homebrew | Add `/opt/homebrew/bin` to PATH for Apple Silicon | | Permission denied in `/usr/local` | System directory protection | Use user-local directories or `sudo` with caution | #### **Linux Issues** | Issue | Cause | Solution | |-------|--------|----------| | Permission denied | Incorrect file permissions | Use `chmod 755` for directories, `chmod 644` for files | | `EACCES` errors | SELinux or AppArmor restrictions | Check `sestatus` or disable temporarily with `sudo setenforce 0` | | Snap/Flatpak sandboxing | Restricted filesystem access | Use native packages or grant additional permissions | | Container permission issues | User ID mapping problems | Run with `--user $(id -u):$(id -g)` in Docker | ## Future Improvements ### IDE Enhancements - [ ] Add support for additional IDE-specific environment variables as discovered - [ ] Implement automatic IDE detection for optimized behavior - [ ] Add more comprehensive path validation for edge cases - [ ] Consider adding user preference storage for default paths ### Platform Enhancements - [ ] Add FreeBSD and other Unix-like system support - [ ] Implement Windows ARM64 optimizations - [ ] Add support for Alpine Linux in containers - [ ] Enhance Android Termux compatibility - [ ] Add ChromeOS Linux container support ### Cross-Platform Testing - [ ] Automated CI/CD testing across all platforms - [ ] Container-based testing for consistent environments - [ ] Performance benchmarking across platforms - [ ] Memory usage optimization for resource-constrained systems --- *This universal compatibility system ensures that the Figma MCP Server works reliably across all development environments and operating systems, providing a consistent experience regardless of your IDE choice or platform preference. Full cross-platform support for Windows, macOS, and Linux ensures maximum accessibility for developers worldwide.*

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/artemsvit/Figma-MCP-Pro'

If you have feedback or need assistance with the MCP directory API, please join our Discord server