STM32-MCPのロゴ

STM32-MCP

コミュニティ
shieldyguy

build, flash, debug stm32 projects

公開者shieldyguy
リポジトリstm32-mcp
言語Python
フォーク
2
スター
25
利用可能なツール
0
通信方式stdio
カテゴリ
ライセンスMIT
リンク
  • ツールをAIワークフローに接続

    STM32-MCPは、対応するAIクライアントやAIエージェントから利用できるMCP機能を提供します。

  • 0個の利用可能なツール

    呼び出し可能なアクションを以下で確認できます。サーバーから提供されている場合は、名前や説明も表示されます。

  • コピーして使える設定

    セットアップ用の設定例を使って、お好みのMCPクライアントにこのサーバーを設定できます。

  • オープンソースの注目度

    リンク先のリポジトリには25件のスターと2件のフォークがあります。

stm32-mcp

MCP server that lets Claude Code build, flash, and communicate with STM32 hardware.

stm32-mcp is pretty specific to how I tend to approach hardware development, but it is likely useful to others, too! It could be massaged to fit lots of workflows, but this is laser focused on mine (stlink-v3 mini, VCP on that header, STM32 microcontroller).

You can do things like:

me: hey who is plugged in right now?

claude: two unnamed probes connected to two unnamed PCBs

me: k ask them who they are and give them a nickname based on their response

claude: got it, do you want to nickname the probes too? your boards are 'doorbell A' and 'synthesizer B'

me: yep, I put paint marker on those probes. call doorbell's 'blue' and the synth's 'red'

claude: done. what's next?

me: give them both VCP commands so they can talk to each other, then have the doorbell ask the synth on a date

claude: thinking... done, synth declined. plenty of fish in the sea, doorbell!

MCP (Model Context Protocol) is an open standard that lets AI assistants like Claude use external tools. This server gives Claude the ability to compile your firmware, flash it to a board, talk to it over serial, and read memory via SWD. It is flexible and conversational.

[!WARNING] This server gives an AI direct access to your compiler, debug probe, and serial ports. It can flash firmware, overwrite memory, and send arbitrary data to your hardware. This is powerful and useful, but it is not a sandbox. Know what's connected before you let it rip.

Prerequisites

  • STM32CubeIDE installed at /Applications/STM32CubeIDE.app (macOS) or /opt/st/stm32cubeide_* (Linux)
  • Python 3.10+
  • OpenOCD (brew install open-ocd) — for flash, memory read/write, and live monitoring
  • open-source stlink tools (brew install stlink) — for probe enumeration
  • ST-Link connected via USB (for flash/board info)
  • Serial port available (ST-Link VCP or USB-UART adapter)

Installation

bash
git clone https://github.com/shieldyguy/stm32-mcp.git
cd stm32-mcp
python3 -m venv .venv
source .venv/bin/activate
pip install -e .

Register with Claude Code

Option A: CLI

bash
claude mcp add stm32 -- /path/to/stm32-mcp/.venv/bin/python -m stm32_mcp.server

Option B: Project config

Add to your project's .claude/settings.json or .claude.json:

json
{
  "mcpServers": {
    "stm32": {
      "command": "/path/to/stm32-mcp/.venv/bin/python",
      "args": ["-m", "stm32_mcp.server"]
    }
  }
}

Self-serve CLI

bin/ contains four thin wrappers over the same code the MCP tools use

CommandUsage
stm32-listList connected probes + boards with nicknames
stm32-flashstm32-flash <probe|board> <file.elf> [--noverify] [--noreset]
stm32-buildstm32-build <project_path> [Debug|Release] [--clean]
stm32-bfstm32-bf <project_path> <probe|board> [Debug|Release] [--clean]
stm32-helpList these commands with their usage (auto-generated from the scripts)

Add bin/ to your PATH:

bash
export PATH="/path/to/stm32-mcp/bin:$PATH"

