MCP J-Link Server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP J-Link Server Flash firmware.hex to my STM32 and check the RTT logs."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP J-Link Server
透過 Model Context Protocol (MCP) 讓 AI 直接控制 SEGGER J-Link 嵌入式除錯探針。
讓 AI 自動讀取暫存器、分析記憶體、燒錄韌體、追蹤 RTT 日誌 — 用自然語言描述問題,AI 幫你除錯。
功能概覽
群組 | 工具 | 說明 |
探索 |
| 列舉探針、查看連線狀態 |
連線 |
| 開啟/連線/關閉探針 |
記憶體 |
| 讀寫記憶體(8/16/32-bit) |
燒錄 |
| 韌體燒錄、全片擦除 |
執行控制 |
| 重置/暫停/繼續/單步 |
暫存器 |
| 讀寫 CPU 暫存器 |
RTT |
| SEGGER RTT 即時通訊 |
共 21 個 MCP 工具,涵蓋嵌入式除錯的完整工作流程。
Related MCP server: jlink-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 搜尋優先順序:
環境變數
JLINK_SDK_PATHSEGGER 預設安裝路徑下的
JLink*目錄(自動匹配帶版本號名稱如JLink_V922)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]"
# 執行測試
pytestLicense
MIT
Available Tools
21 toolsjlink_closeA
關閉 J-Link 連線並釋放所有資源。
會自動停止 RTT(若啟動中)、斷開目標連線、關閉探針連線。
Inputs: no named parameters. Returns: result
jlink_connectA
連線到目標晶片。
必須先透過 jlink_open 開啟探針。常用晶片名稱範例: STM32F407VE, STM32F103C8, nRF52832_xxAA, LPC1768, ATSAMD21G18 等。
Args: chip_name: 目標晶片名稱(SEGGER 裝置資料庫中的名稱) speed: 通訊速率,可填 "auto"、"adaptive" 或數字 kHz(如 "4000") interface: 除錯介面,"SWD" 或 "JTAG"(預設 SWD)
Inputs: chip_name (required), speed, interface. Returns: result
jlink_erase_chipA
擦除目標晶片的整個 Flash 記憶體。
注意:此操作不可逆轉,將清除晶片上所有已燒錄的韌體。
Inputs: no named parameters. Returns: result
jlink_flash_fileA
燒錄韌體檔案到目標晶片的 Flash 記憶體。
支援 .hex、.bin、.srec 等常見韌體格式。 燒錄前會自動擦除對應的 Flash 區塊。
Args: file_path: 韌體檔案的絕對路徑 address: 燒錄起始位址(.hex 檔通常忽略此參數),預設 "0x0"
Inputs: file_path (required), address. Returns: result
jlink_get_statusA
取得目前 J-Link 連線狀態的完整摘要。
顯示探針連線狀態、目標晶片資訊、RTT 狀態等。 此工具隨時可以呼叫。
Inputs: no named parameters. Returns: result
jlink_goB
繼續執行目標晶片的 CPU(從目前位置繼續)。
Inputs: no named parameters. Returns: result
jlink_haltB
暫停目標晶片的 CPU 執行。
Inputs: no named parameters. Returns: result
jlink_list_emulatorsA
列舉所有透過 USB 連線的 J-Link 除錯探針。
回傳每支探針的序號與產品名稱。 此工具不需要先開啟連線即可使用。
Inputs: no named parameters. Returns: result
jlink_memory_readB
讀取目標晶片的記憶體。
Args: address: 起始位址,支援十六進位格式如 "0x20000000" 或十進位 num_units: 讀取的單元數量(依 width 而定) width: 資料寬度,可選 8、16 或 32(位元),預設 32
Inputs: address (required), num_units, width. Returns: result
jlink_memory_writeB
寫入資料到目標晶片的記憶體。
Args: address: 起始位址,支援十六進位格式如 "0x20000000" 或十進位 data: 要寫入的資料陣列,每個元素對應一個 width 單元 width: 資料寬度,可選 8、16 或 32(位元),預設 32
Inputs: address (required), data (required), width. Returns: result
jlink_openA
開啟與 J-Link 探針的連線。
若只有一支探針連線,可不指定參數。若有多支探針,需透過序號指定。 也可透過 IP 位址連線到遠端 J-Link(透過 J-Link Remote Server)。
Args: serial_no: J-Link 探針序號(可透過 jlink_list_emulators 取得) ip_addr: 遠端 J-Link 的 IP 位址與埠號,格式如 "192.168.1.100:19020"
Inputs: serial_no, ip_addr. Returns: result
jlink_register_readB
讀取指定的 CPU 暫存器值。
Args: register: 暫存器索引(0=R0, 1=R1, ..., 13=SP, 14=LR, 15=PC, 16=xPSR)
Inputs: register (required). Returns: result
jlink_register_read_allA
讀取所有 CPU 暫存器的值。CPU 必須處於暫停狀態。
Inputs: no named parameters. Returns: result
jlink_register_writeB
寫入值到指定的 CPU 暫存器。
Args: register: 暫存器索引(0=R0, ..., 13=SP, 14=LR, 15=PC) value: 要寫入的 32 位元值
Inputs: register (required), value (required). Returns: result
jlink_resetB
重置目標晶片。
Args: halt: 重置後是否暫停 CPU(預設 True,暫停在重置向量)
Inputs: halt. Returns: result
jlink_stepA
執行單一指令(單步執行)。CPU 必須處於暫停狀態。
Inputs: no named parameters. Returns: result
rtt_get_statusB
取得 RTT 緩衝區狀態資訊。
Inputs: no named parameters. Returns: result
rtt_readA
從 RTT 上行緩衝區讀取資料(裝置→主機方向)。
讀取的資料會從緩衝區中移除。若無資料則回傳空結果。
Args: buffer_index: RTT 上行緩衝區索引,預設 0(通常是 Terminal) num_bytes: 最大讀取位元組數,預設 1024
Inputs: buffer_index, num_bytes. Returns: result
rtt_startA
啟動 RTT(Real-Time Transfer)通訊。
目標韌體必須已整合 SEGGER RTT 函式庫。 啟動後可使用 rtt_read / rtt_write 進行雙向通訊。
Inputs: no named parameters. Returns: result
rtt_stopB
停止 RTT 通訊。
Inputs: no named parameters. Returns: result
rtt_writeB
寫入資料到 RTT 下行緩衝區(主機→裝置方向)。
Args: text: 要傳送的文字內容 buffer_index: RTT 下行緩衝區索引,預設 0
Inputs: text (required), buffer_index. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 21 tools
Every tool has a clearly distinct purpose with no ambiguity. Tools are well-organized into categories: core J-Link operations (connect, open, close, reset, go, halt, step), memory operations (read/write), register operations (read/write), flash operations (erase, flash), emulator management (list), status queries (get_status), and RTT operations (start, stop, read, write, get_status). Even similar-sounding tools like jlink_memory_read and jlink_register_read target different resources (memory vs CPU registers).
Perfectly consistent snake_case naming throughout. All tools follow a clear prefix pattern: 'jlink_' for core debugger operations and 'rtt_' for RTT-specific operations, followed by descriptive verb_noun combinations (e.g., jlink_connect, jlink_memory_write, rtt_start). This creates a predictable and readable naming convention across all 21 tools.
21 tools is slightly high but reasonable for a comprehensive embedded debugging server. The server covers multiple aspects: probe management, target control, memory/register access, flashing, and RTT communication. While some consolidation might be possible (e.g., register read/write could be one tool with a mode parameter), each tool earns its place by providing distinct functionality needed for embedded development workflows.
The tool surface provides complete coverage for J-Link debugging operations. It includes all essential CRUD/lifecycle operations: connection management (open/close/connect), target control (reset/halt/go/step), memory access (read/write), register access (read/write), flash programming (erase/flash), status monitoring, and RTT communication (start/stop/read/write). No obvious gaps exist for typical embedded debugging scenarios.
Maintenance
Related MCP Connectors
Enable secure connectivity between Sentry issues and debugging data, and LLM clients, using a Model Context Protocol (MCP) server.
Live browser debugging for AI assistants — DOM, console, network via MCP.
The Cortex MCP server provides read-only access to real-time engineering context from the Cortex developer portal, allowing AI coding assistants to answer natural language questions about your organization's catalog (microservices, libraries, domains, teams, infrastructure), scorecards (engineering standards and best practices), initiatives (goals and deadlines), and Engineering Intelligence metrics. It includes tools for querying documentation, tracking personal entities, and accessing AI-assisted insights across the entire Cortex ecosystem.
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Related MCP Servers
- AlicenseAqualityDmaintenanceStateful 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.4149 PyPI11MIT
- AlicenseAqualityDmaintenanceEnables AI assistants like Claude to directly debug microcontrollers via JLink, supporting breakpoints, single-step, memory/register access, variable inspection, RTT logging, and firmware flashing.257MIT
- AlicenseAqualityDmaintenanceEnables LLMs to interact with embedded devices by reading and writing Segger RTT data through a J-Link debugger.91MIT
- AlicenseAqualityDmaintenanceEnables AI assistants to interact with STM32 development boards via J-Link debugger using RTT communication, supporting connection, logging, memory operations, and firmware flashing through natural language.121MIT