Skip to main content
Glama
J-Link RTT Viewer MCP

J-Link RTT Viewer MCP

J-Link RTT Viewer MCP Server

English | 中文


English

An MCP server that wraps J-Link RTT Viewer, enabling AI assistants to control STM32 development boards via natural language.

Quick Start (3 steps)

# 1. Clone and install
git clone https://github.com/MisakaMikoto128/J-Link-RTT-Viewer-MCP.git
cd J-Link-RTT-Viewer-MCP
python -m venv .venv && .venv\Scripts\activate  # Windows
pip install -r requirements.txt

# 2. Configure Claude Desktop
# Add to %APPDATA%\Claude\claude_desktop_config.json:
# { "mcpServers": { "jlink-rtt": { "command": "python", "args": ["-m", "src.server"], "cwd": "C:\\path\\to\\J-Link-RTT-Viewer-MCP" } } }

# 3. Restart Claude Desktop and use natural language!

Tool Reference

Tool

Parameters

Description

connect

target, interface="SWD", speed=4000

Connect to MCU. Target example: STM32F103C8

disconnect

(none)

Disconnect from J-Link

read_rtt

channels=[0], max_size=4096

Read RTT log data from MCU

write_rtt

data, channel=0

Send command to MCU via RTT

reset

mode="normal"

Reset MCU. Modes: normal, auto_reconnect, halt

flash_firmware

firmware_path

Flash .hex or .bin file to MCU

get_device_info

(none)

Get connected device details

read_memory

address, size

Read MCU memory (hex address like 0x08000000)

write_memory

address, data

Write data to MCU memory

start_log_recording

log_dir="logs"

Record RTT output to file

stop_log_recording

(none)

Stop recording

set_rtt_channel

channel

Set default RTT channel (0-15)

Common Commands (for write_rtt)

freq 200      - Set LED blink interval to 200ms
freq 1000     - Set LED blink interval to 1s
mode on       - Turn LED on
mode off      - Turn LED off
mode blink    - Set LED to blink mode
status        - Get current settings
ping          - Test connection (returns "pong")
reset         - Reset MCU software

Example: Control LED

User: Connect to my STM32F103C8 board
AI: [connect] Connected to STM32F103C8

User: What's in the RTT logs?
AI: [read_rtt] STM32F103C8T6 LED Control ===\r\nCommands: freq, mode, status...

User: Make the LED blink faster
AI: [write_rtt, data="freq 200"] Done! LED now blinks every 200ms

User: Turn the LED on
AI: [write_rtt, data="mode on"] LED is now on

User: Flash new firmware
AI: [flash_firmware, firmware_path="path/to/firmware.hex"] Flash complete!

Supported Hardware

  • Debugger: SEGGER J-Link (V7-V10)

  • MCU: STM32F1xx, STM32F4xx, nRF52xxx, etc.

  • Interface: SWD, JTAG

Test with MCP Inspector

npx @modelcontextprotocol/inspector -- python -m src.server

Related MCP server: MCP Server for Segger RTT via J-Link

中文

封装 J-Link RTT Viewer 的 MCP 服务器,使 AI 助手能通过自然语言控制 STM32 开发板。

快速开始(3 步)

# 1. 克隆并安装
git clone https://github.com/MisakaMikoto128/J-Link-RTT-Viewer-MCP.git
cd J-Link-RTT-Viewer-MCP
python -m venv .venv && .venv\Scripts\activate  # Windows
pip install -r requirements.txt

# 2. 配置 Claude Desktop
# 添加到 %APPDATA%\Claude\claude_desktop_config.json:
# { "mcpServers": { "jlink-rtt": { "command": "python", "args": ["-m", "src.server"], "cwd": "C:\\path\\to\\J-Link-RTT-Viewer-MCP" } } }

# 3. 重启 Claude Desktop,用自然语言对话!

工具参考

工具

参数

说明

connect

target, interface="SWD", speed=4000

连接 MCU。示例: STM32F103C8

disconnect

(无)

断开 J-Link

read_rtt

channels=[0], max_size=4096

读取 MCU 的 RTT 日志

write_rtt

data, channel=0

通过 RTT 发送命令到 MCU

reset

mode="normal"

重置 MCU。模式: normal, auto_reconnect, halt

flash_firmware

firmware_path

烧录 .hex 或 .bin 文件

get_device_info

(无)

获取设备详细信息

read_memory

address, size

读取 MCU 内存

write_memory

address, data

写入 MCU 内存

start_log_recording

log_dir="logs"

录制 RTT 输出到文件

stop_log_recording

(无)

停止录制

set_rtt_channel

channel

设置默认 RTT 通道 (0-15)

常用命令(用于 write_rtt)

freq 200      - 设置 LED 闪烁间隔为 200ms
freq 1000     - 设置 LED 闪烁间隔为 1s
mode on       - 打开 LED
mode off      - 关闭 LED
mode blink    - 设置 LED 闪烁模式
status        - 获取当前设置
ping          - 测试连接(返回 "pong")
reset         - 软件重置 MCU

示例:控制 LED

用户: 连接到我的 STM32F103C8 开发板
AI: [connect] 已连接到 STM32F103C8

用户: RTT 日志里有什么?
AI: [read_rtt] STM32F103C8T6 LED Control ===\r\nCommands: freq, mode, status...

用户: 让 LED 闪快一点
AI: [write_rtt, data="freq 200"] 完成!LED 现在每 200ms 闪烁一次

