MCP Server for Segger RTT via J-Link

MCP Server for Segger RTT via J-Link

Enables LLMs to interact with embedded devices by reading and writing Segger RTT data through a J-Link debugger.

Category
访问服务器

README

MCP Server for Segger RTT via J-Link

An MCP server that provides access to Segger RTT (Real Time Transfer) through a J-Link debugger. This allows an LLM (like Claude) to interact with embedded devices by reading and writing RTT data.

Features

  • RTT Read: Read output from embedded devices through RTT up-buffer
  • RTT Write: Send commands to embedded devices through RTT down-buffer
  • J-Link Management: Connect/disconnect J-Link debuggers, list available devices
  • Real-time Display: RTT data is continuously printed to terminal while monitoring
  • Ring Buffer: Recent RTT data is accumulated for reading by the LLM

Prerequisites

  • Python 3.10+
  • SEGGER J-Link Software installed (provides JLinkARM.dll/libjlinkarm.so)
  • A J-Link compatible debugger
  • Target device running SEGGER RTT

Installation

# Clone or navigate to this directory
cd mcp-rtt-server

# Install dependencies
pip install -e .

Usage

Step 1: 安装

cd mcp-rtt-server
pip install -e .

Step 2: 启动 MCP Inspector(调试/测试用)

终端 A — 启动 MCP 服务器:

npx @modelcontextprotocol/inspector python -m mcp_rtt_server.server

启动后会输出一个本地网址(如 http://localhost:6274/?...),在浏览器打开。

终端 B — 实时查看 RTT 数据:

# PowerShell
Get-Content .\rtt_output.log -Wait
# Git Bash / WSL
tail -f ./rtt_output.log

Step 3: 使用工具

在浏览器 Inspector 中按顺序调用:

  1. jlink_connect — 连接 J-Link 和目标设备,启动 RTT 监控
  2. rtt_read — 读取设备发送的 RTT 数据
  3. rtt_write — 向设备发送数据(需固件支持接收)
  4. jlink_status — 查看连接状态和缓冲区信息
  5. jlink_disconnect — 断开连接

Claude Code 集成

在项目 .claude/settings.json 中添加:

{
  "mcpServers": {
    "rtt": {
      "command": "python",
      "args": ["-m", "mcp_rtt_server.server"],
      "cwd": "."
    }
  }
}

注意:将 python 替换为你的 Python 解释器实际路径(如 C:\Python313\python.exe)。

重启 Claude Code 会话后,可直接用自然语言与设备交互,例如:

  • "连接 RTT 读取设备数据"
  • "查看设备状态"

Claude Desktop 集成

编辑 %APPDATA%\Claude\claude_desktop_config.json:

{
  "mcpServers": {
    "rtt": {
      "command": "python",
      "args": ["-m", "mcp_rtt_server.server"],
      "cwd": "."
    }
  }
}

注意:cwd 需要改为本项目的实际绝对路径,因为 Claude Desktop 不会自动定位到项目目录。

Available Tools

Tool Description
jlink_connect Connect to J-Link and start RTT monitoring
jlink_disconnect Disconnect from J-Link
jlink_status Get connection status and buffer info
rtt_list_devices List available J-Link devices
rtt_read Read accumulated RTT data
rtt_write Write data to RTT down-buffer
rtt_clear Clear the RTT ring buffer

Example Session

> jlink_connect(device="HC32L19x")
Connected to J-Link device 'HC32L19x' (serial: 12345678, speed: 4000 kHz)
RTT monitoring started on channel 0

> rtt_read()
[OSAL] HC32L19x OSAL starting...
[RTT] SEGGER RTT initialized
[OSAL] Registering tasks...
[OSAL] Starting scheduler...

> rtt_write(channel=0, data="status\r\n")
Wrote 7 bytes to RTT channel 0

Architecture

┌─────────────────┐     stdio (JSON-RPC)     ┌─────────────────┐
│   Claude /      │ ◄──────────────────────►  │  MCP RTT Server │
│   MCP Client    │                          │    (Python)     │
└─────────────────┘                          └────────┬────────┘
                                                      │
                                             pylink   │
                                                      ▼
                                            ┌─────────────────┐
                                            │  JLinkARM.dll   │
                                            └────────┬────────┘
                                                      │ USB
                                                      ▼
                                            ┌─────────────────┐
                                            │   J-Link Probe  │
                                            └────────┬────────┘
                                                      │ SWD/JTAG
                                                      ▼
                                            ┌─────────────────┐
                                            │  Target Device  │
                                            │  (HC32L19x)     │
                                            │  SEGGER RTT     │
                                            └─────────────────┘

Environment Variables

Variable Default Description
JLINK_SERIAL (none) J-Link serial number
JLINK_DEVICE HC32L19x Target device name
JLINK_SPEED 4000 SWD speed in kHz
RTT_CHANNEL 0 Default RTT channel
RTT_RING_BUFFER_SIZE 100 Ring buffer entries
RTT_POLL_INTERVAL_MS 10 Poll interval in ms

Troubleshooting

"J-Link not found"

  • Make sure J-Link software is installed
  • Check that J-Link is connected via USB
  • Try running as administrator/root

"Device not supported"

  • Check if the device name is correct
  • Try using rtt_list_devices to see available probes
  • Verify the target is connected and powered

"RTT not initialized"

  • Make sure the target firmware calls SEGGER_RTT_Init()
  • Check that RTT buffers are configured in SEGGER_RTT_Conf.h

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选