mcp

v1.1.20
@locofy/mcp Checked 2 days ago Published 2 months ago

Locofy MCP Server

Locofy MCP (Model Context Protocol) connects AI code editors directly to your Locofy project. Convert Figma designs to code, pull generated components, and sync files — all from your editor's chat. convertDesignToCode ✨ Convert a Figma design into production-ready code. Paste a Figma URL and the tool generates code for your project's framework, applies enhancement steps, and guides the AI through merging it cleanly into your workspace. getLatestComponentAndDependencyCode Pull one or more components and their dependencies from your Locofy project and merge them into your workspace.

Summary extracted from the README.

Locofy MCP Server

Locofy MCP (Model Context Protocol) connects AI code editors directly to your Locofy project. Convert Figma designs to code, pull generated components, and sync files — all from your editor's chat.

Important: The MCP configuration must be set up per project, not globally. The mcp.json downloaded from the Locofy dashboard contains your project-specific credentials and must be placed in your project's editor config folder (e.g. .cursor/mcp.json). A global install is not recommended.

Requirements

  • Node.js 20.0.0 or higher
  • A Locofy account with a project created
  • An MCP-compatible editor: Cursor, Windsurf, VS Code (GitHub Copilot), Claude Code, or Gemini CLI

Tools

convertDesignToCode ✨

Convert a Figma design into production-ready code. Paste a Figma URL and the tool generates code for your project's framework, applies enhancement steps, and guides the AI through merging it cleanly into your workspace.

  • Inputs:
    • figmaUrls (string[]): One or more Figma design URLs
    • workspacePath (string): Absolute path to the workspace root
  • Notes:
    • A Figma URL must be present to trigger this tool
    • Conversion takes a couple of minutes — the tool waits for it automatically
    • Your instructions always take priority (e.g. "use shadcn", "put files in src/screens", "use tokens from src/tokens.ts")
    • For empty workspaces, all generated files including boilerplate are copied; for existing projects, files are merged selectively
    • Generated files are extracted to a temp directory (not the project). After a successful merge, the agent should delete that temp folder
    • If anything is unclear, the AI will ask before making decisions

getLatestComponentAndDependencyCode

Pull one or more components and their dependencies from your Locofy project and merge them into your workspace.

  • Inputs:
    • componentNames (string[]): Component or screen names, e.g. ["HomePage", "NavBar"]
    • workspacePath (string): Absolute path to the workspace root

getLatestFileCode

Pull specific files from your Locofy project by name, without fetching their full dependency tree.

  • Inputs:
    • fileNames (string[]): File names, e.g. ["Button.tsx", "tokens.css"]
    • workspacePath (string): Absolute path to the workspace root

Figma design inspection

Pass the Figma URL the user pasted. The tools parse fileKey and node-id from the link — the user never needs those values.

They read the Figma file through your Locofy-connected Figma account (via PERSONAL_ACCESS_TOKEN). For local testing you can set FIGMA_ACCESS_TOKEN instead to call the Figma REST API directly.

get_design_context

Primary design-to-code inspection tool. Returns React + Tailwind reference code, simplified layout/style JSON, and a screenshot of the node.

  • Inputs: figmaUrl (required). Optional: clientLanguages, clientFrameworks, forceCode, excludeScreenshot
  • Notes: Treat the output as a reference and adapt it to this project. For Locofy production-ready generation from a Figma URL, use convertDesignToCode.

get_screenshot

Renders a PNG of a node. Returns a short-lived image URL (and optional inline base64).

  • Inputs: figmaUrl (required). Optional: contentsOnly, enableBase64Response (default false), maxDimension (default 1024)

get_metadata

Sparse XML outline of a node (ids, types, names, positions, sizes). Prefer get_design_context when you already know the frame. If the URL has no node-id, lists top-level pages.

  • Inputs: figmaUrl (required)

get_variable_defs

Variables and tokens used on a node (colors, spacing, typography). The Locofy proxy's /variables/local route currently returns 403 from Figma; the tool falls back to computed paints, type, and spacing from the node tree.

  • Inputs: figmaUrl (required)

Getting Started

Step 1: Create Your Locofy Project

  1. Open the Locofy Dashboard and create a project.
  2. For getLatestComponentAndDependencyCode / getLatestFileCode: open the Locofy Figma plugin, convert your designs, and sync them to Locofy Builder before pulling.
  3. For convertDesignToCode: no sync needed — just have your Figma URL ready.

Step 2: Get Your MCP Configuration

  1. In the Locofy Dashboard, select your project.
  2. Click the gear icon → Project Settings → MCP Configuration.

dashboard

  1. Choose a token expiry (1 Month or No Expiry) and click Generate Token.
  2. Download the mcp.json file — it contains your PROJECT_ID and PERSONAL_ACCESS_TOKEN.

Step 3: Configure Your Editor

Copy the contents of the downloaded mcp.json into your editor's MCP config file for this project. Set IDE_SOURCE to match your editor.

Cursor

Create .cursor/mcp.json in your project root:

{
  "mcpServers": {
    "Locofy": {
      "command": "npx",
      "args": ["-y", "@locofy/mcp@latest"],
      "env": {
        "PERSONAL_ACCESS_TOKEN": "your-token-here",
        "PROJECT_ID": "your-project-id",
        "IDE_SOURCE": "cursor"
      }
    }
  }
}

Go to Cursor Settings → Features → Model Context Protocol and enable the Locofy server. Hit the refresh icon if it doesn't appear as enabled after a few seconds.

Windsurf

Create .windsurf/mcp.json in your project root:

{
  "mcpServers": {
    "Locofy": {
      "command": "npx",
      "args": ["-y", "@locofy/mcp@latest"],
      "env": {
        "PERSONAL_ACCESS_TOKEN": "your-token-here",
        "PROJECT_ID": "your-project-id",
        "IDE_SOURCE": "windsurf"
      }
    }
  }
}

Go to Windsurf Settings → Cascade → Manage MCP Servers and click refresh.

VS Code (GitHub Copilot)

Create .vscode/mcp.json in your project root:

{
  "servers": {
    "Locofy": {
      "command": "npx",
      "args": ["-y", "@locofy/mcp@latest"],
      "env": {
        "PERSONAL_ACCESS_TOKEN": "your-token-here",
        "PROJECT_ID": "your-project-id",
        "IDE_SOURCE": "vscode"
      }
    }
  }
}

VS Code detects the file automatically and shows a Start button above the server entry. Click it to launch.

Claude Code

claude mcp add Locofy \
  --env PERSONAL_ACCESS_TOKEN=your-token-here \
  --env PROJECT_ID=your-project-id \
  --env IDE_SOURCE=claude \
  -- npx -y @locofy/mcp@latest

To verify: claude mcp get Locofy

Gemini CLI

Add to ~/.gemini/settings.json:

{
  "mcpServers": {
    "Locofy": {
      "command": "npx",
      "args": ["-y", "@locofy/mcp@latest"],
      "env": {
        "PERSONAL_ACCESS_TOKEN": "your-token-here",
        "PROJECT_ID": "your-project-id",
        "IDE_SOURCE": "gemini"
      }
    }
  }
}

Configuration Reference

Environment Variable Required Description
PERSONAL_ACCESS_TOKEN Yes Your Locofy personal access token, from Project Settings → MCP Configuration
PROJECT_ID Yes Your Locofy project ID, included in the downloaded mcp.json
IDE_SOURCE No Editor identifier: cursor, windsurf, vscode, claude, gemini. Defaults to other
FIGMA_ACCESS_TOKEN No Optional Figma personal access token. When set, get_design_context / get_screenshot / get_metadata / get_variable_defs call the Figma REST API directly instead of Locofy's Figma proxy

Usage Examples

Open your editor's agent chat and try:

  • "Convert this Figma design to code: https://figma.com/design/... and use the shadcn components from src/components"
  • "Fetch the NavigationBar component from Locofy."
  • "Pull Homepage from Locofy and replace the existing navbar with the one already in this project."
  • "Get the ListingCard from Locofy and merge it with my existing card component."

Regenerating Your Token

  1. Go to the Locofy Dashboard and select your project.
  2. Click the gear icon → Project Settings → MCP Configuration.
  3. Click Regenerate Token, choose an expiry, and confirm. The previous token is immediately invalidated.
  4. Download the new mcp.json and update the PERSONAL_ACCESS_TOKEN value in your editor config.

More Resources