Skip to main content
Glama
fpgaZeroMCP

fpgaZeroMCP

by lcapossio

fpgaZeroMCP

CI License: MIT Python MCP

オープンソースの Model Context Protocol サーバーです。AI アシスタントに完全な FPGA ツールチェーン(lint、シミュレーション、合成、配置配線、ビットストリームの書き込み、および GitHub をバックエンドにしたライブ IP コアレジストリ)を提供します。

AI にコアの検索、取り込み、HDL の lint、ディスク上の複数ファイルからなる VHDL/Verilog プロジェクトの合成、シミュレーションの実行、そしてボードへのビットストリームの書き込みまでを、チャットウィンドウから離れることなく実行させられます。

機能

  • 多言語: Verilog、SystemVerilog、VHDL(ghdl-yosys-plugin 経由)

  • 3 つの入力モード: インラインの code 文字列、複数ファイルの files dict、またはディスク上の project_dir パス

  • ファイルリスト対応: files.f/sources.f と +incdir+、+define+、ネストされた -f ディレクティブ

  • ボードプリセット: 11 の内蔵ボード(iCEBreaker、ULX3S、TinyFPGA BX、Tang Nano など)— target/device/package/clock を自動設定

  • 制約ファイルの自動検出: プロジェクトディレクトリ内の .pcf/.lpf/.pdc/.cst を検出

  • ビットストリーム書き込み: iceprog(iCE40)または openFPGALoader(ECP5/Gowin/Nexus/Xilinx)でフラッシュ

  • Vivado: start_build によるバッチ実行、LiteX 経由の Xilinx ビルド、build_status での構造化された Vivado ログ解析

  • シミュレーション判定の解析: PASS/FAIL/UVM パターン検出と VCD 信号サマリー

  • バックグラウンドビルド: ステータスポーリング付きの長時間実行合成/配置配線と、EDA 専用コマンドのみを許可する厳格な許可リスト

  • 並行リクエスト: 時間のかかるツール呼び出しが実行されている間も ping、ビルドステータス、キャンセルに応答します。notifications/cancelled は実行中の呼び出しを中止します

  • 機械可読な結果: ツール結果の structuredContent(MCP 2025-06-18)と、リトライ/フォールバック判断のための統一 error_code 分類

  • 進行通知: クライアントが progressToken を送信すると、合成、配置配線、LiteX 実行のフェーズ境界で notifications/progress を送信します

  • IP コアレジストリ: FuseSoC CAPI2 メタデータによる GitHub からのライブ検索とインポート

  • ヘルスチェック: インストール済みで到達可能な OSS CAD Suite ツールを検出します


Related MCP server: vivado-mcp-agent

目次


仕組み

Your AI assistant  <-->  fpgaZeroMCP (stdio MCP server)  <-->  OSS tools
                                    |
                           cores/   registry on GitHub
                           (uart_tx, fifo + any imported)

MCP サーバーはローカルのサブプロセスとして実行されます。AI は JSON-RPC(stdio)経由でサーバーのツールを呼び出します。サーバーは OSS CAD Suite の Yosys、nextpnr、iverilog、Verilator などのツールをシェル経由で実行し、オープンソースの FPGA コアを GitHub から直接取得することもできます。

前提条件

要件

備考

Python 3.11+

OSS CAD Suite

iverilog、Yosys、nextpnr、Verilator、Verible、GHDL を 1 つのダウンロードに同梱

LiteX + litex-boards

任意 — LiteX ツールでのみ必要

インストール後、OSS CAD Suite を PATH に追加してください。すべてのツールラッパーは、ツールが不足している場合でもグレースフルに動作します。

GitHub API アクセス

GitHub API リクエストは、デフォルトでは認証されておらず、レート制限の対象です。レート制限を引き上げるには、パーソナルアクセストークンを設定してください:

# Linux/macOS
export GITHUB_TOKEN=ghp_...
# Windows (PowerShell)
$env:GITHUB_TOKEN = "ghp_..."

インストール

git clone https://github.com/lcapossio/fpgaZeroMCP
cd fpgaZeroMCP
pip install -e .

MCP クライアントのセットアップ

Claude Desktop

claude_desktop_config.json に追加:

{
  "mcpServers": {
    "fpgaZeroMCP": {
      "command": "python",
      "args": ["/path/to/fpgaZeroMCP/server.py"],
      "env": { "PYTHONPATH": "/path/to/fpgaZeroMCP" }
    }
  }
}

VS Code (GitHub Copilot)

ワークスペース内の .vscode/mcp.json に追加:

{
  "servers": {
    "fpgaZeroMCP": {
      "type": "stdio",
      "command": "python",
      "args": ["/path/to/fpgaZeroMCP/server.py"],
      "env": { "PYTHONPATH": "/path/to/fpgaZeroMCP" }
    }
  }
}

Cursor / Windsurf

MCP 設定(Settings → MCP Servers)に追加:

{
  "fpgaZeroMCP": {
    "command": "python",
    "args": ["/path/to/fpgaZeroMCP/server.py"],
    "env": { "PYTHONPATH": "/path/to/fpgaZeroMCP" }
  }
}

プロンプト例

  • "I2C マスターコアを探してインポートして。"

  • "~/projects/my_fpga 内の VHDL ファイルを合成して、LUT 数を教えて。"

  • "iCEBreaker ボード向けにプロジェクトを配置配線して、それからフラッシュして。"

  • "より良いタイミングを試すために、シード 42 で配置配線を実行して。"

  • "この Verilog を lint して、エラーを修正して。"

  • "この FIFO をシミュレーションして、テストベンチがパスしたか教えて。"

  • "この SystemVerilog ファイルをフォーマットして。"

  • "どの OSS CAD Suite ツールがインストールされていますか?"

ツール

HDL 品質

Tool

説明

lint_hdl

iverilog(V/SV)または GHDL(VHDL)による構文/エラーチェック — 単一ファイル

lint_project

複数のファイルをまとめて lint し、モジュール間参照を解決します

get_diagnostics

行ごとの構造化診断 — Verilator → verible フォールバック(V/SV)、GHDL(VHDL)

format_hdl

verible-verilog-format(V/SV)または vsg(VHDL)による自動フォーマット

設計フロー

Tool

説明

simulate

テストベンチのコンパイルと実行 — iverilog(V/SV)または GHDL(VHDL)。code、files、project_dir を受け付けます。判定結果 + VCD サマリーを返します

synthesize

リソース統計付きの Yosys 合成。code、files、project_dir を受け付けます。Verilog、SV、VHDL

place_and_route

Yosys + nextpnr を 1 ステップで実行。ボードプリセット、制約ファイルの自動検出、ビットストリームをディスクに書き込み(bitstream_path)

program_fpga

iceprog または openFPGALoader でビットストリームをフラッシュ

list_boards

内蔵ボードプリセット(target/device/package/clock)を列挙

IP コアレジストリ

Tool

説明

list_ip_cores

ローカルレジストリを閲覧し、カテゴリでフィルタリング

get_ip_core

コアのマニフェストと HDL ソースを取得

generate_ip

パラメータ化されたインスタンス化スニペット + ソースファイルを取得

search_github_cores

MIT ライセンスの FPGA IP リポジトリを GitHub で検索

import_github_core

GitHub リポジトリをローカルレジストリにダウンロード

import_fusesoc_core

ローカルの FuseSoC CAPI2 .core ファイルをインポート

LiteX

Tool

説明

litex_build

--build 付きで LiteX ボードターゲットを実行

litex_soc

ゲートウェアをビルドせずに LiteX SoC を生成

litex_flow

完全にカスタムな引数で LiteX ボードターゲットを実行

ビルド管理

Tool

説明

start_build

長時間実行コマンドをバックグラウンドで開始(許可リストに登録された EDA ツールのみ)

build_status