Probe nicknames and board nicknames resolve.

Builds share the MCP's headless CubeIDE workspace lock, so a stm32-build/stm32-bf racing an agent-driven build will queue behind it.

Available Tools

Build & Flash

ToolDescription
stm32_buildCompile firmware using CubeIDE headless builder
stm32_flashFlash .elf/.bin/.hex to board via ST-Link SWD
stm32_build_and_flashBuild + flash in one step (the 90% case)
stm32_board_infoRead ST-Link/MCU info (device ID, flash size, voltage)

Multi-Board Management

ToolDescription
stm32_list_probesShow all connected boards with nicknames and MCU IDs
stm32_set_nicknameName a board (by MCU UID) or probe (by ST-Link SN)

Board nicknames follow the physical MCU (persist across probe swaps). Probe nicknames follow the ST-Link hardware. Use nicknames in any probe parameter across all tools.

Serial Communication

ToolDescription
serial_list_portsList serial ports (marks ST-Link VCP ports with nicknames)
serial_connectOpen a serial connection
serial_sendSend data and read response
serial_readRead buffered serial data
serial_disconnectClose a serial connection
serial_sequenceRun multi-step send/delay/memory sequences in one call

Debug & Monitoring

ToolDescription
stm32_read_memoryRead memory by address or variable name (from ELF symbols)
stm32_write_memoryWrite memory by address or variable name
live_memory_startStart continuous background memory monitoring via SWD
live_memory_readRead recent entries from a live memory session
live_memory_stopStop a live memory session

Hardware Sequences

serial_sequence schedules multiple steps (serial send, delay, webcam capture, and SWD memory read/write) in one tool call. delays use a time.sleep() in the executor thread. Claude can't reliably time individual tool calls, so this allows tight timing of commands and expectations.

Step types

json
[
  { "send": "SIM_LEFT", "to": "/dev/cu.usbmodem11202" },
  { "delay_ms": 500 },
  {
    "send": "GET_BLINK_STATE",
    "to": "/dev/cu.usbmodem11402",
    "expect": "BLINK"
  },
  { "capture": true, "label": "post_brake" },
  {
    "mem_write": true,
    "address": "0x48000418",
    "value": "0x40",
    "probe": "yellow"
  },
  { "delay_ms": 1000 },
  {
    "mem_read": true,
    "address": "0x48000400",
    "count": 2,
    "probe": "yellow",
    "label": "gpio_post"
  }
]
  • Send step: {send, to, expect?, read_timeout?, line_ending?} — to is the port path from serial_connect
  • Delay step: {delay_ms} — real time.sleep(), not tool-call round-trips
  • Capture step: {capture: true, label?, device_index?} — PNG saved to /tmp/stm32-captures/
  • Memory write step: {mem_write: true, address | symbol + elf_path, value, probe, width?}
  • Memory read step: {mem_read: true, address | symbol + elf_path, probe, count?, width?, label?}

Memory step notes:

  • probe accepts ST-Link SN, probe nickname, or board nickname
  • address is hex (e.g. "0x48000418"); alternatively use symbol + elf_path to resolve by name
  • width is 8/16/32 bits, defaults to 32 (auto-detected from symbol size when using symbol)
  • Each memory op currently launches a fresh OpenOCD process (~tens of ms overhead per op), so inter-memory-op timing below ~50ms is approximate. Delays themselves are accurate.

Parameters

  • on_failure: "continue" (default) runs all steps regardless. "stop" aborts on first failure.
  • filter_responses: When true, expect patterns match only >-prefixed VCP response lines (ignores debug noise).

Output

Step 1 [/dev/cu.usbmodem11202] SEND: SIM_LEFT
  Response: >OK:SIM_LEFT

Step 2 DELAY: 500ms

Step 3 [/dev/cu.usbmodem11402] SEND: GET_BLINK_STATE
  Response: >BLINK_STATE:BLINK
  Expect "BLINK": PASS

Step 4 [yellow] MEM_WRITE: Wrote 0x00000040 to 0x48000418

Step 5 DELAY: 1000ms

Step 6 [yellow] MEM_READ: gpio_post 0x48000400: 0xabffdfff 0x00000080

Summary: 2/2 sends OK, 1/1 assertions PASS, 1/1 mem_writes OK, 1/1 mem_reads OK

Live Memory Monitoring

Monitor firmware variables in real time via SWD, without modifying firmware or using serial. OpenOCD runs as a persistent subprocess and polls variables over its built-in TCL socket.

Start a session

live_memory_start(
    variables='["blink", "ts"]',       # symbol names from ELF
    elf_path="/path/to/firmware.elf",
    probe="taillight",                  # board/probe nickname
    interval_ms=500                     # min 250ms
)

Variables can be:

  • Symbol names (strings): "blink" — resolved from the ELF via arm-none-eabi-nm
  • Dicts with symbol + type: {"symbol": "temperature", "type": "float"} — interprets 32-bit value as IEEE 754
  • Dicts with raw address: {"address": "0x20000304", "name": "x", "width": 32}

Read recent values

live_memory_read(session_id="abc123", last_n=10)

Returns recent entries from an in-memory ring buffer (max 100 entries). Full history is written to the JSONL output file.

JSONL output format

json
{ "t": 1709830123.456, "elapsed_s": 1.002, "values": { "blink": 65539 } }

Stop a session

live_memory_stop(session_id="abc123")

Returns stats: duration, read count, error count, output file path.

Constraints

  • One session per probe — this is a hardware constraint (single SWD connection)
  • Stop before flashing — live_memory holds the SWD connection; stm32_flash and stm32_read/write_memory will fail if a session is active
  • TCL port 6666 — OpenOCD's default. Stop other OpenOCD instances first if there's a conflict

Serial Defaults

  • Baud rate: 115200
  • Line ending: LF (\n)
  • Read polling: 50ms inter-byte sleep, 200ms silence break
  • Buffer limits: 4096 bytes max read

Development

MCP Inspector

bash
source .venv/bin/activate
mcp dev src/stm32_mcp/server.py

Loopback Testing

Serial tools can be tested without hardware using pyserial's loopback:

python
import serial
ser = serial.serial_for_url("loop://", baudrate=115200, timeout=0.1)
ser.write(b"PING\n")
print(ser.read(100))  # b'PING\n'

STM32-MCPのMCPを複数のAIモデルで活用

TypingMindはワークスペース単位でMCPツールに接続します。そのため、一度STM32-MCPに接続すれば、モデルごとに個別に設定することなく、TypingMind内のさまざまなAIモデルで利用できます。 このMCPは、デバイス上のTypingMind MCPコネクタを通じてローカルで動作します。

ローカルコネクタのセットアップガイド

MCPサーバーが、お使いのコンピューター上のローカルファイル、アプリ、非公開リソースにアクセスする必要がある場合は、この方法を使います。

1

MCP設定を開く

TypingMindで「設定」、「詳細設定」、「MCP」の順に進み、「コネクタを設定」を選択してください。

  1. ブラウザでTypingMindを開いてください。
  2. 設定アイコンをクリックしてください。
  3. 「詳細設定」に移動してください。
  4. 「MCP」セクションを開いてください。
  5. 「コネクタを設定」をクリックし、「このデバイス」を選択してください。
「このデバイス」が選択されたTypingMindのMCPコネクタ設定画面
2

コネクタのコマンドを実行

「このデバイス」を選択し、TypingMindからコマンドをコピーしてターミナルで実行してください。MCPの使用中は、プロセスを実行したままにしてください。

  1. TypingMindに表示されるセットアップコマンドをコピーしてください。
  2. macOSではターミナルを、WindowsではWindows Terminalを開いてください。
  3. コマンドを貼り付けて実行してください。
  4. ターミナルで続行の確認を求められた場合は、パッケージのインストールを承認してください。
  5. MCPツールの使用中は、ターミナルウィンドウを開いたまま、プロセスの実行を継続してください。
