MCP J-Link Server MCP Server

Local setup required. This server has to be cloned and prepared on your machine before you register it in Claude Code.
1

Set the server up locally

Run this once to clone and prepare the server before adding it to Claude Code.

Run in terminal
git clone https://github.com/gghammer/MCP_JLINK.git
cd MCP_JLINK
pip install -e .
2

Register it in Claude Code

After the local setup is done, run this command to point Claude Code at the built server.

Run in terminal
claude mcp add mcp-jlink -- node "<FULL_PATH_TO_MCP_JLINK>/dist/index.js"

Replace <FULL_PATH_TO_MCP_JLINK>/dist/index.js with the actual folder you prepared in step 1.

README.md

Control SEGGER J-Link embedded debug probes via natural language.

MCP J-Link Server

透過 Model Context Protocol (MCP) 讓 AI 直接控制 SEGGER J-Link 嵌入式除錯探針。

讓 AI 自動讀取暫存器、分析記憶體、燒錄韌體、追蹤 RTT 日誌 — 用自然語言描述問題,AI 幫你除錯。

功能概覽

群組 工具 說明
探索 jlink_list_emulators jlink_get_status 列舉探針、查看連線狀態
連線 jlink_open jlink_connect jlink_close 開啟/連線/關閉探針
記憶體 jlink_memory_read jlink_memory_write 讀寫記憶體(8/16/32-bit)
燒錄 jlink_flash_file jlink_erase_chip 韌體燒錄、全片擦除
執行控制 jlink_reset jlink_halt jlink_go jlink_step 重置/暫停/繼續/單步
暫存器 jlink_register_read jlink_register_read_all jlink_register_write 讀寫 CPU 暫存器
RTT rtt_start rtt_read rtt_write rtt_stop rtt_get_status SEGGER RTT 即時通訊

21 個 MCP 工具,涵蓋嵌入式除錯的完整工作流程。

前置需求

  • Python 3.10+
  • SEGGER J-Link Software下載安裝
  • J-Link 探針(USB 連接)

注意:Python 位元數必須與 J-Link DLL 匹配(64-bit Python 需要 JLink_x64.dll)。

安裝

git clone https://github.com/你的帳號/MCP_JLINK.git
cd MCP_JLINK
pip install -e .

驗證安裝:

python -m mcp_jlink

伺服器啟動後會透過 STDIO 等待 MCP 請求(按 Ctrl+C 結束)。

整合設定

Claude Code / Antigravity

將以下設定加入 MCP 設定檔:

{
  "mcpServers": {
    "jlink": {
      "command": "python",
      "args": ["-m", "mcp_jlink"],
      "cwd": "/path/to/MCP_JLINK"
    }
  }
}

Claude Desktop

claude_desktop_config.json 中加入相同設定。

使用範例

設定完成後,直接用自然語言與 AI 對話:

你:我的板子卡住了,幫我看一下停在哪裡
AI:(自動執行 jlink_open → jlink_connect → jlink_halt → 讀取 PC/LR 暫存器 → 分析)
    程式停在 0x0800_1A3C,位於 SysTick_Handler 中。
    LR = 0xFFFF_FFF9,表示從 Thread Mode 進入中斷。
    看起來是 SysTick 中斷處理函式內的無限迴圈...
你:幫我燒錄 firmware.hex 到 STM32F407VG
AI:(自動執行 jlink_open → jlink_connect("STM32F407VG") → jlink_flash_file → jlink_reset)
    韌體燒錄完成!已寫入 32,768 bytes,耗時 1.2 秒。目標已重置並開始執行。
你:開啟 RTT 日誌,讓我看看板子在印什麼
AI:(自動執行 rtt_start → rtt_read → 持續讀取)
    RTT Channel 0 輸出:
    [INFO] System boot OK
    [INFO] Sensor init: BME280 detected
    [WARN] WiFi connection timeout, retrying...

J-Link DLL 搜尋