用户: 打开 LED
AI: [write_rtt, data="mode on"] LED 已打开

用户: 烧录新固件
AI: [flash_firmware, firmware_path="path/to/firmware.hex"] 烧录完成!

支持的硬件

  • 调试器: SEGGER J-Link (V7-V10)

  • MCU: STM32F1xx, STM32F4xx, nRF52xxx 等

  • 接口: SWD, JTAG

使用 MCP Inspector 测试

npx @modelcontextprotocol/inspector -- python -m src.server

Available Tools

12 tools
connectA

连接到 J-Link 调试器和目标 MCU

Args: target: 目标设备型号 (如 STM32F103C8, STM32F407VG, nRF52840) interface: 调试接口 (SWD 或 JTAG),默认 SWD speed: 连接速度 (kHz),默认 4000 channel: RTT 通道号,默认 0 retry_attempts: 重试次数,默认 3

Returns: 连接状态和设备信息的 JSON 字符串

Inputs: target (required), interface, speed, channel, +1 more. Returns: result

disconnectA

断开 J-Link 连接

安全地断开与 J-Link 调试器的连接,清理所有资源。

Returns: 断开状态的 JSON 字符串

Inputs: no named parameters. Returns: result

flash_firmwareA

烧录固件到 MCU

将固件文件烧录到连接的目标 MCU。

Args: firmware_path: 固件文件路径 (.hex, .bin)

Returns: 烧录结果的 JSON 字符串

Inputs: firmware_path (required). Returns: result

get_device_infoA

获取当前连接设备的信息

返回 J-Link 调试器和目标 MCU 的详细信息。

Returns: 设备信息的 JSON 字符串

Inputs: no named parameters. Returns: result

read_memoryA

读取 MCU 内存

从目标 MCU 的指定地址读取内存数据。

Args: address: 起始地址 (如 0x08000000) size: 读取字节数 (1-1048576)

Returns: 内存数据的 JSON 字符串(十六进制格式)

Inputs: address (required), size (required). Returns: result

read_rttB

读取 RTT 日志数据

从目标 MCU 读取 RTT (Real-Time Transfer) 日志数据。 默认读取所有通道 (0-15),返回结构化的日志数据。

Args: channels: 要读取的通道列表,None 表示所有通道 (默认) max_size: 最大读取字节数,默认 4096

Returns: RTT 数据的 JSON 字符串,包含时间戳、通道、内容和元数据

Inputs: channels, max_size. Returns: result

resetA

重置目标 MCU

重置连接的目标 MCU。支持多种重置模式。

Args: mode: 重置模式 - "normal": 标准重置,保留连接会话 (默认) - "auto_reconnect": 重置后自动断开重连 - "halt": 重置后暂停 CPU(停在复位状态) wait_time: 重置后等待时间(秒),默认 0.3

Returns: 重置结果的 JSON 字符串

Inputs: mode, wait_time. Returns: result

set_rtt_channelB

设置默认 RTT 通道

设置后续 RTT 操作使用的默认通道。

Args: channel: 通道号 (0-15)

Returns: 设置结果的 JSON 字符串

Inputs: channel (required). Returns: result

start_log_recordingC

开始日志记录

开始将 RTT 数据记录到文件。

Args: log_dir: 日志目录,默认 "logs"

Returns: 记录状态的 JSON 字符串

Inputs: log_dir. Returns: result

stop_log_recordingB

停止日志记录

停止将 RTT 数据记录到文件。

Returns: 停止状态的 JSON 字符串

Inputs: no named parameters. Returns: result

write_memoryB

写入 MCU 内存

向目标 MCU 的指定地址写入数据。

Args: address: 起始地址 (如 0x08000000) data: 要写入的数据(十六进制字符串或普通字符串) is_hex: 是否为十六进制数据,默认 True

Returns: 写入结果的 JSON 字符串

Inputs: address (required), data (required), is_hex. Returns: result

write_rttA

向 RTT 通道写入数据

向目标 MCU 的 RTT 通道发送数据。

Args: data: 要写入的数据 channel: 通道号,None 使用默认通道 is_hex: 是否为十六进制数据,默认 False

Returns: 写入结果的 JSON 字符串

Inputs: data (required), channel, is_hex. Returns: result

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 12 tools

    Disambiguation5/5

    Each tool targets a distinct operation (connect, disconnect, flash, memory read/write, RTT read/write, logging, reset, device info) with no overlapping purposes.

    Naming Consistency5/5

    All tools use consistent verb_noun snake_case naming (e.g., read_memory, write_rtt) with no deviations or mixed conventions.

    Tool Count5/5

    12 tools is well-scoped for a J-Link/RTT debugger, covering essential operations without being excessive or minimal.

    Completeness4/5

    Core operations (connect, flash, memory R/W, RTT R/W, logging, reset) are covered, but minor gaps like erase or verify exist.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Enables AI assistants like Claude to directly debug microcontrollers via JLink, supporting breakpoints, single-step, memory/register access, variable inspection, RTT logging, and firmware flashing.
      25
      7
      MIT
    • A
      license
      B
      quality
      B
      maintenance
      Enables AI assistants to debug embedded devices via SEGGER J-Link probes, including reading memory, flashing firmware, streaming RTT logs, and diagnosing crashes.
      48
      181 npm
      43
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Enables AI assistants to flash firmware, program memory, modify option bytes, erase chips, reset boards, and capture SWO printf traces for STM32 microcontrollers via STM32CubeCLT.
      12
      MIT