3

STM32-MCPをサーバーとして追加

コネクタのステータスが「準備完了」になったら、「サーバーを編集」をクリックし、MCPサーバーの設定を貼り付けてください。

  1. コネクタのステータスが「準備完了」になるまでお待ちください。
  2. 「サーバーを編集」をクリックしてください。
  3. STM32-MCPのMCPサーバー設定を貼り付けてください。
  4. サーバー一覧を保存してください。
  5. コネクタが引き続き使用可能か確認するには、更新してください。
稼働中のサーバーと「サーバーを編集」ボタンが表示されたTypingMindのMCP設定画面
{
  "mcpServers": {
    "stm32-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

複数のモデルで同じ接続を使用

サーバー一覧を保存し、「プラグイン」を開いてSTM32-MCPのMCPツールを有効にしてください。その後、TypingMindで対応するAIモデルを選択し、チャットでツールを使うか、AIエージェントに割り当ててください。

  1. TypingMindの「プラグイン」ページを開いてください。
  2. STM32-MCPのMCPツールを有効にしてください。
  3. チャットを開始し、使用するAIモデルを選択してください。
  4. MCPツールをチャットで使うか、AIエージェントに割り当ててください。
  5. MCPに再接続することなく、必要に応じて別のAIモデルに切り替えられます。
選択したAIモデルと有効なMCPツールを使用したTypingMindのチャット
STM32-MCPを使ってこのタスクを手伝ってもらえますか?
STM32-MCP
はい、読みました。
STM32-MCPで調べた結果をお伝えします。

よくある質問

STM32-MCP MCPサーバーは何に使いますか?

STM32-MCPは、対応するAIクライアントを外部ツールやコンテキストに接続するためのMCPサーバーです。TypingMindでは、このMCPサーバーを一度追加するだけで、AIワークスペース内でそのツールを利用できるようになります。

TypingMindでSTM32-MCP MCPを複数のAIモデルと併用できますか?

はい。TypingMindはワークスペース単位でMCPツールに接続するため、モデルごとにMCPサーバーを設定する必要はありません。Claude、ChatGPT、Geminiや、TypingMindで設定したその他のAIモデルでSTM32-MCPを利用できます。

TypingMindでSTM32-MCP MCPを使うメリットは何ですか?

TypingMindは、複数のAIモデル、プロンプト、プラグイン、AIエージェント、APIキー、MCPツールを1つのワークスペースにまとめられる、LLMチャット向けの優れたフロントエンドです。STM32-MCPを接続すると、TypingMindでチャットのワークフローを整理しながら、お好みのモデルでそのMCPツールを利用できます。

STM32-MCP MCPをTypingMindに接続するにはどうすればよいですか?

STM32-MCPはTypingMindのローカルMCPコネクタ経由で動作します。MCPサーバーがコンピューター上のローカルファイル、デスクトップアプリ、コマンドラインツール、プライベートリソースにアクセスする必要がある場合に最適です。

TypingMindでSTM32-MCP MCPのどのようなツールを利用できますか?

STM32-MCPはMCP機能を提供しています。TypingMindのプラグインページで有効にすると、チャットで使用したり、AIエージェントに割り当てたりできます。

STM32-MCP MCPを使うには、APIキーをTypingMindと共有する必要がありますか?

いいえ。TypingMindはローカルファーストの設計で、モデルプロバイダー、APIキー、プロンプト、MCP設定をご自身で管理できます。STM32-MCPで認証が必要な場合は、接続の作成時に、そのMCPサーバーに必要なヘッダー、OAuth設定、またはローカル設定を追加してください。

関連するMCPサーバー

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