進行状況を確認 — ステータス、経過時間、解析されたフェーズ/使用率/タイミング

list_builds

追跡中のすべてのビルドを一覧表示(実行中と完了済み)

cancel_build

実行中のバックグラウンドビルドを強制終了

cleanup_build_logs

経過時間と合計サイズに基づいて古いビルドログを削除

サーバー / レジストリ

Tool

説明

check_tools

インストール済みの OSS CAD Suite ツールをパスとバージョン付きで報告

reload_registry

サーバーを再起動せずにコアディレクトリを再スキャン

IP コアレジストリ

コアは cores/<name>/ に置かれます。— core.json マニフェストと 1 つ以上の HDL ファイルからなります。サーバーは起動時にそれらを自動検出し、インポート後にも再読み込みします。

フォーマットの例として、2 つのリファレンスコア(uart_tx、fifo)が含まれています。このレジストリはここで拡張することを意図していません — GitHub を基盤としています。

ランタイムでのコア取得

# Find a RISC-V softcore
search_github_cores("riscv softcore", language="verilog")

# Pull it in
import_github_core("YosysHQ/picorv32")

# It is now in the local registry
get_ip_core("picorv32")
generate_ip("picorv32", {"COMPRESSED_ISA": 1})

サーバーは、リポジトリ内に FuseSoC CAPI2 メタデータ(.core ファイル)が見つかった場合、それを自動的に使用し、より豊富なパラメータおよびポート情報を提供します。許可されたライセンス を持つリポジトリのみが受け入れられます。

コアの提供

このリポジトリにコアを追加する PR は開かないでください。 代わりに、次のようにしてください:

  1. GitHub で fpga トピックと MIT ライセンスを付けて HDL リポジトリを公開する

  2. 任意で、よりリッチなメタデータのための FuseSoC CAPI2 .core ファイルを追加する

  3. その後は誰でも import_github_core("you/your-core") を直接呼び出せます

これによりサーバーは軽量なまま保たれ、コミュニティは GitHub 上で有機的に成長できます。

合成ターゲット

ターゲット

ベンダー / ファミリ

完全な OSS P&R

ice40

Lattice iCE40

対応 — nextpnr-ice40

ecp5

Lattice ECP5

対応 — nextpnr-ecp5

nexus

Lattice Nexus (CrossLink-NX, CertusPro-NX)

対応 — nextpnr-nexus

gowin

Gowin

対応 — nextpnr-gowin

xilinx

Xilinx / AMD

合成のみ

intel

Intel / Altera

合成のみ

generic

テクノロジ非依存

ネットリストのみ

place_and_route でよく使用する device/package の値:

ターゲット

device

package

ice40

hx1k hx8k up5k lp1k

tq144 qn84 sg48 cm81

ecp5

25k 45k 85k

CABGA256 CABGA381

nexus

LIFCL-40-9BG400C

(デバイス文字列に埋め込まれています)

gowin

GW1N-UV4LQ144C6/I5

(デバイス文字列に埋め込まれています)

LiteX

LiteX は、多くの FPGA ボードをターゲットにできる Python 製 SoC フレームワークです。fpgaZeroMCP は専用の LiteX ツールを 3 つ公開しており、synthesize と place_and_route で backend="litex" も受け付けます。

# Dedicated tools
litex_build(board="arty", args=["--build"])
litex_soc(board="arty", args=["--no-compile"])
litex_flow(board="arty", args=["--build", "--output-dir", "build_arty"])

# As a backend in existing flow tools
synthesize(code="...", top_module="top", backend="litex", litex_board="arty")
place_and_route(code="...", top_module="top", target="ice40", device="hx1k",
                backend="litex", litex_board="arty", litex_args=["--build"])

ローカルコアリポジトリ

レジストリを自分のローカル HDL ディレクトリに向けるには、2 つの方法があります:

環境変数:

Linux/macOS(コロン区切り):

export USERCORES_PATH=/home/you/my-cores:/home/you/work-cores

Windows(セミコロン区切り、PowerShell):

$env:USERCORES_PATH = "C:\Users\you\my-cores;C:\Users\you\work-cores"

設定ファイル(~/.fpgazero_mcp/config.json):

{
  "core_paths": [
    "/home/you/my-cores",
    "/home/you/work-cores"
  ]
}

すべてのパスは、起動時に組み込みの cores/ ディレクトリとともにスキャンされます。

許可されるライセンス

デフォルトでは、import_github_core は以下のいずれかの SPDX ライセンスを持つリポジトリを受け入れます:

MIT, BSD-2-Clause, BSD-3-Clause, Apache-2.0, ISC, GPL-2.0, GPL-3.0, LGPL-2.1, LGPL-3.0

FPGAZERO_ALLOWED_LICENSES 環境変数(カンマ区切りの SPDX ID)で上書きできます:

# Linux/macOS
export FPGAZERO_ALLOWED_LICENSES=MIT
export FPGAZERO_ALLOWED_LICENSES=MIT,Apache-2.0
# Windows (PowerShell)
$env:FPGAZERO_ALLOWED_LICENSES = "MIT"
$env:FPGAZERO_ALLOWED_LICENSES = "MIT,Apache-2.0"

ライセンス ID は SPDX 表記に従います。チェックはインポート時に行われ、search_github_cores はライセンスに関係なく結果を返すため、インポートする前に評価できます。


テスト

pip install -e ".[dev]"
python -m pytest tests/ -v

一部のテストでは、PATH に OSS CAD Suite ツールが必要です。不足しているツールを必要とするテストは自動的にスキップされます。


メモリ使用量の削減

サーバーは stdio トランスポート上で、セッションごとに 1 プロセスずつのサブプロセスとして実行されます(これは Claude Desktop などの MCP クライアントが起動する方法です)。Linux では、各セッションのアイドル時 RSS は ~60〜90 MB で、そのほとんどは Python インタープリターと依存関係によるものです。

多数の MCP セッションを同時に実行する場合は、MCP クライアントを起動する前に次の環境変数を設定してください:

# Linux — reduces glibc malloc arena fragmentation (can save 10-20 MB per session)
export MALLOC_ARENA_MAX=2

# Strip bytecode position annotations from tracebacks (saves a few MB)
export PYTHONNODEBUGRANGES=1

# Skip .pyc cache files (no memory impact, avoids disk writes)
export PYTHONDONTWRITEBYTECODE=1

これらはコード変更が一切不要で、完全に透過的です。


環境変数

変数

説明

GITHUB_TOKEN

GitHub 個人アクセストークン — API レート制限を引き上げます

USERCORES_PATH

追加のコア検索ディレクトリ(OS のパス区切り文字で区切る)

FPGAZERO_ALLOWED_LICENSES

import_github_core 用のカンマ区切り SPDX ID(デフォルト: MIT,BSD-2-Clause,BSD-3-Clause,Apache-2.0,ISC,GPL-2.0,GPL-3.0,LGPL-2.1,LGPL-3.0)

FPGAZERO_TMPDIR

一時ワークスペースのルートディレクトリを上書きします

FPGAZERO_DATA_DIR

永続的なサーバーアーティファクトのルート — ビルドログ、LiteX 出力、一時ワークスペース(デフォルト: <install dir>/no_commit)

FPGAZERO_ALLOWED_DIRS

project_dir が読み取り元として使用でき、start_build/place_and_route が work_dir として使用できる追加ディレクトリの、OS パス区切り文字で区切られたリスト(cwd と $HOME に加えて)


スタンドアロン / スクリプティング

Python API は MCP クライアントなしで直接使用できます:

from registry.resolver import CoreRegistry
from tools.lint import lint_hdl

reg = CoreRegistry()

# Import a core from GitHub
reg.import_github_core("ben-marshall/uart")

# Generate a parameterized instantiation
result = reg.generate_ip("uart", {"CLKS_PER_BIT": 868})
print(result["instantiation"])

