# uxmynd/figma-desktop-bidirectional-mcp architecture

> Architecture diagram of the GitHub repository uxmynd/figma-desktop-bidirectional-mcp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-02-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/uxmynd/figma-desktop-bidirectional-mcp
- Repository: https://github.com/uxmynd/figma-desktop-bidirectional-mcp

## Overview

##### Project type and purpose
- This is a “connector” or “middleware” system that links AI assistants (via the Model Context Protocol, MCP) to the Figma design tool. It consists of:
- An MCP server (Node.js/TypeScript) exposing 72 Figma commands
- A WebSocket broker for channel-based multi-session support
- An HTTP bridge for non-MCP clients (curl, Python scripts, etc.)
- A Figma plugin (UI + in-canvas code) that receives commands and invokes the Figma Plugin API

##### File structure
- Top-level
- package.json, tsconfig.json, build scripts, .claude/ (MCP config for Claude Code)
- server/
- index.ts – MCP server entrypoint over stdio
- broker.ts – WebSocket broker on port 3055, handles channel registration & message routing
- websocket.ts – client library used by the plugin to connect to the broker
- http-bridge.ts – HTTP REST API on port 3056 for non-MCP tools
- types.ts – shared TypeScript interfaces
- plugin/
- code.ts – Figma plugin logic, command handlers that receive MCP commands through WS or HTTP
- ui.html – simple UI to connect, display & copy channel IDs
- docs/ – user guides, quick-start, permission and integration guides

##### Key architecture details from README
- AI Assistant → MCP Server (stdio)
- ↓
- WebSocket Broker (3055) ──→ Figma Plugin → Figma API
- ↑
- HTTP Bridge (3056) ────────────┘
- Channel system: each plugin session generates a unique channel ID; AI tool joins that channel; all messages scoped by channel.
- Two transport paths: MCP (stdio → broker → plugin) vs HTTP (REST → broker → plugin).

##### Detailed call-outs
- That MCP Server defines 72 tool commands (referenced in index.ts)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External actors
    AI_Assistant["AI Assistant\n(MCP-compatible)"]:::external
    HTTP_Client["HTTP Client\n(curl, scripts)"]:::external
    Figma_API["Figma API\n(external)"]:::external

    %% Server-side
    subgraph "Server-side Processes"
        direction TB
        MCP_Server["MCP Server\n(stdio)\n72 commands"]:::server
        WebSocket_Broker["WebSocket Broker\n(port 3055)\nChannel registry & routing"]:::server
        HTTP_Bridge["HTTP Bridge\n(port 3056)\nREST API"]:::server
        Types["Shared Types"]:::server
    end

    %% Plugin
    subgraph "Figma Plugin" 
        direction TB
        UI["UI (ui.html)\nConnection & Channel ID"]:::plugin
        Code["Handlers (code.ts)\n71 commands"]:::plugin
        WS_Client["WebSocket Client Lib\n(websocket.ts)"]:::server
    end

    %% Configuration & Docs
    subgraph "Configuration & Documentation"
        direction TB
        CLAUDE[".claude config"]:::config
        Manifest["manifest.json"]:::config
        Docs["docs/"]:::config
        NPM["package.json\ntsconfig*.json"]:::config
        Scripts["start-broker.bat\nstart-http-bridge.bat"]:::config
    end

    %% Connections
    AI_Assistant -->|stdio| MCP_Server
    MCP_Server -->|WebSocket| WebSocket_Broker
    HTTP_Client -->|HTTP REST| HTTP_Bridge
    HTTP_Bridge -->|WebSocket| WebSocket_Broker
    WebSocket_Broker -->|WebSocket| WS_Client
    WS_Client --> Code
    Code -->|Plugin API| Figma_API

    %% Click events
    click MCP_Server "https://github.com/uxmynd/figma-desktop-bidirectional-mcp/blob/main/server/index.ts"
    click WebSocket_Broker "https://github.com/uxmynd/figma-desktop-bidirectional-mcp/blob/main/server/broker.ts"
    click WS_Client "https://github.com/uxmynd/figma-desktop-bidirectional-mcp/blob/main/server/websocket.ts"
    click HTTP_Bridge "https://github.com/uxmynd/figma-desktop-bidirectional-mcp/blob/main/server/http-bridge.ts"
    click Types "https://github.com/uxmynd/figma-desktop-bidirectional-mcp/blob/main/server/types.ts"
    click Code "https://github.com/uxmynd/figma-desktop-bidirectional-mcp/blob/main/plugin/code.ts"
    click UI "https://github.com/uxmynd/figma-desktop-bidirectional-mcp/blob/main/plugin/ui.html"
    click CLAUDE "https://github.com/uxmynd/figma-desktop-bidirectional-mcp/blob/main/.claude/mcp.json"
    click Manifest "https://github.com/uxmynd/figma-desktop-bidirectional-mcp/blob/main/manifest.json"
    click Docs "https://github.com/uxmynd/figma-desktop-bidirectional-mcp/tree/main/docs/"
    click NPM "https://github.com/uxmynd/figma-desktop-bidirectional-mcp/blob/main/package.json"
    click Scripts "https://github.com/uxmynd/figma-desktop-bidirectional-mcp/blob/main/start-broker.bat"

    %% Styles
    classDef server fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef plugin fill:#90EE90,stroke:#333,stroke-width:1px
    classDef external fill:#FFA500,stroke:#333,stroke-width:1px
    classDef config fill:#EEEEEE,stroke:#333,stroke-width:1px
```
