Skip to main content
Glama

t32-mcp

An MCP server for Lauterbach TRACE32, enabling AI agents to inspect embedded targets, run PRACTICE scripts, and control execution.

面向 Windows 的 MCP 服务端。Agent 可以启动或连接 Lauterbach TRACE32 PowerView,执行调试命令、运行 PRACTICE 脚本并读取窗口输出。

能解决什么

  • 命令batch和脚本可返回失败位置、PowerView 的诊断,以及从本机手册查到的语法提示。

  • view 通过 PowerView 的打印接口导出窗口。超过回包长度时会给出本地结果路径。

  • 长操作返回操作编号,供后续查询。同步调用超过期限时,服务可终止自己启动的 PowerView 并报告会话状态。

Related MCP server: trace32-mcp

安装

下载源码,在项目目录运行,Python版本要求为3.12或更高。

python --version
python -m venv .venv
.\.venv\Scripts\python.exe -m pip install -e .
.\.venv\Scripts\python.exe -m t32_mcp --help

使用

在 MCP 客户端中添加 t32 的 stdio 服务。如果客户端使用 mcpServers,示例如下。见配置模板。

{
  "mcpServers": {
    "t32": {
      "command": "C:/path/to/t32-mcp/.venv/Scripts/python.exe",
      "args": ["-m", "t32_mcp", "--sys", "C:/T32"]
    }
  }
}

command 指向.venv安装的 python.exe。路径可在根目录执行指令获得。

(Resolve-Path .\.venv\Scripts\python.exe).Path.Replace('\', '/')

C:/T32 改为实际的 TRACE32 安装目录,无参数默认值为 C:\T32,可由T32SYS环境变量覆盖。

工具

工具

用途

session_open

启动 PowerView,或Attach到当前已运行实例

session_status

版本、探头、License、目标状态、各目录路径

session_close

关闭,或把 PowerView 留给用户

command

执行 PRACTICE 命令

evaluate

批量求值 PRACTICE 函数

script

运行 .cmm 脚本

view

读 T32 窗口

run

运行控制,等到目标停下

manual

查手册:给名字返回语法,给几个词返回候选,不需要会话

operation_get

继续等待未结束的操作

operation_cancel

取消等待或中止操作

三种连接

  • usb:在探头上启动一台 PowerView,窗口可见,你可以旁观。

  • sim:启动指令集模拟器,有空闲探头时用探头授权。

  • attach:连上你已经开着的 PowerView,默认只读。

Attach时如果 PowerView 没开 API,在命令行输入:

SETUP.API.RCL.Enable /PRotocol TCP /Port AUTO /RemoteHost DENY

不用重启,也不影响已经连着的目标。端口由服务端自己查找。

运行记录

从源码安装时,会话文件放在本仓库的 tmp/sessions/。安装 wheel 时,目录在虚拟环境的 t32_mcp/tmp/sessions/ 下。MCP 和 PowerView 都需要能读写这个位置。每个会话一个子目录,保留最近 20 个:

  • journal.jsonl 记录操作开始、参数和已取得的结果。进程意外退出时,最后一次操作可能只有开始记录。

  • view-<op>.txt 保存 PowerView 导出的窗口内容。

  • script-<op>.cmm、script-<op>.log:脚本和它的输出。

测试

.venv\Scripts\python -m pip install "pytest>=8"
.venv\Scripts\python -m pytest                       # 默认离线,包含模拟的板级与 Trace 场景
.venv\Scripts\python -m pytest -m hw                 # 运行需要 PowerView 和探头的集成测试
.venv\Scripts\python tools\mutation_check.py          # 离线变异检查
.venv\Scripts\python tools\mutation_check.py --live   # 也运行需要 PowerView 的变异检查
  • 板级与 Trace 场景在 RAPI 边界提供模拟响应,用实际的服务代码验证运行控制、错误传播和结果交付。默认测试可在没有探头或实验固件的环境中运行。

  • hw 集成测试用于配有一台空闲 PowerDebug 的独占测试台。它们会启动真实 PowerView,部分用例会终止测试进程并验证探头恢复。

  • 检查特定版本的窗口导出时,使用自己的匹配 ELF 和 Trace 归档。运行 python tools/window_sweep.py --help 可查看参数。

许可证

本项目采用 MIT 许可证。运行实机调试需要另行安装并授权 Lauterbach TRACE32。

Available Tools

11 tools
commandA
Destructive

Run PRACTICE commands in order. Stops at the first failure and reports what ran.

OK means TRACE32 accepted the command, so read settings back with evaluate. Use script for DO, session_close for QUIT, and run for Go when you need to wait for the target to stop. Commands can execute host programs through OS.Command. Wait for this reply before calling run: calls sent together run even if the setup failed.

Inputs: lines (required), wait_s, deadline_s, stop_on_error.

evaluateA
Read-only

Evaluate PRACTICE functions, for example Register(PC), Data.Long(D:0x20000000), Var.VALUE(counter), Trace.RECORDS(). Each expression succeeds or fails on its own, so pass everything you need in one call. An expression that calls a target function runs it on the target.

Inputs: expressions (required).

manualA
Read-only

Look something up in the TRACE32 manuals installed here. Give a name for its syntax, options and subcommands, or a few English words for candidates: Break.Set, Data.Long, PERF, flash programming. Add the target when a page differs by target: SYStem.MemAccess cortexm. An RTOS name alone lists its commands and setup: freertos. Needs no session. The manuals cover every target, so a name found here may not exist on yours: PRACTICE.CoMmanD.AVAILable() and PRACTICE.FUNCtion.AVAILable() tell.

Inputs: query (required).

operation_cancelA

Cancel an operation. A queued one is dropped, a script is stopped, a run stops waiting and leaves the target running. A blocked command can only be ended with kill=true, which kills PowerView and loses target state.

Inputs: operation (required), kill.

operation_getA
Read-only

Wait for an operation that replied Running, and return its final reply. Finished operations return the same reply again.

Inputs: operation (required), wait_s.

runA

Control the target: go, step, step_over, go_up, go_return, break. go waits until the target stops, also when it is already running. break stops the target now, wherever it is, so to wait for a breakpoint use go, not break. With until, go runs to that address and the reply says whether it got there. Reaching the deadline leaves the target running: nothing stops it for you.

Inputs: action (required), until, wait_s, deadline_s.

scriptA
Destructive

Run a PRACTICE script from a file or from text and wait for it to end. Output from PRINT is returned. If it stops on an error the reply gives the failing command, and commands before it have already taken effect. A script that opens a dialog cannot continue, because nobody can click it.

Inputs: args, path, text, wait_s, +1 more.

session_closeA

End the session. A PowerView started here quits, unless leave_running is true, which hands it to the user. An attached PowerView is only disconnected.

Inputs: leave_running.

session_openA

Start or join a TRACE32 PowerView. Connects only: it does not reset, download or run.

connection:

  • usb: start a PowerView on the probe.

  • sim: start the instruction set simulator, licensed by the probe when one is free.

  • attach: join a PowerView the user already opened. Read-only unless access="control". Open it read-only and look first. Stopping the target or writing to it changes what the user is debugging, so ask the user before asking for control.

Installed targets: none found. TRACE32 directory: C:\T32.

Inputs: port, access, serial, target, +2 more.

session_statusA
Read-only

Report the session: PowerView version, probe, license, CPU, target state, script depth, and the demo, manual and session directories. Works while an operation is blocked.

Inputs: no named parameters.

viewA
Read-only

Read a TRACE32 window as text, for example Register.view, Frame.view /Locals /Caller, Data.dump D:0x20000000++0xFF, Break.List, Trace.STATistic.Func, TASK.List.tasks, PER.view. Output past max_chars stays in a file, and its path is in the reply.

Use full command names. Only display windows are accepted; for anything else use command with PRinTer.FILE and WinPrint.

Give Trace.List a record range such as Trace.List (-1000.)--(-1.): a full list can be gigabytes. Reading PER windows can touch registers that have read side effects.

Inputs: window (required), format, max_chars, deadline_s.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.9/5.0

    Scored across 11 tools

    Disambiguation4/5

    The tools have mostly distinct purposes: session lifecycle, command execution, expression evaluation, script running, window reading, target control, manual lookup, and async operation management. There is some conceptual overlap between command, script, evaluate, and run since all interact with the debugger, but the descriptions draw clear boundaries (e.g. use script for DO, read settings back with evaluate, use go not break to wait). An agent can reliably pick the right tool.

    Naming Consistency3/5

    There are recognizable prefix groups (session_status/session_open/session_close, operation_get/operation_cancel), but the remaining tools are bare verbs or nouns (command, evaluate, script, view, run, manual) with no consistent verb_noun pattern. The conventions are mixed, though all names are readable and unambiguous in context.

    Tool Count5/5

    Eleven tools is well within the ideal 3-15 range and each tool earns its place: session management, core execution primitives, manual lookup, and async operation handling. The surface is neither bloated nor thin for a debugger-control server.

    Completeness4/5

    The surface covers the full session lifecycle (open/status/close), command and script execution, expression evaluation, window reading, target control (go/step/break), manual lookup, and async operation get/cancel. Minor gaps exist in dedicated breakpoint, memory-write, and register tools, but these are largely reachable through command, evaluate, and view, so no major dead ends remain.

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      A
      quality
      D
      maintenance
      Enables AI agents to debug embedded systems by providing a comprehensive interface for GDB operations across multiple architectures like ARM and x86. It supports remote debugging via gdbserver or QEMU, allowing for detailed inspection of memory, registers, stack frames, and variables.
      31
      -
    • A
      license
      A
      quality
      C
      maintenance
      MCP server bridging Lauterbach TRACE32 debuggers to AI agents for autonomous debugging, providing 47 tools for execution control, breakpoints, memory, registers, variables, and symbol inspection.
      10
      100
      14
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents to control TriCore/AURIX debug sessions, including workspace loading, target connection, flashing, run control, breakpoints, and reading variables, registers, memory, and call stacks via the UDE Object Model.
      1
      MIT