Skip to main content

Figma ファイルをローカルキャッシュし MCP サーバーとして提供する軽量ツール

Project description

YetAnotherFigmaMCP

CI codecov Maintainability Python 3.13+ License: MIT Ruff Checked with pyright CodeRabbit Pull Request Reviews DeepWiki

Figma ファイルをローカルキャッシュし、MCP (Model Context Protocol) サーバーとして提供する軽量ツール。

背景

Figma 無料プランでは API / MCP 呼び出し回数が月 6 回までに制限されています。本ツールは Figma のファイル・ノード JSON を事前取得しキャッシュすることで、この制限内で効率的にデザインデータを活用できるようにします。

特徴

  • 事前キャッシュ方式: Figma API を事前に叩いて JSON をローカル保存
  • 検索用インデックス: ノード名・フレーム名での高速検索
  • MCP サーバー: AI エージェントからキャッシュデータを参照可能
  • API 呼び出し最小化: キャッシュ生成時と明示的リフレッシュ時のみ API 使用

インストール

pip install yet-another-figma-mcp

または uvx / pipx でも利用可能:

uvx yet-another-figma-mcp --help
pipx install yet-another-figma-mcp

セットアップ

Figma API トークンの設定

環境変数に Figma API トークンを設定:

export FIGMA_API_TOKEN="your-figma-api-token"

トークンは Figma の設定画面 から取得できます。

使い方

キャッシュの生成

# 単一ファイルのキャッシュ生成
yet-another-figma-mcp cache --file-id <FILE_ID>

# 複数ファイル
yet-another-figma-mcp cache --file-id <ID1> --file-id <ID2>

# ファイル ID リストから一括生成
yet-another-figma-mcp cache --file-id-list path/to/file_ids.txt

# 強制リフレッシュ(API を再度呼び出し)
yet-another-figma-mcp cache --file-id <FILE_ID> --refresh

MCP サーバーの起動

# MCP サーバー起動
yet-another-figma-mcp serve

# 動作確認
yet-another-figma-mcp status

Claude Desktop での設定

claude_desktop_config.json に以下を追加:

{
  "mcpServers": {
    "figma-cache": {
      "command": "uvx",
      "args": ["yet-another-figma-mcp", "serve"]
    }
  }
}

MCP ツール一覧

MCP サーバーは以下のツールを提供します:

get_cached_figma_file

指定ファイルのノードツリーやメタデータを取得。

引数:
  - file_id: string (必須)

返り値:
  - ルートノードと主要フレーム一覧
  - ファイル全体のメタデータ

get_cached_figma_node

単一ノードの詳細情報を取得。

引数:
  - file_id: string (必須)
  - node_id: string (必須)

返り値:
  - ノードのプロパティ(type, name, layout, style, children など)

search_figma_nodes_by_name

ノード名でノードを検索。

引数:
  - file_id: string (必須)
  - name: string (必須)
  - match_mode: "exact" | "partial" (オプション、デフォルト: exact)
  - limit: number (オプション)

返り値:
  - マッチしたノードのリスト

search_figma_frames_by_title

フレーム名からフレームノードを検索。

引数:
  - file_id: string (必須)
  - title: string (必須)
  - match_mode: "exact" | "partial" (オプション)
  - limit: number (オプション)

返り値:
  - 対象フレームノードの一覧

list_figma_frames

ファイル直下の主要フレーム一覧を取得。

引数:
  - file_id: string (必須)

返り値:
  - フレーム名・node_id・パスのリスト

キャッシュファイルの構造

~/.yet_another_figma_mcp/
  index.json                     # 全ファイル共通のメタ情報
  <file_id>/
    file_raw.json                # Figma API /files の生 JSON
    nodes_index.json             # ノード検索用インデックス

ユースケース例

画面実装の参照

ユーザー: 「サインアップ画面を実装してください」
→ AI: search_figma_frames_by_title で「Sign Up」を検索
→ AI: get_cached_figma_node でフレーム構造を取得
→ AI: 取得したデザイン情報をもとにコード生成

コンポーネントの特定

ユーザー: 「Primary Button のスタイルを教えて」
→ AI: search_figma_nodes_by_name で検索
→ AI: get_cached_figma_node で詳細取得

制限事項

本ツールは PoC(Proof of Concept)として以下の機能はスコープ外としています:

  • スクリーンショット取得
  • Code Connect(ノード⇔コンポーネント対応)
  • 変数・デザイントークンの取得
  • FigJam 対応

開発

セットアップ

# 開発用依存関係をインストール
uv sync --group dev

Task コマンド(推奨)

Task がインストールされている場合、以下のコマンドが使えます:

# 利用可能なタスク一覧
task

# 依存関係インストール
task install

# リント
task lint

# リント(自動修正付き)
task lint:fix

# フォーマット
task format

# フォーマット確認(修正なし)
task format:check

# 型チェック
task typecheck

# テスト
task test

# テスト(詳細出力)
task test:verbose

# テスト(並列実行)
task test:parallel

# テスト(カバレッジ付き)
task test:cov

# 全チェック(lint + format:check + typecheck + test)
task check

# pre-commit フック実行
task pre-commit

# MCP サーバー起動
task serve

# MCP サーバー起動(詳細ログ付き)
task serve:verbose

# キャッシュ状態確認
task status

# Figma ファイルをキャッシュ
task cache -- -f <FILE_ID>

# 生成ファイルのクリーンアップ
task clean

手動実行

# リント
uv run ruff check .

# フォーマット
uv run ruff format .

# 型チェック
uv run pyright

# テスト
uv run pytest

Acknowledgments

  • Figma-Context-MCP - AI 向けノード簡略化のアプローチを参考にさせていただきました

ライセンス

MIT License - 詳細は LICENSE を参照してください。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yet_another_figma_mcp-0.2.0.tar.gz (102.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yet_another_figma_mcp-0.2.0-py3-none-any.whl (33.7 kB view details)

Uploaded Python 3

File details

Details for the file yet_another_figma_mcp-0.2.0.tar.gz.

File metadata

  • Download URL: yet_another_figma_mcp-0.2.0.tar.gz
  • Upload date:
  • Size: 102.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for yet_another_figma_mcp-0.2.0.tar.gz
Algorithm Hash digest
SHA256 bdff76fcd8ca0ebc4dad129b0b7f9beffb236f962552fbfaf154dffdbacd98cc
MD5 35fa2c99024f7534a35db36f6a81708c
BLAKE2b-256 185a0fe56c9d987a2e0911520bce8035b9df4f855908becb481975e03c090675

See more details on using hashes here.

Provenance

The following attestation bundles were made for yet_another_figma_mcp-0.2.0.tar.gz:

Publisher: release-please.yml on yk-lab/yet-another-figma-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file yet_another_figma_mcp-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for yet_another_figma_mcp-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 96328f6dc7f6888dd62bfcb85f8dabb992c72a6e35f0958455833aa9ee03acad
MD5 cd317762590e95604a7359eda008ddde
BLAKE2b-256 6873b00dfb1c2f9b2d6bb8db85ab3a971a44f2dad951199a410eae1c33cfb3ec

See more details on using hashes here.

Provenance

The following attestation bundles were made for yet_another_figma_mcp-0.2.0-py3-none-any.whl:

Publisher: release-please.yml on yk-lab/yet-another-figma-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page