stm32-stlink-mcp
{"type": "text"}
stm32-stlink-mcp
STM32マイクロコントローラをST-LINK経由でデバッグするためのMCPサーバーで、STMicroelectronics純正のSTM32CubeCLTツールセット(ST-LINK_gdbserver、STM32_Programmer_CLI、arm-none-eabi-gdb(GDB/MI2経由で駆動))を基に構築されています。OpenOCD、J-Link、probe-rsは使用しません。
Architecture
デバッグセッションは、STが公式に文書化したワークフロー(UM2576、「STM32CubeIDE ST-LINK GDB server」)を正確にミラーリングした、2つの子プロセスのペアです:
arm-none-eabi-gdb --interpreter=mi2 --(TCP, target extended-remote)--> ST-LINK_gdbserver --(USB)--> ST-LINK --(SWD)--> STM32arm-none-eabi-gdbはMI2モードで駆動されるため、サーバーはGDB Remote Serial Protocolを手動で実装する代わりに、ソースレベルステップ、シンボリックブレークポイント、シンボル対応の式評価を無料で利用できます。ST-LINK_gdbserverはセッションの存続期間中、プローブへのUSBハンドルを保持します。gdbのload(MI: -target-download)によるフラッシュは、サーバーによってSTM32CubeProgrammerに透過的に委任されるため、再フラッシュのためにセッションを終了する必要はありません。スタンドアロンのワンショットフラッシュ(flash_standalone、セッション不要)はSTM32_Programmer_CLIを直接呼び出すため、同じプローブ上の既存セッションと競合します — ツールの説明を参照してください。
Related MCP server: dbgprobe-mcp-server
Setup
npm install
npm run buildSTM32CubeCLTがインストールされ、そのbin/ディレクトリにアクセス可能である必要があります — すでにPATH上にあるか(CLTインストーラーがデフォルトでこれを行います)、またはSTMCP_CUBECLT_PATH/ツールごとのオーバーライドを介して。確認するにはnpm run doctorを実行してください。
Running
node dist/index.js serve # starts the MCP server on stdio (default mode)
node dist/index.js doctor # pre-flight check: tool resolution, connected probes, udev rules
node dist/index.js doctor --jsonRegistering with an MCP client
{
"mcpServers": {
"stm32-stlink": {
"command": "node",
"args": ["<path-to-this-repo>/stmcp/dist/index.js"]
}
}
}Configuration (environment variables)
変数 | デフォルト | 目的 |
| — | バイナリごとのオーバーライド(最優先) |
| — | CubeCLTインストールルート; サブパスは |
| — | デフォルトのプローブシリアル(省略時、接続されているプローブが1つだけなら自動選択) |
|
| デフォルトのMCUデバイス文字列 |
|
|
|
|
| SWD/JTAGクロック |
|
| 同時デバッグセッションの上限 |
|
| 「Waiting for debugger connection...」を待つ時間 |
|
|
|
| — | オプションのログファイル(stderrは常に使用されます — stdoutはMCPフレーミング用に予約されています) |
|
| 消去パスを有効にします |
|
|
|
|
|
|
| (unrestricted) | ELF/binファイル引数用のカンマ区切りの許可リストルート |
|
| ファイル引数の最大サイズ |
|
| 書き込みガード用のフラッシュアドレスウィンドウ(デフォルト: 128KB、STM32G431CB) |
Tools
ドメイン | ツール | 目的 |
Probe |
| 接続されているST-LINKプローブを一覧表示 |
Session |
| gdbserver+gdbを起動し、ELFシンボルを読み込み、接続 |
Session |
| セッションのクリーンな終了 |
Session |
| セッション情報(1つ、またはすべて) |
Flash |
| STM32_Programmer_CLIによるワンショットフラッシュ、セッション不要 |
Flash |
| 開いているセッション内でgdb |
Execution |
| 再開/続行 |
Execution |
| 割り込み |
Execution |
| リセット(monitor reset [halt]) |
Execution |
| ステップオーバー/イン/アウト |
Breakpoints |
| ファイル:行、シンボル、または |
Memory |
| 生メモリアクセス(書き込みはガードされています) |
Registers |
| 名前付きコアレジスタ |
Registers |
| ワンコールのCortex-M SCBフォールトレジスタダンプ(CFSR/HFSR/... デコード済み) |
Expressions |
| gdb MIによるシンボル対応の評価 |
Deferred to v2
SVDペリフェラルレジスタツール(memory_read/write + evaluate_expressionはすでにアドレスですべてにアクセス可能)、ライブ/ストリーミングメモリポーリング、プラグインシステム、チップごとのメモリ領域許可リスト、任意のgdb monitorパススルー、およびオプションバイト/RDPツール(ブリック可能、意図的にスコープ外)
RTT
RTT(SEGGER Real Time Transfer — ライブで非停止のコンソール/変数トレース)は、このサーバーでは意図的に実装されていません。ST-LINK_gdbserverのGDB/MIスタブにはノンストップモードがないため、このサーバーのdebug_connectセッションを通じてメモリを読み取るには、まずコアを停止する必要があります — これではRTTの目的が損なわれます。正しいメカニズムは、コアを決して停止させない直接APメモリアクセスです(ST自身のSTM32CubeMonitorソースを読むことで確認済みで、これがまさにそれを使用しており、STM32_Programmer_CLIの-r32fastでも確認できます)。
それがstrttがすでに行っていることであり、strtt-mcpはそれを独自のMCPサーバー(strtt_start/strtt_stop/strtt_status/strtt_read/strtt_write)としてラップしています。このサーバーを経由するのではなく、並行して登録してください:
{
"mcpServers": {
"stm32-stlink": { "command": "node", "args": ["<...>/mcp-server/dist/index.js"] },
"strtt": {
"command": "node",
"args": ["<path-to-strtt-repo>/mcp/dist/index.js"],
"env": { "STRTT_BIN": "<path-to-strtt-binary>" }
}
}
}strtt_startをtcp: trueで開始すると、USBデバイスを直接要求する代わりに共有ST-LINKサーバーを介して接続します — これにより、GdbServerProcessが常に-t/--sharedをST-LINK_gdbserverに渡すため、ここで開いているdebug_connectセッションと並行して実行できます。tcp: trueがない場合、strttと開いているデバッグセッションは同じプローブをめぐって競合します。
Hardware verification runbook
ST-LINKとターゲットが接続されている場合:
node dist/index.js doctor # confirm probe + tools resolve
npx @modelcontextprotocol/inspector node dist/index.js # interactive tool testing次に、インスペクタまたはMCPクライアントを介して:
list_probes→ プローブのシリアルが表示されます。debug_connect { elfPath, device, interface: "swd", serial }→sessionIdを返します。breakpoint_set { sessionId, location: "main" }→ ブレークポイント番号を返します。debug_run { sessionId }→reason: "breakpoint-hit"で停止します。register_read { sessionId, registers: ["pc","sp","lr","r0"] }evaluate_expression { sessionId, expression: "<a known global>" }read_fault_registers { sessionId }→ リセット直後は良性/ゼロのフラグ。debug_disconnect { sessionId }→ 孤立プロセスがないことを確認:ps aux | grep -E 'ST-LINK_gdbserver|arm-none-eabi-gdb'セッションを開かずに
flash_standalone { file, reset: "hard", run: true }を実行。ネガティブテスト: セッションを開き、同じシリアルで
flash_standaloneを呼び出す →DEVICE_BUSYが期待されます。
注: debug_connectはターゲットのCPUを停止させます。予期しない停止が安全でない方法でアクチュエータ/出力を積極的に駆動しているボードには、事前に確認せずに接続しないでください。
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceA GDB/MI protocol server based on the MCP protocol, providing remote application debugging capabilities.68MIT
- AlicenseAqualityCmaintenanceStateful MCP server for driving debug probes (J-Link) to flash, debug, and inspect embedded targets. Enables AI agents to perform flash, memory, breakpoint, and ELF/SVD-aware operations conversationally.4111MIT
- AlicenseNot gradedqualityCmaintenanceMCP server for embedded debugging based on probe-rs, providing 22 tools for ARM Cortex-M and RISC-V microcontrollers, including connection, memory operations, breakpoints, flash programming, and RTT communication.2MIT
- AlicenseNot gradedqualityCmaintenanceAn MCP server that provides comprehensive debugging capabilities for J-Link debuggers, enabling memory, flash, register, and RTT operations through AI assistants.32MIT
Related MCP Connectors
MCP server for Klever blockchain smart contract development.
An MCP server that let you interact with Cycloid.io Internal Development Portal and Platform
A MCP server built for developers enabling Git based project management with project and personal…
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/phryniszak/stmcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server