# Lint some HDL
lint_hdl(open("my_design.v").read())
python example.py   # runs the built-in demo

core.json スキーマ

{
  "name": "my_core",
  "version": "1.0.0",
  "description": "...",
  "author": "you",
  "license": "MIT",
  "language": "verilog",
  "category": "communication",
  "tags": ["spi", "serial"],
  "parameters": {
    "DATA_WIDTH": { "type": "integer", "default": 8, "description": "..." }
  },
  "ports": {
    "clk": { "direction": "input", "width": 1, "description": "System clock" }
  },
  "files": ["my_core.v"]
}

著者

Leonardo Capossio (bard0) — hello@bard0.com

ライセンス

MIT — LICENSE を参照してください。

Available Tools

25 tools
build_statusA

Check the progress of a background build. Returns status (running/success/failed), elapsed time, and recent log output.

Inputs: build_id (required), tail_lines, parse.

cancel_buildB

Cancel a running background build.

Inputs: build_id (required).

check_toolsA

Check which EDA tools are installed and reachable. Returns tool name, path, and version for each detected binary.

Inputs: no named parameters.

cleanup_build_logsA

Delete old build logs to reclaim disk space. Removes logs older than max_age_days, then trims oldest until under max_total_mb.

Inputs: max_age_days, max_total_mb.

format_hdlA

Format HDL source code and return the result. Verilog/SystemVerilog: uses verible-verilog-format. VHDL: uses vsg (pip install vsg). Returns the formatted code and whether it changed.

Inputs: code (required), language.

generate_ipB

Generate a parameterized instance of an IP core. Returns the HDL source files and a ready-to-paste Verilog instantiation snippet with the requested parameter values applied.

Inputs: name (required), parameters, instance_name.

get_diagnosticsB

Return structured lint diagnostics (line, column, severity, message) for HDL source. Verilog/SystemVerilog: uses Verilator (primary) with verible-verilog-lint as fallback. VHDL: uses GHDL. All tools are part of OSS CAD Suite.

Inputs: code (required), language.

get_ip_coreB

Fetch the full manifest and HDL source files for a named IP core.

Inputs: name (required).

import_fusesoc_coreA

Import a local FuseSoC CAPI2 .core file into the registry. HDL files referenced in the .core file must exist in the same directory. Useful when you already have FuseSoC cores checked out locally.

Inputs: path (required).

import_github_coreA

Download an open-source GitHub repository and add it to the local IP core registry. Automatically uses FuseSoC CAPI2 metadata (.core file) if one exists in the repo. After import, the core is immediately available via get_ip_core and generate_ip.

Inputs: repo (required), subdir, ref.

lint_hdlA

Lint HDL source code using iverilog/verilator (Verilog/SystemVerilog) or ghdl (VHDL). Use linter='verilator' to enable -Wall checks including multidriven net detection.

Inputs: code (required), language, top_module, linter.

lint_projectA

Lint multiple HDL files together so cross-module references resolve. Pass a dict of filename-to-source pairs. All files are compiled in one invocation of iverilog/verilator (Verilog/SystemVerilog) or ghdl (VHDL). Use linter='verilator' to enable -Wall checks including multidriven net detection.

Inputs: files (required), language, top_module, timeout, +1 more.

list_boardsA

List all known FPGA board presets with target, device, package, and clock frequency.

Inputs: no named parameters.

list_buildsA

List all tracked builds (running and finished) with status summary.

Inputs: no named parameters.

list_ip_coresA

List all available IP cores in the registry. Optionally filter by category.

Inputs: category.

litex_buildC

Run LiteX board target with --build. Returns logs and output directory.

Inputs: board (required), args, output_dir, timeout.

litex_flowA

Run a generic LiteX board target with caller-provided args.

Inputs: board (required), args, timeout.

litex_socA

Generate LiteX SoC without building gateware. Returns logs and output directory.

Inputs: board (required), args, output_dir, timeout.

place_and_routeA

Synthesize HDL with Yosys then place-and-route with nextpnr in one step. Provide source as: code (single string), files (dict of filename→source), or project_dir (path to HDL files on disk). If backend=litex, runs LiteX build and ignores HDL inputs. Returns max frequency, critical path, resource utilization, bitstream, and full logs. Supported targets: ice40, ecp5, nexus, gowin. Common device/package values: ice40: device=hx1k|hx8k|up5k|lp1k package=tq144|qn84|sg48|cm81 ecp5: device=25k|45k|85k package=CABGA256|CABGA381 nexus: device=LIFCL-40-9BG400C (package embedded in device string) gowin: device=GW1N-UV4LQ144C6/I5 (package embedded in device string)

Inputs: top_module (required), code, files, project_dir, +12 more.

program_fpgaA

Flash a bitstream to an FPGA board using iceprog (ice40) or openFPGALoader (ecp5/gowin/nexus). Provide bitstream as base64 (from place_and_route output) or a file path on disk.

Inputs: target (required), bitstream_b64, bitstream_path, programmer, +2 more.

reload_registryA

Re-scan all core directories and rebuild the IP core cache. Call after adding cores to disk or editing config.json.

Inputs: no named parameters.

search_github_coresA

Search GitHub for open-source FPGA IP cores (MIT, BSD, Apache, GPL, etc). Returns repo names, star counts, descriptions and topics. Use import_github_core to download a result into the local registry.

Inputs: query (required), language, max_results.

simulateA

Compile and simulate HDL using Icarus Verilog (iverilog + vvp) or GHDL (VHDL). Provide the design source and a separate testbench. Returns all $display/$monitor output (Verilog) or report output (VHDL) and any runtime errors.

Inputs: code (required), testbench (required), language, timeout.

start_buildA

Start a long-running build command in the background. Returns a build_id to check progress with build_status. Use for synthesis, place-and-route, LiteX builds, or any command that takes minutes.

Inputs: cmd (required), label, work_dir.

synthesizeA

Synthesize HDL (Verilog, SystemVerilog, or VHDL) using Yosys or run LiteX backend. Provide source as: code (single string), files (dict of filename→source), or project_dir (path to HDL files on disk). Returns resource statistics and the list of inferred modules. Supported targets: generic, ice40, ecp5, gowin, xilinx, intel.

Inputs: top_module (required), code, files, project_dir, +6 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 25 tools

    Disambiguation5/5

    Each tool targets a distinct operation: build management, IP core management, HDL linting/simulation, synthesis/P&R, and LiteX flows. Overlaps like lint_hdl vs lint_project are clearly differentiated by single vs multi-file scope, so agents can reliably select the correct tool.

    Naming Consistency5/5

    All tool names follow consistent snake_case with a verb_noun pattern (e.g., list_boards, generate_ip, cancel_build). No camelCase or mixed styles, making naming predictable and easy to remember.

    Tool Count4/5

    25 tools cover a broad FPGA development workflow without being excessive. Each sub-domain (builds, IP cores, linting, synthesis, LiteX) is adequately represented, though the count is at the upper end of typical scopes.

    Completeness4/5

    The tool set covers the main FPGA flow: HDL linting, simulation, synthesis, place-and-route, and programming, plus build management and IP core discovery/import. Minor omissions like constraint file generation or waveform viewing exist, but core operations are well-supported.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Provides AI assistants with a complete FPGA toolchain for HDL linting, simulation, synthesis, and place-and-route across various hardware targets. It features a GitHub-backed IP core registry that enables users to search for and import MIT-licensed cores directly through their chat interface.
      15
      1
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      MCP server for deterministic Vivado FPGA automation including project scaffolding, simulation, synthesis, implementation, and gated bitstream generation.
      4
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      A minimal MCP server that provides 25 tools and 5 hooks to control Xilinx Vivado EDA for FPGA development, including session management, Tcl execution, smart diagnostics, and IP debugging.
      32
      166 PyPI
      181
      Apache 2.0