本專案不內含 J-Link SDK,DLL 搜尋優先順序:

  1. 環境變數 JLINK_SDK_PATH
  2. SEGGER 預設安裝路徑下的 JLink* 目錄(自動匹配帶版本號名稱如 JLink_V922
  3. pylink-square 內建搜尋

專案架構

src/mcp_jlink/
├── server.py        # FastMCP 伺服器 + 21 個 MCP tool 定義
├── connection.py    # JLinkManager 連線狀態機(單例)
├── errors.py        # 自訂例外 + 前置條件裝飾器
├── __main__.py      # python -m mcp_jlink 進入點
└── __init__.py

skills/               # AI 除錯情境指南(按需載入)
├── SKILL.md          # 主索引 + 情境路由表
├── crash-analysis.md
├── hardfault-diagnosis.md
├── peripheral-verification.md
├── flash-and-verify.md
├── rtt-logging.md
├── memory-leak-detection.md
├── variable-monitoring.md
├── interrupt-analysis.md
├── low-power-debug.md
└── batch-flashing.md

連線狀態機

DISCONNECTED ──open()──> PROBE_OPEN ──connect()──> TARGET_CONNECTED ──rtt_start()──> RTT_ACTIVE
     ^                      |                           |                              |
     └──────close()─────────┴──────────close()──────────┴──────────close()─────────────┘

每個工具透過裝飾器自動檢查前置條件,不需要手動管理連線狀態。

開發

# 安裝開發相依
pip install -e ".[dev]"

# 執行測試
pytest

License

MIT

Tools (21)

jlink_list_emulatorsList available J-Link debug probes.
jlink_get_statusCheck the connection status of the J-Link probe.
jlink_openOpen a connection to a specific J-Link probe.
jlink_connectConnect to the target device.
jlink_closeClose the connection to the probe.
jlink_memory_readRead data from target memory.
jlink_memory_writeWrite data to target memory.
jlink_flash_fileFlash a firmware file to the target.
jlink_erase_chipPerform a full chip erase.
jlink_resetReset the target device.
jlink_haltHalt the target CPU.
jlink_goResume target execution.
jlink_stepExecute a single CPU instruction.
jlink_register_readRead a specific CPU register.
jlink_register_read_allRead all CPU registers.
jlink_register_writeWrite to a specific CPU register.
rtt_startStart SEGGER RTT logging.
rtt_readRead data from RTT channel.
rtt_writeWrite data to RTT channel.
rtt_stopStop RTT logging.
rtt_get_statusGet RTT connection status.

Environment Variables

JLINK_SDK_PATHPath to the J-Link SDK if not in default installation directory.

Configuration

claude_desktop_config.json
{"mcpServers": {"jlink": {"command": "python", "args": ["-m", "mcp_jlink"], "cwd": "/path/to/MCP_JLINK"}}}

Try it

My board is unresponsive, can you halt the CPU and read the program counter and link register?
Flash the firmware.hex file to my STM32F407VG target and reset it.
Start the RTT logger and show me the output from channel 0.
Read the memory at address 0x08000000 to verify the firmware was written correctly.

Frequently Asked Questions

What are the key features of MCP J-Link Server?

Direct control of SEGGER J-Link debug probes via natural language.. Full suite of 21 tools for memory, register, and execution control.. Integrated support for SEGGER RTT real-time logging.. Automated state management for probe connections and target debugging..

What can I use MCP J-Link Server for?

Automated firmware flashing and verification during development cycles.. Remote debugging of embedded systems by analyzing CPU registers and memory state.. Real-time monitoring of system logs via RTT without needing a serial console.. Rapid diagnosis of hard faults by inspecting stack frames and registers..

How do I install MCP J-Link Server?

Install MCP J-Link Server by running: git clone https://github.com/gghammer/MCP_JLINK.git && cd MCP_JLINK && pip install -e .

What MCP clients work with MCP J-Link Server?

MCP J-Link Server works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep MCP J-Link Server docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare