Mdkdebug
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., "@MdkdebugRead SData_UA and show the call stack"
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.
Mdkdebug —— 可被 AI 工具调用的 Keil uVision 调试服务
你只要把线接好,剩下的交给 AI。
通过 UVSOCK/TCP 协议连接 Keil uVision 调试器,以 MCP(Model Context Protocol)Server 形式,向 Claude、灵犀等 AI 工具暴露嵌入式在线调试能力:读变量 / 表达式、读写目标内存、 运行控制(运行 / 暂停 / 复位 / 单步)、断点管理,以及自动进入 / 退出调试模式。
适用于 Cortex-M 等 ARM 目标板的在线调试。协议层参考自 KeilAssistant 的 UVSOCK 实现。
先看一个真板实测的结果

上面这张图不是示意图,是 STM32F401 上真跑一个 RTOS 的实测回放:5.36 s 连续录制、
56,355 条事件、5,386 次上下文切换、24,136 次中断进出、0 条丢失,编码后只有
3.67 字节/事件(相对 12 字节记录 3.27× 压缩),时间戳取目标侧 DWT_CYCCNT(11.9 ns/拍),
所以微秒级的切片也分辨得出来。
它怎么做到「只接 SWD 两线还能连续不丢」——两件事:
目标侧先压缩。每次切换 / 中断 / 阻塞编成 token:命中字典只写 1 字节槽号 + 变长时间差, 新键才写全量四元组
(type, kind, id, arg);槽号是四元组的直接映射哈希。背压而不是覆盖。字节写进 8 KB RAM 环,主机用
trace_swd_read增量搬走并回报drained;环满时丢新事件并计数(lost_events),绝不覆盖没搬走的区域。 于是任何时刻停下,已经录下的那一段都是完整的;只要平均搬运速度跟得上,就一条都不丢。
trace_instrument(backend="swd", swd_bytes=8192)
→ trace_swd_status(...) # 环容量 / 未读字节 / lost / 压缩比
→ trace_swd_next(...) # 还能录多久 / 该多久搬一次(算出来的节拍,不用试)
→ trace_swd_read(..., out_file="trace.json") # 搬走未读的那一段并解成事件
→ (循环:跑一段 → 搬一段;停机搬走不会丢任何东西)前提说清楚:这条路要先插桩(编译期改代码),事件率约 10k/s 时 8 KB 环只够 0.22 s,
搬运间隔必须短于这个窗口;也别指望它替代 SWO/ETM——它解决的是「板子只焊了 SWD 两线」
这个场景。SWO/RTT/ETM 怎么选,见 trace_guide。
可交互版本(滚轮缩放 / 拖动平移 / 单击定位 / 回放,含任务泳道、上下文切换带、
PendSV/SysTick 中断活动与阻塞事件通道):
docs/demo/trace-replay-swd.html。
gitee 只能预览 HTML 源码,把仓库 clone 下来双击这个文件(无需服务器、无外部依赖)
就能看到上面截图里的交互页面。
页面刻意把「单核、同一时刻只有一个任务在跑」画在脸上:每个任务的运行条同一像素列里只会亮一条,
不把单核画成并行的泳道。详见 docs/demo/README.md。
Related MCP server: dbgprobe-mcp-server
功能特性
功能特性
MCP Server:以标准
stdio或streamable HTTP传输方式暴露调试能力,AI 工具可直接调用;表达式 / 变量读取:
calc_expression读全局变量、寄存器、指针解引用(如SData_UA、*(uint32_t*)0x20000000);内存读写:任意地址读 / 写,超过单次上限(16 KB)自动分块,规避 Keil 协议长度限制;
运行控制:全速运行、暂停、复位、单步(
into/over/out/instruction)、run_to_line运行到指定行;单步/运行到行后自动附带当前停靠位置(文件:行号)+ 源码上下文 + 调用栈,让 AI 单步进函数 / 出函数后立即看到效果,不必再额外查询;像人一样看代码位置:
get_current_location读取当前 PC,基于.axf调试符号定位到源文件:行号,返回该行附近源码上下文与完整调用栈回溯(PC/LR/SP + 栈启发式扫描,多级调用链),让 AI 像人一样知道程序停在哪、是谁调进来的;并检测源码是否比.axf新(漂移时提示先重编译);局部变量读取:
read_locals基于 DWARF 解析当前 PC 所在函数的参数与局部变量,用calc_expression在当前上下文求值,让 AI 看到当前函数的局部状态(而非仅全局变量);断点命中与定时运行:程序停在
set_breakpoint所设断点时返回命中反馈(含命中次数);run_timeout全速运行 N 毫秒后自动暂停并返回停靠位置,便于验证时序;断点带位置:
set_breakpoint自动反查断点对应的文件:行号,list_breakpoints返回断点列表含位置信息;断点管理:设 / 删 / 列断点,基于 Keil 命令窗口命令(
BS/BK/BL);断点列表解析自窗口BL的真实输出(含代码断点与数据观察点、Keil 断点编号、命中计数),清除时优先按 Keil 断点编号执行(数据观察点按地址会报error 72清不掉),并提供hard=true一键清空 Keil 侧全部断点;数据断点(watchpoint):
set_watchpoint在变量 / 地址处设 读 / 写 / 读写 访问断点(KeilBS READ/WRITE/READWRITE),命中即暂停,用于观察某内存被访问的时机;状态快照:
snapshot一次性返回当前位置(文件行 + PC)+ 源码上下文 + 完整调用栈 + 局部变量 + 指定全局变量,让 AI 一眼看清程序卡在哪、处于什么状态;变量组:
watch批量读取一组表达式的当前值,便于固定观察多路信号;结构体字段概览:
read_struct基于 DWARF 解析结构体的字段布局(类型 / 偏移 / 大小),并用基址 + 偏移读取各字段运行时值,让 AI 看清一个结构体的完整内容;寄存器组 + AAPCS:
read_registers批量读取 R0-R12/SP/LR/PC/xPSR 并解读 AAPCS 调用约定(R0-R3 入参、R0 返回值、LR 返回地址),排查函数参数传错 / 返回值不对 / 寄存器被踩;反汇编:
disassemble用 capstone 反汇编目标代码(支持0x地址/ 符号名 / 文件:行 / 缺省 PC),排查死循环、跑飞、启动流程与优化后行为;内存分析套件:内存地图(
query_memory_map)+ 字节搜索(search_mem)+ 批量填充(fill_mem)+ 外设写(write_peripheral)+ 状态 diff(snapshot_diff)+ 函数耗时(profile_function)+ 异常自动抓取(wait_fault),覆盖从定位地址、找魔数到观察运行变化、复现崩溃的全链路;工程产物解析:
parse_build_errors把编译错误/警告解析为结构化列表(兼容 AC5/AC6 两种格式),parse_map解析 .map 的 FLASH/RAM 占用、符号地址与栈使用;批量命令:
read_mem_multi一次读取多个地址内存、batch一次提交多条只读命令(read_mem/read_variable/calc_expression/get_status/read_registers)聚合返回,显著减少 AI 往返;多 target / 工程配置:
project_targets枚举工程全部 target + 当前 target + 调试 target,set_debug_target切换调试目标,read_project_config解析各 target 的编译器(AC5/AC6)、优化级别(-O0~-Otime)、编译宏 Define 与包含路径——排查“不同 target 行为不同”时对比宏/优化差异;采样剖析:
profile_sampling基于 PC 统计采样定位热点函数(按 .axf 符号表归函数算占比),找“哪个函数占 CPU 最多”的性能瓶颈;profile_function/dwt做函数级精确计时;目标器件信息:
target_info实时读 DBGMCU->IDCODE 判芯片 DEV_ID/REV_ID + SCB->CPUID 判内核类型,返回标称 Flash/RAM 容量与内存布局,排查资源吃紧/选错型号/容量不符;环境自检 + 工作流引导:
mdk_guide一键自检 Keil/UVSOCK/UV4/.axf/源码漂移/调试态/RTOS 类型,并返回推荐调试工作流与各场景应调用的工具——AI 落地的第一个工具,避免盲目试错;一键诊断:
diagnose聚合寄存器组 + PC 反汇编 + 源码上下文 + 调用栈 + 局部变量 + 指定全局变量,AI 接到 bug 报告后一次调用即可看清现场;符号检索:
find_symbol从 .axf ELF 符号表模糊检索函数/全局变量(地址+类型),AI 读任意符号不再靠猜名字;写寄存器 / 改 PC:
set_register写 CPU 寄存器并读回验证,可修正现场、改返回值、改 PC 跳转执行;性能分析:
dwt读 DWT 周期计数器(自动使能),配合两次采样测代码段执行时间;HardFault / 异常定位:
fault_report读 SCB 寄存器判异常类型与原因,并从异常栈帧恢复现场(PC/LR/R0-R3),排查死机/跑飞;复位循环识别:
watch_reset按固定间隔读DHCSR.S_RESET_ST(读即清),把「启动即死 / 喂狗超时 / 反复复位」这类没有单次停靠可抓的故障识别出来——间隔稳定即判复位循环,快过采样间隔时如实说「测不出周期」而不是编一个;由于该位读即清、且 Keil 在目标复位后会重新同步并自读一次 DHCSR,单靠它会漏报,所以还可传flags_addr指定芯片的复位标志寄存器(如 STM32 的RCC_CSR=0x40023874)做交叉验证:窗口前后各读一次,报出被置起的位置,位含义照手册读、本工具不解释;条件断点:
set_conditional_breakpoint设 C 表达式条件/命中次数断点,只在特定条件或第 N 次命中才停;外设寄存器一键读(SFR):
read_peripheral内置 STM32F4 常用外设寄存器表(RCC/GPIO/USART/SPI/I2C/TIM/ADC/PWR/FLASH/SysTick/SCB/NVIC/DWT/EXTI/SYSCFG),一键读指定外设全部寄存器当前值并解析关键位域(时钟使能/波特率/GPIO 模式/定时器计数),list_peripherals列出可用外设——排查时钟没使能、GPIO 模式配置错、串口波特率不对等场景,不依赖外部 SVD 文件、离线可用;ITM / Debug(printf) Viewer trace:
itm_trace检查 Trace 配置(DEMCR.TRCENA / ITM->TCR / ITM->TER)是否就绪,并经 UVSOCK 串口通道拉取 Debug(printf) Viewer 收到的 ITM 打印文本,再交给traceproto做结构化解码——按 ITM 报文给出 port / header /data_text,overflow与半包(leftover_bytes)如实计数,连续拉取只喂新增字节,不把丢过包的时间线当完整证据;printf 走 SWO 输出时无需占用 UART,排查实时日志/运行状态;真实 ITM 输出需 Keil 已配置 Trace(Core Clock + Stimulus Port0)且调试器(ST-Link/J-Link)SWO 引脚已连接;自动进出调试模式:
enter_debug/exit_debug,支持 AI 驱动"进入 → 设断点 → 运行到断点 → 读变量 → 退出"完整闭环;编译 / 烧录闭环:基于 Keil 官方
UV4.exe命令行,提供build_project(编译)、rebuild_project(重编译)、flash_download(烧录)、build_and_flash(编译成功后自动烧录),支持 AI 自主"改代码 → 编译 → 烧录 → 上板"全流程闭环;后台静默编译:编译 / 烧录以隐藏窗口方式启动 UV4,不会闪现新的 Keil 界面,用户已打开的实例不受打扰;
AI 管理 Keil 开关(闭环):
launch_uvision拉起 Keil 打开工程(已有同工程窗口则复用,不新开),close_uvision关闭 Keil(默认优雅关闭、残留自动强制),Keil 的开启/关闭全部由 AI 闭环管理,无需手动操作;Keil 窗口不累积:UV4.exe 不是单实例程序(真机实测同工程可并存 6 个窗口),因此
launch_uvision、编译后调试通道自愈都先查已有实例、复用而不新开;默认single=true时已经开着别的工程就拒绝新开(keil-multiple-instances,摆出既有实例与下一步),同工程则强制复用(reuse_forced)——确需多窗口才传single=false。list_uvision_instances可随时清点,close_uvision(keep="oldest")把多余的收敛成一个(持 UVSOCK 4823 的是最早那个实例),保证「只开一个窗口调试」;先改文件、后开 Keil:「先开 Keil 再改源码/工程」会让 Keil 弹「文件已被外部修改」的模态框,并把 UVSOCK 通道一起堵死(表现成「调试通道假死」)。因此
launch_uvision成功即返回order_hint,uvprojx_edit在 Keil 开着同一工程时直接拒绝(project-open-in-keil,force=true才放行);规避旧窗口调试旧代码:
flash_debug自动按「关闭所有 Keil → 让新固件上板 → 重新打开本工程 → 进入调试」顺序执行,避免因残留旧工程窗口导致调试到旧代码(即使 AI 不记得先关旧窗口也能保证加载的是新固件符号);上板方式自动选路:工程勾选了 Keil 的Update Target before Debugging(.uvprojx的UpdateFlashBeforeDebugging=1,Keil 默认)时,进入调试会由 Keil 自己把最新程序下载进 Flash,于是只编译、不再显式烧录(省掉一次全片擦写与UV4 -f往返),返回flash_plan=debug_download;未勾选时才退回显式烧录(flash_plan=explicit_flash);编译烧录输出集中返回:每次编译/烧录的完整日志(含警告/错误)经
-o捕获并由 AI 完整返回,在对话中即可查看,无需盯 Keil 窗口;UV4 自动探测:优先显式
--uv4-path,其次枚举本机全部盘符 × 常见安装子目录,最后查 Windows 注册表——32 / 64 两个视图都查(Keil 是 32 位程序,只读默认视图在 64 位系统上会一无所获),Path值兼容「安装根」与「工具根」两种写法;连接缓存:常驻服务内共享一条 TCP 连接,空闲自动断开、下次调用自动重连;
并发调用可安全并行:所有 UVSOCK 命令经统一闸门串行化——进程内 RLock(同进程多线程)+ 跨进程锁文件(多个 mdkdebug 实例共用同一调试通道时也只允许一个发命令),超时降级并如实记入遥测;
get_status/keil_health会回报其他 mdkdebug 实例(PID + 心跳年龄)并在有竞争时给出concurrency_warning,把「写入被静默吞掉」从猜测变成可见证据;详见 docs/PITFALLS.md;第二条调试通道:Keil 官方命令行批处理(
UV4 -d):batch_debug_script把一串命令写成初始化文件挂到.uvoptx的<tIfile>,以-j0无人值守执行,按日志逐条判定执行结果。为什么要它:不依赖 UVSOCK 交互式会话,进程隔离、天然可重放,适合「跑一段固定脚本 → 拿结果」的冒烟/回归;UVSOCK 不可用时也是降级通道。已处理三个真机硬坑:初始化文件与 trace 落到 ASCII 临时目录、.uvoptx前置备份 + finally 字节级还原、<tIfile>唯一性先数再换;静态 lint 会拦下真机会挂死的写法(Go main/DISPLAY/SAVE/Step)并给正确写法;Modbus 主站(规范 RTU/ASCII + 非规范裸帧):
modbus_read/modbus_write/modbus_scan/modbus_sniff/modbus_raw/modbus_decode/modbus_session。为什么不能用串口日志监听做:serialmon是按行切分的日志通道,而 Modbus 是二进制帧(含\x00、没有换行、多从站应答会连成一坨),按行切必然切坏——所以 Modbus 走独立的二进制收发路径,按帧间静默 t3.5(>19200 波特固定 1.75ms)切帧。协议侧:CRC16 / LRC 自己算、功能码 01/02/03/04/05/06/0F/10、异常帧译中文(0x02→ 地址越界)、规范上限(读寄存器 ≤125 / 读线圈 ≤2000 / 写寄存器 ≤123)在发出去之前就拦。关键取舍:字节回来了 ≠ 帧是对的——transact的ok只表示「有没有字节返回」,另给parsed_ok;半帧 / CRC 不过时modbus_read判失败,且与「一个字节都没收到」分开报(modbus-bad-crcvsmodbus-timeout-no-response,这两类问题的排查方向完全不同),而modbus_raw保持传输层口径——它存在的意义就是看非规范帧。端口是独占资源:串口日志监听正占着同口时明确报错、不抢口(抢来的「成功」会收到错数据);同口同参数复用不重开,避免 DTR 抖动把目标板复位;帧方向自动识别——旁听/抓包得到的帧多半是主站请求,先按应答解、不符再按请求解,05/06/08/16这类请求与应答同形的功能码如实标ambiguous,不把最常见的读请求一律判成「载荷不符」。报错知识库:
explain_build_error+keil_command把编译诊断文本与 Keil 命令错误码翻成「含义 / 根因 / 修法」(#20 identifier is undefined、error 57 illegal address、error 145断点已存在…)。只收录真机实测过的条目,未收录的一律confidence=unknown+ 通用排查路径,不编造含义;CMSIS-SVD 解码:
svd_list/svd_decode按芯片厂商的 SVD 解释寄存器值(比内置硬编码表更权威、换型号也能用):支持derivedFrom继承、cluster、数组与枚举位域;地址反查按<addressBlock>界定真实范围(固定窗口会在外设密集排布处串台),结果附matched_by标可信度、附svd_device标明用的是哪份 SVD;不给器件时按当前工程<Device>推断,绝不盲挑盘上第一份 .svd;工程文件受控编辑:
uvprojx_read/uvprojx_edit只读查看与增删包含路径/文件;改前默认备份、文本级替换不重排工程、锚点唯一性校验后再写,空改动不落盘(不写坏用户工程);通用等待与能力自述:
wait_state一次完成「等待 + 超时 + 现场」(timeout/unreachable/never_debugging三种超时分开报);capabilities一次问清当前环境两条通道、内置模块与工具面;address_for_line补齐「源码行 → 地址」反查(返回偶数地址,避开 Keil 的error 57);跨会话状态(
session_state):把「上次调到哪」存成文件——工程 / 符号文件 / UV4 路径 / 串口 / 调试态 / 断点 / 数据断点 / SVD 器件 / 工具集 / 快照基线一键save到state.json(默认~/.mdkdebug/state.json, 可用path或MDKDEBUG_STATE_FILE指定,多工程各存一份);load默认只对比不应用,apply=true也只做主机侧可逆动作(切换符号文件),断点 / 内存 / 运行态一律标never_auto_applied——恢复现场交给人/AI 决定,工具不替调用方猜。原子写 + 旧版.bak,文件损坏 / 结构不符 /schema不符 都明确报错,不假装「没有状态」;高输出工具的输出控制三件套(
compact/max_lines/full):list_tools、snapshot、read_registers、parse_map、serial_read等 36 个「列表 + 长说明」型工具的返回体容易吃掉上下文预算。 受控工具额外接受三个可选参数:max_lines=N只留 N 条、compact=true去空值字段 + 把元素间完全相同的 字段提到output.shared+ 把说明类长文本截断到 200 字符、full=true取全量(覆盖环境变量默认与max_lines)。 不传参数时行为与以前一字不差;裁了就报(output.truncated/dropped/hint), 不碰真值(数值与 line/text/value/data 这类内容字段绝不截断,列表元素不改写);随附 companion 技能
skills/mdkdebug/SKILL.md:把「怎么用这套工具」写成 AI 可直接读的技能文件 (先自检再动手、四条主线工作流、session_state接续、三个输出控制旋钮、参数与工具面约定、出错先看谁), 避免每次冷启动都从list_tools摸索;不依赖 Keil 的芯片也能调:
toolchain_*自己探测 gcc/make/cmake 并跑构建、target_*把接口与 trace 参数固化成 20 份档案、ocd_*用 OpenOCD 做内存/寄存器/断点/烧录——RISC-V、ESP32 这类不用 MDK 的目标走这条链路,与 Keil 链路互不干扰;SWD/SWO 两条 trace 通路 + 目标侧插桩:
trace_swo_*走 TPIU/ITM 单线输出,trace_rtt_*主机侧自研读写 SEGGER 兼容环形缓冲(不依赖上位机),另有 SWD 采样剖析(明标侵入式)与 DWT 计数器。插桩分两种工作模式:stream持续录持续读(要人在旁边盯着看),buff全速录、事后搬——固件自己往静态环形缓冲写,调试器只在 dump 那一下进来,时间粒度由目标侧 DWT 决定(可到 10 ns 级),录制期间目标不停、不 halt、不占 SWO/ETM;配套trace_buff_status/trace_buff_dump/trace_buff_reset。观测类工具(RTT / 变量 scope / halt 采样 / DWT / PC 采样)在 Keil 与 OpenOCD 两条链路上通用,用link=auto|keil|ocd选路:auto哪条链路有活会话用哪条(两条都有时优先 Keil);显式指定而那条不可用时不拿另一条顶上(那会读到另一个目标的现场),直接报错并带上两条链路各自的原因与起法;
读到的东西一定带
read_confidence/while_running/degenerate——读到的 0 不等于数据是 0;主机侧只能看到“目标愿意发出来的东西”,所以配套提供目标侧插桩组件components/trace/(ITM/RTT/UART/目标侧缓冲 四后端,只依赖 CMSIS),事件按带 CRC8 的 MTF 帧传出,丢包与坏帧如实计数上报;
随附模拟调试器:无需硬件即可离线联调与跑测试(UVSOCK 与 OpenOCD 各一份)。
工作原理
架构
┌──────────────┐ MCP(stdio/http) ┌──────────────────┐ UVSOCK/TCP ┌─────────────────┐
│ AI 工具客户端 │ ────────────────► │ Mdkdebug MCP Server │ ─────────────► │ Keil uVision │
│ (Claude/灵犀) │ │ (mdkdebug) │ 127.0.0.1:4823 │ + UVSOCK 插件 │
└──────────────┘ └──────────────────┘ └─────────────────┘AI 客户端通过 MCP 协议把用户/模型意图转成工具调用;mdkdebug 收到后,按 UVSOCK 二进制
协议把请求编码成命令帧,通过 TCP 发送给 Keil uVision 中加载的 UVSOCK 调试插件执行,并回传结果。
UVSOCK 协议要点
默认监听
127.0.0.1:4823;命令帧:头部 32 字节(
m_nTotalLen/m_eCmd/m_nBufLen/cycles/tStamp/m_Id)+ 数据段; 响应帧头部在此基础上多 8 字节(r_cmd/r_status),地址小端;关键命令码:
命令 | 码值 | 说明 |
|
| 进入调试模式 |
|
| 退出调试模式 |
|
| 全速运行 |
|
| 暂停 |
|
| 查询调试/目标状态 |
|
| 复位 |
|
| 单步进入 |
|
| 计算表达式 / 读变量 |
|
| 读内存 |
|
| 写内存 |
|
| 执行命令窗口命令( |
UV_DBG_STATUS的响应码语义为0=已停止、1=执行中(区别于通用UV_STATUS错误码)。
环境与依赖
环境要求
项 | 要求 |
操作系统 | Windows(Keil uVision 运行环境) |
Python | ≥ 3.11(开发 / 验证于 3.12) |
Keil | uVision 5,且已配置 UVSOCK 调试插件(见"对接真实 Keil") |
Keil UV4 |
|
OpenOCD(可选) | 调非 MDK 芯片 / 用 trace 时需要:可自动探测,也可在 |
交叉工具链(可选) |
|
MDK 与非 MDK 两条链路互相独立:只调 Keil 工程时不需要 OpenOCD,只调 RISC-V / ESP32 时不需要装 Keil。
Python 组件依赖
见 requirements.txt,核心依赖:
包 | 版本 | 作用 |
| ≥ 2.0(验证于 2.2.0) | MCP Server 框架( |
| ≥ 2.8(验证于 2.13.5) | MCP 依赖的类型模型 |
| ≥ 0.30(验证于 0.33) | 解析 |
| ≥ 5.0(验证于 5.0.9) | Thumb 反汇编,供 |
安装(两种方式任选其一):
# 方式一:仅装依赖,从源码运行
pip install -r requirements.txt
python run_server.py
# 方式二:打包安装(推荐,可执行 mdkdebug 命令)
pip install -e .
mdkdebug --version注:
mcp 2.x中FastMCP已改名为MCPServer(from mcp.server.mcpserver import MCPServer), 工具通过@server.tool()+ 类型注解注册。
目录结构
mdk_agent/
├── run_server.py # 启动入口薄壳(转发到 mdkdebug.cli)
├── pyproject.toml # 打包配置(pip install -e .)
├── requirements.txt # Python 依赖
├── README.md
├── mdkdebug/
│ ├── __init__.py # 包初始化(版本号 0.1.8)
│ ├── cli.py # 命令行入口(main,mdkdebug 命令)
│ ├── uvsock.py # UVSOCK 协议:命令码、VSET/AMEM/EXECCMD 打包与解析
│ ├── interface.py # TCP 物理接口层(含异步消息残留清理)
│ ├── client.py # UVClient:调试能力封装 + 连接缓存
│ ├── builder.py # UV4 命令行:编译 / 重编译 / 烧录 / 编译烧录闭环
│ ├── locator.py # 基于 .axf DWARF 的符号定位(地址↔文件:行 双向 + 源码读取)
│ ├── periph.py # 内置 STM32F4 常用外设寄存器表(RCC/GPIO/USART/SPI/I2C/TIM/...)+ 内存区域地图
│ ├── mapfile.py # .map 链接映射文件解析(Program Size/sections/symbols/栈使用/未用段)
│ ├── outctl.py # 高输出工具的输出控制(compact / max_lines / full)
│ ├── session.py # 跨会话状态存储(state.json:原子写 + 旧版备份 + diff)
│ ├── toolchain.py # 非 MDK:gcc/make/cmake 探测、构建、ELF/size/objcopy、编译错误解析
│ ├── targets.py # 非 MDK:目标档案(接口/速度/SWO/RTT 参数)与按名称、ELF 自动识别
│ ├── ocd.py # 非 MDK:OpenOCD telnet 会话与内存/寄存器/断点/烧录操作
│ ├── linkio.py # 链路原语层:把「读/写内存、读核寄存器、停/走」从 Keil(UVSOCK) 与 OpenOCD 里抽出来
│ ├── traceproto.py # trace 协议:ITM 解码、MTF 帧格式与 CRC8
│ ├── trace.py # trace:SWO / RTT(主机侧自研)/ SWD 采样 / DWT / 插桩组件部署(观测类工具两条链路通用)
│ └── server.py # MCP Server 与 190 个工具定义
├── components/
│ └── trace/ # 目标侧插桩组件(ITM / RTT / UART / BUFF 四后端,只依赖 CMSIS)
│ # mdk_trace.[ch] / mdk_trace_rtt.[ch] / config 默认头 / CMakeLists / README
├── skills/
│ └── mdkdebug/SKILL.md # 随附 companion 技能(工作流 / 参数约定 / 输出控制 / 排障入口)
├── tools/
│ └── run_all_tests.py # 统一测试闸门(工具数一致性检查 + 逐批回归)
├── tests/
│ ├── mock_uvsock_server.py # 模拟 Keil 调试器的 UVSOCK 服务器(离线联调)
│ ├── mock_openocd.py # 模拟 OpenOCD 的 telnet 服务器(含假 RAM / RTT 控制块,离线联调)
│ ├── test_batch*.py # 各批次 mock 回归(批次 8 拆为 8a/8b/8cd;逐批覆盖该批新增工具)
│ └── test_e2e / test_mcp / test_stdio / test_enhanced / test_unhardcode / test_diag.py
│ # 协议闭环 / MCP 工具注册 / stdio 握手 / 增强功能 / 去硬编码 / 诊断
├── example_mdk_project/ # 随附 STM32F4 HAL 例程(MDK/UVSOCK 链路的真机验证目标)
└── example_gcc_project/ # 随附 GCC 例程(非 MDK 链路的真机验证目标)
└── rtt_probe/ # STM32F401 自建 RTT 验证固件(引用 components/trace,无需 Keil)快速开始
启动 MCP Server
方式一:stdio(MCP 客户端标准方式)
python run_server.py # 默认连 127.0.0.1:4823
python run_server.py --port 4823 --idle-timeout 30方式二:Streamable HTTP(便于远程 / 网页 MCP 客户端)
python run_server.py --transport http --http-port 8300参数说明:
参数 | 默认 | 说明 |
|
| Keil UVSOCK 插件监听的地址 |
|
| 连接缓存空闲断开秒数( |
|
|
|
|
| HTTP 传输时的监听地址 |
| 自动探测 | Keil |
| 无 | 默认待编译 / 烧录的 |
暴露的 MCP 工具
共 190 个(默认只暴露 44 个,其余按需装载,见工具面),分两大块:
MDK 族(110 个)——调试读写 / 断点与命中等待 / 外设与内存 / 符号定位 / 工程分析 / 编译·清理·烧录 / UV4 命令行批处理调试 / CMSIS-SVD 解码 / 工程文件与分散加载文件(.sct)受控编辑 / 复位循环识别 / Keil 生命周期管理 / 宿主机串口日志与命令应答 · Modbus 主站(RTU/ASCII + 裸帧) / 看门狗冻结与 Cache 感知 / 环境自检引导(下表)。
非 MDK 族(68 个)——工具链(gcc/make/cmake 探测与调用、构建、ELF/size/objcopy、编译错误解析,10 个)/ 目标档案与多核(接口·速度·SWO·RTT 参数档案与自动识别、工程现场配置发现、多核目标的核列举与切换,7 个)/ OpenOCD(会话·内存·寄存器·断点·烧录,17 个)/ trace 与覆盖率(SWO·RTT·采样剖析·DWT·非侵入式 scope·插桩组件部署·代码覆盖率·ETM 能力探测·函数运行时线录制·目标侧缓冲后端·SWD 无缝流后端、任务表取名,34 个)——不依赖 Keil,同样能在 RISC-V / ESP32 等非 MDK 芯片上工作(见非 MDK 芯片与 trace)。
常驻元工具(6 个)——
toolset(工具面按需装载)/list_tools/capabilities/get_version/tools_groups/tools_load:永不被裁,否则 AI 连工具清单都问不出来、也装不回来。RTOS 任务感知(3 个)——
rtos_info/rtos_tasks/rtos_objects:FreeRTOS 的任务列表、状态、栈水位与队列/信号量。跨两条链路(有 Keil 会话走 UVSOCK,否则走 OpenOCD),因为「多任务卡死」既发生在 MDK 工程里也发生在 gcc 工程里(见 RTOS 任务感知)。
下表为 MDK 族工具:
工具 | 说明 | 主要参数 |
| 查询 UVSOCK 插件版本 | — |
| 查询是否处于调试、目标是否运行、状态码,并附当前符号文件路径 + 时间戳( | — |
| 计算并读取表达式 / 变量值 |
|
| 按变量名查地址/值/大小,支持数组逐元素与整块内存;App 侧重定位场景可配 |
|
| 读取目标内存( |
|
| 写入目标内存,默认写后回读校验( |
|
| 读 | — |
| D-Cache 一致性维护(M7 等带 D-Cache 的核): |
|
| 全速运行 | — |
| 全速运行 N 毫秒后自动暂停并返回停靠位置,用于验证时序;返回 |
|
| 暂停执行,默认带停止确证:停止是异步生效的(真机实测 stop 回 ok 后紧跟的 |
|
| 查询/置位 DBGMCU 的 IWDG/WWDG 调试冻结位。新会话/目标复位后冻结位会被清零(真机实测 APB1FZ=0x00000000),此时 halt 超过看门狗溢出时间就被复位、RAM 现场全丢;置位后 halt 期间看门狗停止计数。基址运行时探测(读 IDCODE 校验 DEV_ID,兼顾 F1/F4/F7 的 0xE0042000 与 H7 的 0x5C001000),不按内核硬编码 |
|
| 复位目标(变量回初值、断点保留)。真机实测:复位后停在复位向量、处于停止态,不会自行往下跑——必须再 |
|
| 单步执行,成功后自动附带停靠位置( |
|
| 运行到指定行(run to cursor),接受 |
|
| 读取当前 PC,定位到 文件:行号 + 源码上下文 + 完整调用栈回溯 + 源码漂移提示 + 断点命中反馈。另附 | — |
| 源码 文件:行号 → 地址( |
|
| 读取当前函数 参数+局部变量 及其值(DWARF 解析变量名, | — |
| 状态快照:位置(文件行+PC)+ 源码上下文 + 完整调用栈 + 局部变量 + 指定全局变量,一站式看清当前运行状态 |
|
| 变量组:批量读取多个表达式/变量的当前值,便于固定观察一组信号 |
|
| 结构体字段概览:基于 DWARF 解析字段布局(类型/偏移/大小),并用基址+偏移读各字段运行时值 |
|
| 数据断点:在变量/地址处设 读/写/读写 访问断点,命中即暂停( |
|
| 清除数据断点:先解析 Keil 真实断点编号再 |
|
| 列出当前数据断点(含地址、访问类型、位置) | — |
| 批量读取 CPU 核心寄存器 R0-R12/SP/LR/PC/xPSR 及当前值,并按 AAPCS 解读 R0-R3 入参、R0 返回值、LR 返回地址,排查参数/返回值/寄存器被踩 |
|
| capstone 反汇编目标代码:地址 |
|
| 一键诊断:聚合寄存器组(含 AAPCS) + PC 处反汇编 + 源码上下文 + 完整调用栈 + 局部变量 + 指定全局变量,一次调用看清现场 |
|
| 符号检索:从 .axf ELF 符号表模糊检索函数/全局变量(返回名字/类型/地址/大小),AI 读符号不再靠猜名字; |
|
| 写寄存器/改 PC:向 R0-R12/SP/LR/PC/xPSR 写值并读回验证,可修正现场、改返回值、改 PC 跳转执行 |
|
| DWT 周期计数器:读 CYCCNT(自动使能),配合两次采样算代码段执行周期数与耗时 | — |
| HardFault/异常定位:读 SCB(ICSR/HFSR/CFSR/MMFAR/BFAR)判异常类型+原因,从异常栈帧恢复 PC/LR/R0-R3/xPSR,排查死机/跑飞。CFSR/HFSR 是粘滞位(写 1 清除或复位才归零),故返回 | — |
| 清除 CFSR/HFSR 粘滞位(W1C,写 | — |
| 条件断点:仅在 condition(C 表达式如 R0==5)成立/第 count 次命中时才停,减少无关中断 |
|
| 按 CMSIS-SVD 列外设:在已安装的 Pack 里按订货型号找 |
|
| 按 SVD 解寄存器位域 / 按地址反查外设:给 |
|
| 外设寄存器一键读:内置 STM32F4 外设表(RCC/GPIO/USART/SPI/I2C/TIM/...),读指定外设寄存器并解析关键位域; |
|
| 列出内置外设寄存器表(外设名+基址+说明) | — |
| ITM/Debug(printf) Viewer trace:检查 Trace 配置(DEMCR/ITM->TCR/TER)是否就绪 + 拉取串口窗口缓冲,并做结构化解码(ITM 报文 port/header/ |
|
| 内存区域地图:FLASH/SRAM/外设/ITM/DWT/SCS 地址范围,可标注某地址落在哪个区域,防止把外设区当 RAM 读 |
|
| 在内存范围内扫描字节序列,返回所有命中地址(分块读、块间重叠防跨块漏匹配),找魔数 / 定位被越界写坏的缓冲 |
|
| 批量填充 / 清零内存:连续写入 count 个相同字节,清零大块缓冲 / 初始化 SRAM |
|
| 状态快照 diff:首次建基线(globals + 寄存器),之后对比输出 changed / unchanged / unreadable,定位被意外改写的状态 |
|
| 函数执行耗时分析:自动设入口断点 → 运行到入口记 DWT CYCCNT → step out 再记 → 差值,函数级性能分析 |
|
| 写入外设单个寄存器并读回确认:置时钟使能 / 改 GPIO 模式 / 配波特率 / 改定时器 |
|
| 运行至异常 / 断点并自动诊断:轮询等待停止,若停异常则读 ICSR/CFSR 判类型 + 收集现场,复现崩溃自动抓现场 |
|
| 复位循环 / 启动失败自动识别:按固定间隔读 Cortex-M 的 |
|
| 解析编译错误 / 警告为结构化列表(文件:行:列 + 消息),兼容 AC5 |
|
| 解析 .map 链接映射文件:Program Size / sections / symbols / 栈使用 / 未用段,检查 FLASH/RAM 占用与栈溢出风险 | — |
| 编译/命令报错知识库:把 AC5/AC6 的编译诊断文本或 Keil 命令错误码翻成「含义 + 根因 + 修法」,如 |
|
| 一次读取多个地址的内存(每项 {addr, n_bytes},缺省 32),减少 AI 往返 |
|
| 一次提交多条只读命令聚合返回(read_mem/read_variable/calc_expression/get_status/read_registers),减少往返 |
|
| 枚举工程全部 target + 当前 target + 调试 target(UV_PRJ_ENUM_TARGETS/GET_CUR_TARGET/GET_DEBUG_TARGET) | — |
| 切换调试 target(UV_PRJ_SET_DEBUG_TARGET),多 target 工程切目标后重新进调试 |
|
| 读取工程配置:各 target 编译器(AC5/AC6)、优化级别(-O0~-Otime)、编译宏 Define、包含路径、 |
|
| 读分散加载文件(.sct)结构:按行解析区域头( |
|
| 受控编辑 .sct:按行做文本级替换(保住缩进与注释,不整体序列化),支持 |
|
| 静态校验(结论看 |
|
| 只读查看 .uvprojx: |
|
| 受控编辑 .uvprojx(增删包含路径 / 增删文件):改前默认先备份( |
|
| 查询目标器件信息:实时读 DBGMCU->IDCODE 判 DEV_ID/REV_ID 映射型号 + SCB->CPUID 判内核 + 标称 Flash/RAM 容量与内存布局,排查资源吃紧/选错型号/容量不符 | — |
| 采样剖析定位热点:让目标运行,周期性暂停采 PC 归到函数统计占比(run/stop 采样,非硬件 ETM,会轻微扰动时序),找哪个函数占 CPU 最多 |
|
| 环境自检+工作流引导:一键自检 Keil/UVSOCK/UV4/.axf/源码漂移/调试态/RTOS 类型,返回推荐调试工作流与各场景应调用的工具,AI 落地第一件事先调它 | — |
| 环境一致性体检(跨仓库调试的防呆入口):一次问清「我的配置与板上真实情况是否一致」——① 芯片身份(读 DBGMCU->IDCODE 的 DEV_ID + SCB->CPUID 交叉校验,多地址探测 F1/F4/F7 的 |
|
| 能力自述:一次问清「这台机器上现在能干什么」——两条调试通道各自可用性(UVSOCK 交互 / UV4 命令行)、内置模块(SVD / 命令知识库 / 工程编辑 / 定位器)、工程与符号来源、工具面(注册总数 / 当前装载组 / 收起数与装回来的办法, | — |
| 自动进入 Keil 调试模式;已在调试态时返回 |
|
| 自动退出 Keil 调试模式 | — |
| 在符号 / 地址处设软件断点;已存在时 Keil 报 |
|
| 清除断点: |
|
| 列出断点(含对应的 文件:行号 位置); | — |
| 可见方式拉起 Keil 打开工程;已有同工程窗口则复用并前置,不新开;以 |
|
| 列出当前 Keil 实例(PID / 启动时间 / 打开的工程),一眼看清是否残留多个窗口 |
|
| 关闭 Keil 实例; |
|
| 编译工程( |
|
| 全量重编译( |
|
| 清理工程( |
|
| 烧录到目标 Flash( |
|
| 编译成功后才烧录,AI 全流程闭环(自带通道自愈);烧录后同样自动退出旧调试会话( |
|
| Keil 官方命令行批处理调试(第二条通道):把一串命令写成初始化文件挂到 |
|
| 「关旧 Keil→新固件上板→开新→进调试」一体闭环,规避旧窗口调试旧代码;上板方式自动选路( |
|
| 命令窗口直通:把命令原样发给 Keil 命令窗口并结构化返回(成功/报错行、错误码含义、是否可用 |
|
| 读取命令窗口输出 |
|
| 读取异步消息/报错 |
|
| 宿主机串口日志监听(后台线程收 → 按行切分 → ring buffer): |
|
| 向串口下发数据(一边收一边发): |
|
| 读取串口日志,支持增量:把上次返回的 |
|
| 串口监听状态( | — |
| 停止监听并释放串口(不释放的话 Keil 串口窗口/其他工具会打不开,报 WinError=5)。默认保留已收日志( |
|
| 扫描本机串口:列 |
|
| 串口原子 send+wait:下发命令并等到匹配内容或超时,一步完成请求-响应;只认调用之后新增的输出(不拿缓冲区旧日志冒充命中)。支持 |
|
| 按规范读从站:01 读线圈 / 02 读离散输入 / 03 读保持寄存器 / 04 读输入寄存器(RTU CRC16、ASCII LRC 都支持),返回解码值( |
|
| 按规范写从站:05 写单线圈 / 06 写单寄存器 / 0F 写多线圈 / 10 写多寄存器; |
|
| 非规范 / 私有协议的裸帧收发: |
|
| 离线解析报文(不占端口、不发一个字节):hex 或 ASCII 帧、支持多行批量;给出从站 / 功能码 / 载荷 / 校验结论,失败明确是「长度不足 / CRC 不过 / LRC 不过 / hex 非法」。自动判方向:先按应答解、不符再按请求解,结果给 |
|
| 扫在线的从站: |
|
| 被动旁听,不发一个字节:按静默切帧后列出(协议逆向 / 确认总线上到底有没有在跑)。总线上没主站请求时一帧都收不到是正常结果,不是故障 |
|
| 会话状态 / 开 / 关端口:串口是独占资源,会话会持有到显式关闭或空闲超时( |
|
| 读取持久化断点(.uvoptx) |
|
| 清除持久化断点(.uvoptx) |
|
| 清除全部软件断点; |
|
| 清除全部数据断点(按真实编号逐个清); |
|
| 设置/切换当前调试符号文件 |
|
| 列出预登记候选符号工程 | — |
| 设置 App 侧重定位偏移(运行地址 = 链接地址 + delta,如 SVCrtOS 的 |
|
| 跨会话状态: |
|
| 列出全部工具的名称/用途/必填参数/别名与最小调用示例( |
|
| 通用等待:轮询等目标进入 |
|
| 带超时等待断点命中(symbol/address 或 .uvoptx 持久化断点),命中即回源码位置并计数;支持数据观察点命中判定(返回 |
|
| 断点命中统计 | — |
| Keil 调试通道健康自检(UV4 进程 / UVSOCK 端口 / 模态框),Keil 未运行也能返回;检测到模态框时给出正文( | — |
| 读取并关闭阻塞 Keil 的模态对话框:读出框内正文与全部按钮,按 |
|
| 只重置 UVSOCK 连接(不重启 Keil):丢弃 socket 与残留缓冲,下次调用自动重连 |
|
| 一键重启 Keil:关全部实例 → 脱离父进程重启 → 等 UVSOCK 就绪 → 重连 |
|
编译烧录工具均以隐藏窗口后台执行,不闪现 Keil 界面;
launch_uvision则以可见方式打开 Keil 供调试查看。
编译烧录 / Keil 启动工具的
project均可省略:省略时使用启动参数--default-project指定的默认工程。符号(
.axf)按需惰性装载:启动时没配--default-project/--axf也不会让符号族工具作废—— 首次用到符号时按「本次会话用过的工程 → 服务默认工程 → 符号工程注册表唯一可用的.axf→ 附近唯一可推断的工程」 依次尝试,实际来源在get_status.symbol_source里如实披露;多候选时不替调用方决定(宁可报错)。
非 MDK 芯片与 trace(不依赖 Keil)
这一块工具完全不碰 Keil / UVSOCK:只要本机装了工具链与 OpenOCD,就能对 RISC-V、ESP32 等非 MDK 芯片做编译、烧录、调试与 trace。四组工具共 46 个。
工具链(toolchain_*,10 个)
用自动探测代替写死路径:启动时扫一组候选目录,找出本机实际装了哪些家族的编译器并把 bin 目录入库,工具调用只写家族名,不写绝对路径。
工具 | 说明 | 主要参数 |
| 列出已探测到的工具链家族与其中的可执行文件( |
|
| 组装环境变量(把家族 |
|
| 在已组装的环境里跑任意工具( |
|
| 判断一个目录是什么工程(Makefile / CMakeLists / ESP-IDF / uvprojx…),给出根目录、判据 |
|
| 按探测结果构建(make / cmake / idf.py),支持 |
|
| 直接编一个或多个源文件(不建工程),自动拼 |
|
| 解析 ELF 头:架构 / 机器 / 入口 / 段表(不依赖外部工具,纯 Python 解析) |
|
| 跑 |
|
| 生成 bin/hex/ihex/srec 等镜像格式 |
|
| 把编译器日志变成结构化错误:逐条给出 |
|
目标档案(target_*,4 个 + 工程配置发现 1 个)
把「这颗芯片用哪种接口、多快、SWO 主频与速率、RTT 控制块地址、DWT 是否可用」固化成 20 份档案(STM32F401/F411/F429/F407/F446/F103/F7/H7/L4、GD32F303、Cortex-M 通用、RISC-V 通用、ESP32/C3/C6/S2/S3、nRF52、RP2040、AIR001),避免每次调试都手写一长串 OpenOCD 参数。
工具 | 说明 | 主要参数 |
| 列出全部档案(可按 |
|
| 出一份档案的完整参数,并直接给出可用的 OpenOCD 参数串( |
|
| 查目标芯片信息:实时读 | — |
| 不认识芯片名/ |
|
| 从工程现场发现调试配置:解析 |
|
多核目标(core_*,3 个)
H7 双核(CM7 + CM4)、RP2040 双核(M0+ × 2)这类目标上,最容易踩的坑不是「读不到」,而是读到了另一个核——两个核的 SCS 地址完全一样(0xE000E000 那段在各自核里),所以读到的 CPUID / 断点 / 现场属于谁,只由调试器当前挂在哪个 AP/target 上决定。两条链路的能力不对称,而且这个不对称是真实的:
工具 | 说明 | 主要参数 |
| 列可用核。OpenOCD 链路真列(执行 |
|
| 切换 OpenOCD 当前选中的 target(= 换核)。核名必须与 |
|
| 读 Cortex-M 的 |
|
OpenOCD(ocd_*,17 个)
会话自动管理(起一次、后续工具复用),telnet 协议层做了输出整形:剔回显、折叠 Jim-Tcl 调用栈、提取 Error:(Warn : 不算失败)。
工具 | 说明 | 主要参数 |
| 起 OpenOCD 会话(可只给档案名让它自己拼参数),可追加 |
|
| 关会话:默认走 telnet |
|
| 会话与目标状态( |
|
| 下发任意 OpenOCD 命令(可多行),返回逐条结果;未知命令会带回 OpenOCD 的真实报错,不由工具猜原因 |
|
| 列出可用的 OpenOCD 配置( |
|
| 一次拿全:IDCODE、CPUID(实现者/变体/ | — |
| 运行控制: |
|
| 读内存( |
|
| 写内存,默认写后回读校验( |
|
| 读全部寄存器或读/写指定寄存器 |
|
| 软件断点: |
|
| 数据观察点: |
|
| 烧录:支持 |
|
| 列出 Flash bank(编号/名称/驱动/基址/容量,含 |
|
| 下载镜像到内存( |
|
| 借 GDB 批处理做一件 OpenOCD 原生不好做的事(可指定 |
|
| 读 OpenOCD 日志尾巴(可按 |
|
trace(trace_*,31 个)
三条通路:SWO/ITM(经 TPIU 单线输出)、RTT(目标内存环形缓冲,主机侧自研读写,不依赖 SEGGER 上位机)、SWD 采样(halt 采 PC,明确标注侵入式)。三条通路解码出的事件(含 MTF 帧)汇入同一缓冲区,由 trace_events 统一取。
两条链路:除 SWO 本身依赖 OpenOCD(TPIU 配置与落盘在那里)外,RTT、变量 scope、halt 采样、DWT 计数、PC 采样在 Keil(UVSOCK) 与 OpenOCD 上通用,都接受 link 参数(auto/keil/ocd,默认 auto):Keil 侧先 enter_debug,非 MDK 侧先 ocd_start。选路由 linkio 统一负责——不猜、不换链路顶上;Keil 侧读内存走带脏读判定的 read_mem_verified,返回值带 read_confidence/while_running,可疑就如实标注而不是给一个像样的数。
工具 | 说明 | 主要参数 |
| 主题式使用引导(接线、SWO 速率怎么定、RTT 集成、采样剖析代价、两条链路怎么选…),不认识的方法名会列出可选主题而不是给空 |
|
| trace 紧凑状态:模式、当前用的链路、事件计数、各后端状态、解码器统计(不是把事件全倒出来) | — |
| 配 TPIU + 开 ITM 端口( |
|
| 增量读 SWO 文件(每批只给新增事件,不重复倒);返回事件、解码器统计与后端状态 |
|
| 关 ITM 端口、停采集 | — |
| 离线复解:把一段 hex 或一个文件按 ITM+MTF 解成事件(不接硬件也能查问题) |
|
| 取事件缓冲(可按 |
|
| 清空事件缓冲( |
|
| 在 RAM 里扫 SEGGER RTT 控制块(按魔数扫描,扫描范围可指定成 |
|
| 按地址挂 RTT,读出上下行通道数与通道名;先校验 |
|
| 读上行通道(读后自动把 RdOff 写回目标,否则目标以为没被消费、数据会堆死) |
|
| 写下行通道(文本或 |
|
| 解除挂接并回本次统计 | — |
| 采样剖析:周期性 |
|
| 读 DWT 六个计数器(CYCCNT/CPICNT/EXCCNT/SLEEPCNT/LSUCNT/FOLDCNT)与 CYCCNT 使能位 |
|
| 变量 scope(只用 SWD 两线、不 halt 目标):主机侧按周期用 DAP 读 RAM,把变量连成时间线。 |
|
| 看 scope 现状:每变量 min/max/最后值/变化次数、真实生效采样率、丢点次数;只回最近 |
|
| 停掉后台轮询线程并汇总(忘了停会一直占 SWD 带宽) | — |
| DWT 硬件 PC 采样(同样不 halt 目标):开 |
|
| 把目标侧插桩组件部署进你的工程(见下):按 |
|
| 代码覆盖率(PC 采样法,不停目标):开 |
|
| 看当前快照: |
|
| 停掉后台采样线程并出最终报告(默认把 |
|
| 清空已有样本,从这一刻重新开始统计 | — |
| ETM/ETB 指令级 trace 能力探测(只探测、不抓取):走一遍 CoreSight ROM table(默认 |
|
| 读 CMSIS Event Recorder(MDK 原生、纯 SWD 可用的事件缓冲):数据通路是调试器读目标 RAM、不是 SWO 引脚(uVision 的 Event Recorder / Event Statistics 窗口读的就是这份数据)。 |
|
| 函数运行时线录制(细粒度事件流):在选定函数的入口下断点,每次命中记一条事件(时间、PC、所属函数、调用者、LR/SP、DWT 周期数),并给出按函数统计、调用者分布与时间线。MDK 与 OpenOCD 两条链路的抓取方式完全不同(Keil 走 UVSOCK 的 |
|
| 看目标侧静态环形缓冲的现状( |
|
| 把缓冲里的记录搬出来并解码时间线: |
|
| 复位目标侧缓冲(往控制块写 |
|
| SWD 无缝流后端的健康快照( |
|
| 无缝流的核心动作:读控制块 → 读 |
|
| 节拍预算:环还能录多久、该多久搬一次。环会满、宿主搬得慢就会丢事件,而「还能录多久」以前只能靠试——这里把它算出来:读两次控制块(间隔 |
|
| 往控制块 |
|
| 任务名从哪来、为什么没名字,看这一个工具: |
|
结果可视化(view_*,2 个)
前面那些采集工具(trace_* / rtos_* / coverage_* / 变量 scope)返回的都是给机器读的 JSON。要给人
看,过去得现写一个网页——每个问题写一遍、每次都从零开始,token 全花在画图上。view_render 把这件事
套路化:采集结果直接喂进去,出一张自带缩放/平移/回放的单文件页面。
工具 | 说明 | 主要参数 |
| 把采集结果渲染成一张可直接打开的单文件网页(无外部依赖、 |
|
| 可视化怎么用(省 token 的关键): |
|
用法就是一条命令:trace_buff_dump(...) 拿到 events → 把 JSON 交给 view_render(data_file=...) → 得到
path,打开即可。AI 不需要写一行 HTML。
RTOS 任务感知(rtos_*,3 个)
针对「多任务卡死 / 谁把栈吃爆了 / 消息发不进去」这类高频排查。不依赖任何目标侧配合(不需要
打桩、不需要开 trace),纯主机侧读内存 + 解析 .axf 的 DWARF。
工具 | 说明 | 主要参数 |
| 按符号存在性探测 RTOS 类型(FreeRTOS / RT-Thread),并从 DWARF 反推内核配置: |
|
| 任务列表:名字、状态、优先级、 |
|
| 队列 / 信号量 / 互斥量:名字、句柄、当前排队数与 |
|
三条硬约定(都是踩过坑之后定的):
结构体偏移一律取自
.axf的 DWARF,绝不写死。FreeRTOS 的TCB_t成员随configUSE_TRACE_FACILITY/configUSE_MUTEXES/configRECORD_STACK_HIGH_ADDRESS等宏增删, 写死偏移在别人的工程上必然安静地读出垃圾;缺哪个字段会明确列出来。栈水位算法与 FreeRTOS 自带的
uxTaskGetStackHighWaterMark完全一致:建栈时整片栈被填成0xA5,从pxStack(最低地址)向上数连续0xA5的字节数就是历史最深余量。所以它读的是 「历史最深用量」,对正在运行的任务同样有效(pxTopOfStack那个值只有切出时才更新,会滞后)。 栈底第一个字节就不是0xA5的任务(静态栈 / 自定义分配)会带stack_note,明说它的水位不可信。拿不到就报错,不给半真半假的结果。
configQUEUE_REGISTRY_SIZE==0时内核根本不定义xQueueRegistry,主机侧物理上无法枚举队列——此时返回ok=false并说明「这是内核的限制、 不是本工具没做」,而不是回一个空列表让人误以为没有队列。RT-Thread 路径同理:没有真机固件可验证, 就带verified:false明确拒绝输出,绝不把「看着像真的」的结构解析端上来。
link 默认 auto:有活着的 Keil(UVSOCK)会话就走 Keil,否则走 OpenOCD;两条都没有会同时报出
各自的缺失原因与启动方法。axf 可省略,默认用当前符号文件(set_symbol_file 设过的那个)。
真机验证(F401 + DAPLink,2026-09-18,验证固件 example_gcc_project/freertos_probe/):
OpenOCD 链路(TCB 语义级):8 个任务全部列出(
count == kernel_task_count == 8), 6 个任务的stack_free_words与固件里内核自报的uxTaskGetStackHighWaterMark逐项一致 (105 / 62 / 97 / 71 / 103 / 223);portMAX_DELAY无限阻塞的任务被从「真挂起」里分了出来; 队列注册表里 3 个对象(队列 / 计数信号量 / 互斥量)的名字、uxLength、uxItemSize全对。Keil 链路(取数正确性):
_keil_reader读到的 Flash 向量表 32 字节与.axf里ER_IROM1的镜像逐字节一致,并与 Keil 自己read_variable的求值同值(两条独立的 UVSOCK 取值路径互证)。 本机的 Keil 示例工程是裸机、没有对应的 FreeRTOS 版本,所以 TCB 语义级验证是在 OpenOCD 链路上 做的;两条链路共用同一套解析代码,差异只在读取适配层,这一层按上述方式单独验过。把裸机
.axf喂给 RTOS 工具会得到rtos-not-present(而不是编出一堆任务), 下一步指向「核对.axf是不是目标板上正在跑的那个固件」。stack_size_words由pxStack→pxEndOfStack换算,而 FreeRTOS 建栈时会把栈顶按portBYTE_ALIGNMENT向下取整后才记进pxEndOfStack,所以它可能比实际分配少 1~2 个 word (8 字节对齐时实测少 1:256 字的栈报 255)——绝对量看stack_free_words,它是准的,stack_used_pct有 1 个 word 级偏差,结果里附stack_size_note说清这件事。
目标侧插桩组件(components/trace/)
trace 不能只靠主机侧「猜」目标行为,需要在被调试代码里插一小段组件把事件送出来。组件随仓库提供(源码注释为英文,避免旧版编译器中文注释乱码),支持 ITM / RTT / UART / BUFF 四种后端,只依赖 CMSIS,不绑定 HAL:
文件 | 说明 |
| 组件主头:API + MTF 常量 + |
| 全部 |
| DWT/ |
| SEGGER 兼容的 RTT 控制块与环形缓冲(目标侧绝不写 RdOff,由主机侧推进) |
| 目标侧静态环形缓冲后端:控制块 80 B + 记录区(定长 12 B/条)放在一个连续 blob 里,主机只认一个符号 |
| 静态库 |
典型用法(更多见组件内 README):
mdk_trace_init(); /* 选后端、配时基 */
MDK_TRACE_SCOPE(adc_isr); /* 进出成对打点 */
MDK_TRACE_EVENT(ID_ADC_DONE, 123); /* 带 id + 数值的事件 */一条完整的非 MDK 链路大致是:
toolchain_detect_project → toolchain_build → toolchain_errors(有错就改)
target_guess(elf) → ocd_start(profile=...) → ocd_flash(file=...) → trace_instrument(target_dir=...)
→ 重新编译烧录 → trace_rtt_find / trace_swo_start → trace_events → trace_dwt_counters / trace_profile工具面(默认精简 + 按需装载)
190 个工具全量塞进上下文会稀释注意力、也吃掉上下文预算。所以默认只暴露 44 个(core 组 38 个 + 6 个元工具),其余 146 个没被删掉、也没失效,用 toolset 工具随时装回来:
toolset(action="status") # 装了哪些组、收起多少个、怎么装回来
toolset(action="load", toolsets="mem,rtos") # 追加装载(幂等,可反复调)
toolset(action="unload", toolsets="trace") # 收起
toolset(action="load", toolsets="all") # 一次全装 190 个(=full/*)装载也可以放在启动时:MDKDEBUG_TOOLSETS=serial 只留串口 14 个、core,build、toolchain,target,ocd,trace 把上百个 Keil 工具全收起来调非 MDK 芯片;=all 回到全开。启动参数优先于环境变量。
共 11 个组 + 1 个档位(core 为默认装载组;小上下文模型另有 nano 极简档,见下):
组名 | 内容 |
| 进出调试 / 运行控制 / 状态 / 跨会话状态 / 环境一致性体检、符号工程绑定、断点硬件残留校验、复位循环识别、可视化出图(38 个) |
| 内存与外设读写 / D-Cache 一致性维护(11 个) |
| 符号与源码定位(7 个; |
| 编译 / 清理 / 烧录 / 工程配置 / 分散加载文件(.sct)受控编辑(16 个) |
| 宿主机串口监听与命令应答 + Modbus 主站(14 个) |
| 诊断 / 剖析 / SVD / 工程编辑 / 复位循环识别等进阶能力(26 个) |
| 非 MDK:工具链探测 / 构建 / 编译 / ELF·size·objcopy / 编译错误解析(10 个) |
| 非 MDK:目标档案查询与自动识别、工程现场调试配置发现、多核目标列举与切换(7 个) |
| 非 MDK:OpenOCD 会话 / 内存 / 寄存器 / 断点 / 烧录(17 个) |
| 非 MDK:SWO / RTT / 采样 / DWT / 非侵入式 scope / 函数运行时线录制 / 插桩组件部署(含目标侧缓冲后端、SWD 无缝流后端)/ 代码覆盖率 / ETM 能力探测(35 个) |
| RTOS 任务感知:任务列表 / 栈水位 / 队列信号量(3 个;跨 Keil 与 OpenOCD 两条链路) |
四条防翻车约定:收起 ≠ 坏了——收起只是不进工具清单,load 装回来立刻可用(返回值里的 exposed 是新暴露数);list_tools / get_version / capabilities / toolset / tools_groups / tools_load 六个元工具永不被裁(否则 AI 连工具清单都问不出来也装不回来),未归类的工具一律保留、组名写错时只告警不裁剪(宁可少裁不错杀);装完若客户端报「未知工具」,多半是它缓存了旧的 tools/list——重新拉一次清单即可;装载状态随时可核对:toolset(action="status") 与 capabilities.tool_surface 都会报当前装载组、收起数与注册总数。
小上下文模型:nano 档 + 描述分层
工具数只是上下文成本的一半,另一半是每个工具的描述:190 个工具的描述合计约 9.5 万字符,其中约八成是背景叙述、失败模式、真机踩坑这类「参考手册」内容。两条路一起用,冷启动成本能压到很小:
档位 | 工具数 | 描述总字符 | 怎么用 |
默认( | 44 | 约 2.3 万 | 不设环境变量 |
| 19 | 约 4.6 千 |
|
| 190 | 约 9.5 万 |
|
| 190 | 约 8.0 万 | 正文只留 ~360 字符(结构化尾块与结尾告警照留) |
| 190 | 约 5.1 万 | 工具全要,但描述只留一句摘要 |
nano档不是「组」而是档位:它横跨core/build/trace三组,挑出 15 个最短入口(健康检查 / 编译烧录 / 进出调试 / 跑停 / 读写内存与变量 / 断点 / 读 trace / 取回完整说明的mdk_guide)+ 6 个元工具,小上下文模型也能一次装全,之后再按需加装。描述分层(
MDKDEBUG_DESC=full|lean|min,默认full——默认对外暴露的描述一个字不改):选lean/min时,常驻层只留一句话用途 + 【输出控制】/【参数】/【调用示例】块;被挪走的正文一个字不改地归档,随时用mdk_guide(topic="tool", name="read_mem")逐字取回(取回结果与瘦身前完全一致)。正文截断保留「段首 + 段末」,绝不把结尾的关键告警截掉(如read_mem结尾的「置信度低时不要据此下结论」)——schema 里有的参数,描述里必须有说明,不允许出现「参数在、说明没了」这种看似权威的错答案。默认档为什么是full:190 个工具里有七十多个长到会被截,而截掉的往往是边界条件与失败模式——默认档悄悄砍掉它们,模型反而更容易用错工具(这是「看似权威的错答案」的同族问题);要省上下文请走nano档(自动min)或显式选lean/min,别指望默认档替你省。两个装卸入口:
tools_groups()列全部组 / 档与当前是否已装(可直接tools_groups(group="mem")看某组里有什么);tools_load(group="mem,trace")按需装上(group=nano/all也认,unload=true收起)。toolset与它们等价,老用法不受影响。
参数约定(别名 / 类型宽容 / 单位换算)
工具签名面向「AI 直接写」设计,参数名与类型都做了容忍,不必靠报错反推签名:
名称列表参数(
globals、regs、fields、expressions、addresses、commands…) 同时接受数组、JSON 数组字符串、以及逗号 / 分号 / 竖线 / 空格分隔的字符串, 例如regs: ["MODER","ODR"]与regs: "MODER,ODR"等价;地址类参数(
addr/address/start/end/expr/target…) 同时接受整数(0x20000000)、"0x…"、十进制串与符号名,read_mem(addr=0x20000000, n_bytes=8)可直接写;参数别名:主名保持不变(不破坏已有调用与文档),但每个工具额外接受一组统一别名 (如
expr ← expression/var/variable、addr ← address/location、query ← keyword/name)。list_tools的描述里会附一段【参数别名】,并写明规范名以上方【参数】行为准、未列出的 参数名会被拒绝——别名是兼容写法,不是「参数名随便写都行」的许可证;时间参数单位换算:时间参数按族展开,
timeout/duration/max/wait属同一族, 族内「任意前缀 × 任意写法(无后缀 /_ms/_s)」都能落地:run_timeout(duration_s=2)≡run_timeout(timeout_ms=2000)。 单位以别名自带的后缀为准(_s= 秒、_ms= 毫秒);不带后缀时按主名单位解释, 所以list_tools会把主名单位标出来(如timeout_ms(毫秒));interval_/poll_自成一族(采样间隔),刻意不与超时族互通,避免静默改变行为;未知参数显式拒绝:框架默认静默忽略未知参数,打错键名会悄悄拿到默认值。本服务改为直接报错, 并在消息里列出该工具接受的参数与可用别名(
_前缀的元参数除外);别名不遮蔽真实参数,且主名优先:与某工具真实参数同名的别名会被剔除(如
read_mem真有length就不再拿它当n_bytes的别名);主名与别名同时出现时只认主名。
高输出工具的输出控制(compact / max_lines / full)
长链路调试里最先被吃掉的不是 token 预算,而是注意力:list_tools 99 条、snapshot 整份现场、
parse_map 全表、serial_read 几千行日志。36 个高输出工具因此额外接受三个可选参数:
参数 | 作用 |
| 只留「元素为对象的列表」里的前 N 条( |
| 删空值字段、把列表元素间取值完全相同的字段提到 |
| 强制不裁剪,覆盖环境变量默认与 |
不传参数=行为与以前一字不差(返回体里连 output 键都不会出现)。也可以用环境变量给全局默认:
MDKDEBUG_COMPACT=1、MDKDEBUG_MAX_LINES=200;capabilities 会回报当前受控工具数与环境默认值。
两条底线:
裁了就报:只要扔掉过任何东西,信封里必有
output.truncated=true、output.dropped、 以及output.hint说明怎么取回全量——绝不静默丢数据让调用方以为「这就是全部」;不碰真值:只删空值字段 / 重复字段 / 说明性长文本,绝不修改任何数值,绝不截断
line/text/value/bytes/data这类内容字段,列表元素本身也不改写。 注意count/total这类计数字段仍是全量口径(不会被max_lines改写),hint里会写明这一点。
batch 内的子命令同样支持(args 里写这三个键即可),与单工具直调等价。
接入 AI 工具客户端
以支持 MCP 的客户端为例,在 MCP 配置中加入该服务:
{
"mcpServers": {
"mdkdebug": {
"command": "python",
"args": ["D:/工作/git_project/mdk_agent/run_server.py", "--idle-timeout", "30"]
}
}
}请将示例中的绝对路径替换为你的工程实际路径。
注入自定义符号工程
可切换的符号工程(供 list_symbol_projects 列表、配合 set_symbol_file 切换)默认仅含仓库内置的
mdk_test(路径相对仓库根自动推导,clone 后编译出 .axf 即自动可用,不写死本机绝对路径)。
本机或仓库外工程的符号文件无需改代码,用以下任一方式追加注入:
启动参数(可多次指定):
--symbol-project 名字:.axf路径:.map路径:flash起始16进制:flash大小16进制环境变量
MDKDEBUG_SYMBOL_PROJECTS(JSON 数组,flash_start/flash_size为十进制整数):[{"name":"myproj","axf":"D:/board/out.axf","map":"D:/board/out.map","flash_start":134217728,"flash_size":1048576}]
示例(同时保留内置 mdk_test,并追加一个本机工程):
python run_server.py --symbol-project myboard:D:/board/out.axf:D:/board/out.map:0x08000000:0x100000对接真实 Keil
⚠️ 必须先开启 UVSOCK,否则无法在线调试
本工具的所有调试能力(读变量 / 表达式、读写内存、断点、进出 debug、运行控制)全部依赖 Keil 的 UVSOCK 服务(默认监听
127.0.0.1:4823)。不开 UVSOCK = 无法调试,连读一个变量都会失败。开启方法(Keil uVision5):菜单
Edit → Configuration...→ 切到 Other 选项卡 → 勾选 UVSOCK Enabled → 确认端口为 4823 → 点 OK → 重启 Keil 使设置生效。若未开启 UVSOCK,调用调试工具会直接返回上述开启指引(提示你如何打开),不会静默失败或抛无意义的报错。
在 Keil uVision 中开启 UVSOCK:菜单
Edit → Configuration...,切到 Other 选项卡, 勾选 UVSOCK Enabled,确认端口为 4823,点 OK 后重启 Keil 使设置生效; 之后它会在127.0.0.1:4823监听(供本服务连接调试)。若未开启,连接类工具会返回开启指引;进入调试会话后,启动本 MCP Server,即可由 AI 调用上述工具进行在线调试;
calc_expression可直接使用工程内变量名;读写内存地址按目标映射(如0x20000000为 SRAM);断点 / 进出 debug 的命令与语义如下:
断点:
set_breakpoint(BS)、clear_breakpoint(BK)、list_breakpoints(BL)——经UV_DBG_EXEC_CMD下发;进出:
enter_debug/exit_debug——走UV_DBG_ENTER/UV_DBG_EXIT。
使用示例(完整调试闭环)
假设目标停在调试入口,向 AI 工具发起如下调用序列,即可完成一次"设断点 → 运行到断点 → 读变量 → 退出":
1. enter_debug # 自动进入调试模式
2. set_breakpoint(main) # 在 main 设断点
3. run # 全速运行,命中 main 断点后停止
4. calc_expression(SData_UA) # 读取变量值
5. stop # 暂停
6. exit_debug # 退出调试模式
example_mdk_project/mdk_test为随附的 STM32F4 HAL 例程(main 中 while(1) 翻转 GPIOC PIN13), 供真机验证与入门参考,随项目一并开源。
编译 → 烧录 → 调试 完整闭环
AI 修改代码后,可按如下顺序实现"自己编译、自己烧录、自己验证"的全流程闭环:
1. build_and_flash(project="") # 先编译,成功后自动烧录到目标 Flash
# 或拆开:build_project → flash_download
2. enter_debug # 自动进入调试模式
3. set_breakpoint(main) # 在入口设断点
4. run # 全速运行到断点
5. calc_expression(...) # 读取变量验证改动是否生效
6. exit_debug # 退出调试模式注:
build_and_flash返回结构含build与flash两个子结果;仅当编译退出码为 0/1(无致命错误)才执行烧录,否则跳过烧录并报错。
测试
无需真实 Keil,也无需真实 OpenOCD:MDK 链路用 tests/mock_uvsock_server.py 模拟调试器,非 MDK 链路用 tests/mock_openocd.py 模拟 OpenOCD(内建假 RAM 与 RTT 控制块,能验证内存读写、寄存器、断点、烧录与 RTT 收发)。
跑全部(默认 4 路并发,本机约 72s;串行约 157s,两者结论一致):
python tools/run_all_tests.py # 实际工具数 vs tests/README 写死的断言 + 全部批次模块
python tools/run_all_tests.py --fast # 只跑关键 5 批(改一两个模块时用,约 48s)
python tools/run_all_tests.py --only test_batch36,test_batch35 # 指定模块
python tools/run_all_tests.py --jobs 1 # 退化成串行(怀疑并发干扰时用)
python tools/run_all_tests.py --no-run # 只做一致性检查(秒级,改工具后先跑这个)并发的安全前提是「各模块自带 mock、端口互不相同」;共用同一个守卫端口的模块(
EXCLUSIVE_GROUPS:test_batch29/test_batch35)会被自动排到串行尾巴,避免互相抢端口跑出假失败。
单个模块:
python tests/test_e2e.py # UVClient 协议闭环(26 项)
python tests/test_mcp.py # MCP Server 工具注册与调用(31 项)
python tests/test_stdio.py # stdio 全链路客户端握手(7 项)
python -m tests.test_batch36 # 非 MDK:工具链 / 档案 / OpenOCD / trace 四组(137 项)单独启动模拟调试器供人工联调:
python -m tests.mock_uvsock_server --port 4823 # 模拟 Keil 调试器
python -m tests.mock_openocd --port 4444 # 模拟 OpenOCD telnet(打印实际监听端口)可靠性约定(读前必看)
调试工具最贵的一类错误是「用不可信的数据下了结论」——读到整帧 0 就说变量被清零、
看到 UsageFault 位就说刚才跑飞了、stop 回 ok 就当目标已经停下来。以下约定直接决定
「什么结果算数」,细节、真机实测数据与踩坑过程见 docs/PITFALLS.md。
场景 | 约定 | 看到什么不要当真 |
读内存 |
|
|
停目标 |
|
|
看故障 |
|
|
并发调用 | 所有 UVSOCK 命令经统一闸门串行化(进程内 | 同一台调试器上跑多个 MCP 实例时,写入可能被静默覆盖;需要严格顺序的多步写入请用 |
输出裁剪 | 受控工具支持 |
|
Modbus 端口独占 | Modbus 会话与串口日志监听互斥:serial_monitor 正占着同口时 | Modbus 是二进制帧协议,别拿按行切分的日志监听接它 |
串口占用 | 调试结束 / 烧录 / 关 Keil 时自动释放端口(释放只还口、日志保留),另有空闲超时与进程退出兜底 | 同一个串口别被两处同时打开(本服务 + Keil 串口窗口会互相抢占, |
真机调试里已经撞到过的工具问题(现象 / 机理 / 影响 / 处置 / 仍未修的都照实)汇总在 docs/mcp-issues.md。
串口可收也可发:端口按可读可写打开,收与发共用同一句柄;拿不到写权限时退回只读并置
can_write=false。serial_monitor_start 会等端口就绪再返回,其 port_ready / can_write
可直接采信。
serial_monitor_start(port="COM9", baud=115200) # 持有端口
serial_write(text="help") # 下发命令(默认追加 CRLF),并带回新增回显
serial_write(hex="7e 01 00 ff", eol="none") # 二进制 / 镜像片段
serial_read(since=上次 next_seq) # 长响应继续增量取
exit_debug() # 调试结束 → 自动还口,日志仍保留# 规范 Modbus:读 10 个保持寄存器(电表/变频器常见 9600 8E1)
modbus_read(slave=1, func=3, addr=0, count=10, port="COM9", baud=9600, serial_format="8E1")
modbus_write(slave=1, func=6, addr=0x10, value="0x1234", verify=True) # 写后自动回读
modbus_scan(slaves="1-16", port="COM9", baud=9600) # 从站号到底是几
# 非规范 / 私有协议:裸帧收发(自动补 CRC,不用手算)
modbus_raw(req="01 03 00 00 00 01", auto_crc=True, port="COM9", baud=9600)
modbus_sniff(duration_ms=3000, port="COM9") # 旁听:别人在问什么(不发一个字节)
modbus_session(action="close") # 用完把口还回去设计要点
连接缓存:常驻服务内共享一条 TCP 连接,
idle_timeout空闲自动断开、下次调用自动重连,兼顾实时性与资源释放;可靠性优先:不可信的数据不参与结论(脏读防护 / 停止确证 / 粘滞位时效)、并发调用统一串行化、串口用完就还——速查见上节「可靠性约定」,实测数据与踩坑过程见 docs/PITFALLS.md;
输出控制做在调用出口:
compact/max_lines/full统一在 MCP 调用出口实现(含batch子命令), 而不是逐个改上百个工具——新增工具自动继承,也不会有人漏改;非受控工具(如write_mem)保持原样;内存读写分块:超过单次上限(16 KB)自动分块读,规避 Keil 协议长度限制;
地址解析:工具层统一支持
0x/0b/0o前缀或纯十进制;编译烧录选型:采用 Keil 官方
UV4.exe命令行(-b/-r/-f/-o),退出码 0=成功、1=成功有警告、2=有错误、≥3=不完整;编译输出经-o重定向到临时日志文件捕获;build_and_flash在编译成功后自动接烧录,形成闭环;窗口策略:编译 / 烧录用
STARTUPINFO(SW_HIDE)隐藏新进程窗口(不闪现),launch_uvision用可见方式打开 Keil 供调试(已有同工程实例则复用前景化,不新开窗口);隐藏的是本次新建的 UV4 进程,不影响用户已打开实例;UV4 与 UVSOCK 共存:编译烧录与在线调试共用同一 Keil 实例;建议先
build_and_flash(此时 Keil 处于非调试态)再enter_debug进入调试,避免调试态下编译冲突。
已知限制
list_breakpoints的real字段解析自 Keil 命令窗口BL的输出文本,格式可能随 Keil 版本变化; 解析不到时会退化为内部记录并在note中说明(不影响断点本身的设置与清除);断点管理依赖 Keil 命令窗口命令语义,仅适用于 Keil 支持的表达式 / 地址;
UV4.exe 不是单实例程序:早期版本误以为同工程会复用,实际每次可见启动都会新开窗口 (真机曾累积 6 个同工程实例)。现已改为默认复用已有窗口,并提供实例清点与收敛工具; 同工程窗口的识别依据是主窗口标题里的工程全路径,若 Keil 改版改变标题格式会退化识别为 「不同工程」(此时
close_uvision(keep=...)仍可用,只是project过滤可能不命中);enter_debug受工程Load/Flash Download/Run-to-main设置影响,属有副作用的操作。
许可证
本项目采用 MIT License。完整许可证正文见 LICENSE。
MIT License
Copyright (c) 2026 <春雫>参考与致谢
KeilAssistant:UVSOCK/TCP 协议参考实现
debug-keil-uvsc:uvsc DLL 封装,提供完整
EXECCMD/SSTR结构定义与命令窗口断点语义
Available Tools
44 toolsbatch_debug_scriptUV4 命令行批处理调试(-d + 初始化文件)ADestructive
用 Keil 官方命令行批处理通道跑一段固定的调试脚本:UV4 -d <工程> -j0 进调试并执行初始化文件里的命令序列。不依赖 UVSOCK(不需要 Keil 里开着 UVSOCK、也不怕连接被占/空闲断连),适合可重复的冒烟/回归(复位后采现场、跑几步看寄存器、抓一段打印),以及 UVSOCK 不可用时的降级通道。交互式排查请仍用 UVSOCK(enter_debug + keil_command)——那条通道可以中途改主意,本通道是「一条道跑到黑」。
commands:命令清单(数组,或换行分隔的字符串),一行一条。常用的有 g, main(运行到 main)、BS <符号>(下断点)、BL、G(跑到断点)、T/P/O(单步)、EVAL <表达式>、printf("%08X", _RDWORD(0x20000000))(无头读内存)。
四条真机实测的坑(工具已尽力兜住):
命令报错不改退出码(UV4 恒回 0):成败只认日志里的
*** error N, line M。本工具把退出码、逐条命令的 error、以及每条命令是否走到完成标记分开返回,ok 字段是综合判定结果。Go main/Go会挂死(官方语法是g, main,逗号不可省);DISPLAY/SAVE在-j0无头模式下也挂死。这两类写法会被静态检查提前告警,但仍请避开。无窗口焦点时单步退化为指令级(
T会进函数逐条指令走)。每轮 15~25s(含进调试 + Erase/Program/Verify),显著慢于 UVSOCK;timeout_s 默认 240。 实现细节:初始化文件与 trace 日志写在系统临时目录(ASCII 路径,真机实测中文路径会 UnicodeEncodeError),并把路径写入 .uvoptx 的
<tIfile>;前置备份、无论成败都还原,不会把你的工程改脏。返回 artifacts 里给出 init_file / trace_log / workdir 现场路径,log_tail 是日志尾部。高风险:会真正进调试并下载程序(Erase/Program/Verify)。 【参数】必填: commands;可选: project, timeout_s, visible 【调用示例】{"commands": [{"tool": "read_mem", "args": {"addr": "0x20000000", "n_bytes": 16}}]} 【风险】高——不可逆:会改写目标 Flash/内存,或关闭/重启用户的 Keil 实例。执行前确认目标与工程正确。
| Name | Required | Description | Default |
|---|---|---|---|
| project | No | ||
| visible | No | ||
| commands | Yes | ||
| timeout_s | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations already indicate destructiveHint=true, but the description goes far beyond by detailing the exact destructive actions (Erase/Program/Verify), the fact that it can close/restart Keil, the return-code pitfall (always 0), the hang-prone commands, and the backup/restore behavior. This full disclosure significantly exceeds what annotations provide.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Though long, the description is exceptionally well structured: core purpose upfront, then bullet-pointed pitfalls, then implementation details, then parameters and an example. Every sentence adds value – no fluff. The front-loading and use of headings/bullets make it easy to scan and grasp quickly.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a high-risk, high-complexity tool with annotations and an output schema, the description is essentially complete. It covers purpose, usage, parameters, return values (artifacts, log_tail), risk warnings, and even handles edge cases like Unicode paths. An agent has everything needed to call it correctly and understand consequences.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
With 0% schema coverage, the description carries the entire burden of parameter explanation. It explains commands (array or newline-separated), gives concrete command syntax examples, notes timeouts, mentions the optional project and visible parameters, and even describes the return artifacts. This fully compensates for the missing schema descriptions.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description precisely identifies the tool as a UV4 command-line batch debug channel that runs a fixed init-file script. It clearly distinguishes this from the UVSOCK interactive channel by naming the alternative (enter_debug + keil_command) and stating when each is appropriate. This gives an agent a definitive understanding of what the tool does beyond its name.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description explicitly states use cases (repeatable smoke/regression, fallback when UVSOCK unavailable) and explicitly tells agents to use UVSOCK for interactive troubleshooting. It also warns about hangs and slower execution, providing concrete operational guidance and criteria for choosing this tool.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
calc_expression读取表达式 / 变量值ARead-onlyIdempotent
计算并读取调试器中的一个表达式(变量名、寄存器、指针解引用等)。例如传入全局变量名 'SData_UA'、'timer.sec',或 '(uint32_t)0x20000000'。返回表达式在当前断点处的值及其类型。注意:需已进入调试且目标暂停,目标运行中无法求值。刚 run 到断点停止的瞬间读取表达式可能返回脏值(如 PC=1),必要时重试。 【参数】必填: expr;可选: 无 【调用示例】{"expr": "main"} 【参数别名】expr ← expression/func/function/keyword/location/name/pattern/query/symbol/target/var/variable。规范名以上方【参数】行为准;未列出的参数名会被拒绝,不会静默忽略
| Name | Required | Description | Default |
|---|---|---|---|
| expr | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations already mark the tool as readOnly, idempotent, and non-destructive. The description adds meaningful behavioral caveats beyond that: the target must be paused, a running target cannot be evaluated, and a value read immediately after hitting a breakpoint may be stale or dirty (e.g., PC=1), with advice to retry. This is valuable extra context an agent needs to interpret results correctly.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is front-loaded with the core behavior and examples, followed by necessary caveats and then the parameter contract. Every section earns its place, including the alias list, which prevents agents from passing legacy parameter names. There is no filler or tautology.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a single-parameter, read-only tool with an output schema present, the description covers invocation syntax, example inputs, prerequisites, timing caveats, and the parameter contract. An agent has enough information to select and call this tool correctly without needing the output schema content.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema exposes only a bare required string 'expr' with no description, so the description carries the full burden. It clearly explains what expr can contain (variable name, register, pointer dereference), provides multiple concrete examples, lists accepted aliases, and warns that unlisted parameter names are rejected rather than silently ignored.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description opens with '计算并读取调试器中的一个表达式' and gives concrete expression forms such as 'SData_UA', 'timer.sec', and '*(uint32_t*)0x20000000', making the resource and verb clear. It does not explicitly contrast itself with siblings like read_variable or read_mem, so some differentiation is left implicit.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides clear operational context: debug must be active, the target must be paused, evaluation is impossible while running, and values may be dirty immediately after a run-to-breakpoint with retry guidance. It does not name alternatives or explicitly state when to choose this tool over read_variable or read_mem, so full routing guidance is missing.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
capabilities能力自检(本服务能做什么、哪条通道现在通)ARead-onlyIdempotent
冷启动第一步的能力自检:一次看清这台上有什么可用、以及每条通道当前通不通,避免 AI 拿不存在的功能去试错。返回四块:
channels:两条调试通道的可用性——uvsock(交互式,需 Keil 运行且 UVSOCK 已开)与uv4_cmdline(UV4 -d 批处理,不依赖 UVSOCK);附各自实测结论与何时该用哪条。modules:本服务内置模块是否就绪——uvprojx 编辑、CMSIS-SVD 解码、Keil 报错知识库(含已实测的命令错误码条数)、串口监视、构建器等。env:UV4 路径、默认工程、符号文件来源、端口、工具裁剪设置。tool_surface:当前暴露的工具数(受 MDKDEBUG_TOOLSETS 影响),以及推荐工作流。 与 keil_health 的分工:keil_health 做诊断(坏了帮你定位坏在哪一环),capabilities 做枚举(有什么、哪条路现在能走)。 【输出控制】本工具返回体可能较大,额外接受三个可选参数:compact=true(精简)/ max_lines=N(限制列表条数)/ full=true(强制全量)。默认都不传=行为不变;被裁掉的内容一定会在返回体的 output 字段里如实上报(truncated/dropped/trimmed/hint),不会静默丢数据。也可用环境变量 MDKDEBUG_COMPACT=1 / MDKDEBUG_MAX_LINES=N 设全局默认。 【参数】必填: 无;可选: compact, max_lines, full 【调用示例】{}
| Name | Required | Description | Default |
|---|---|---|---|
| full | No | 强制返回全量:忽略 compact/max_lines 与对应环境变量的默认值。当上面两项让你只看到部分数据、而你要据此下结论时,用它取回完整结果。 | |
| compact | No | 精简返回体:去掉空值字段,把列表元素中取值完全相同的字段提到 output.shared,并把 usage/note/hints 之类**说明性**长文本截断到 200 字符(数值与内容字段不动)。被裁掉的东西都会列在 output 里,绝不静默丢弃。不传则不改行为(受 MDKDEBUG_COMPACT 影响)。 | |
| max_lines | No | 限制返回的列表条数(只作用于元素为对象的列表,如 results/items/tools):最多 N 条,其余丢弃并在 output.truncated/dropped/hint 里如实上报。0 或省略=不限(受 MDKDEBUG_MAX_LINES 影响)。 |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations already declare readOnlyHint, idempotentHint, destructiveHint=false, and the description is fully consistent with them (no contradiction). Beyond that, it adds rich behavioral context the annotations cannot express: the output payload can be large with an output-control mechanism, truncated/dropped/trimmed content is always reported in the output field (never silently discarded), env vars MDKDEBUG_COMPACT/MDKDEBUG_MAX_LINES affect defaults, and channel availability depends on Keil runtime and UVSOCK state.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The core purpose is front-loaded in the first sentence ('冷启动第一步的能力自检'), and every subsequent block — four return sections, keil_health differentiation, output-control rules, parameter summary — earns its place. The output-control paragraph is long, but justified given this tool returns large payloads and obeys environment variables. Minor redundancy exists between the description body and the input-schema parameter texts.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's complexity — an output schema documenting return values, complete annotations covering safety/idempotence, and three optional parameters — the description is complete. An agent has everything needed to call it correctly: what it returns (4 sections), when to call it (cold-start first), how sizing controls behave and interplay with env vars, and the guarantee of no silent data truncation. The presence of an output schema relieves the description of explaining return-value shapes.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100%, so each of the three parameters (full, compact, max_lines) is already documented in the schema, giving a baseline of 3. The description adds real value beyond the schema by explaining how the params interact with each other and with the environment variables (defaults, precedence, 'default not passed = unchanged behavior'), and by clarifying that dropped content is reported rather than silently lost. It slightly exceeds the baseline but the schema still carries the core burden.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a specific verb-plus-resource pair: '能力自检' (capability self-check) enumerated across four concrete return sections (channels, modules, env, tool_surface). It explicitly differentiates itself from the sibling keil_health ('keil_health 做诊断, capabilities 做枚举'), so an agent can distinguish it without opening either schema.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description is explicit about when to invoke it: '冷启动第一步' (first step on cold-start) before trying features the agent might not have. It names the alternative keil_health and gives the exact selection criterion (diagnosis vs enumeration), and even advises which of the two debug channels to use per scenario (uvsock needs Keil running with UVSOCK open vs uv4_cmdline which does not depend on UVSOCK).
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
clear_all_breakpoints清除全部软件断点ADestructiveIdempotent
清除软件断点:清空本服务内部记录并逐个按确切地址发 BK。include_uvoptx=True 时一并清除工程 .uvoptx 中 Keil 持久化的断点(BK 清不掉、下次进调试会自动恢复的残留)。注意:Cortex-M 目标经 SWD/JTAG 调试时,未超出硬件断点槽位(FPB)的代码断点走硬件断点,清除不涉及改写 Flash,无需重新烧录;仅当断点数量超出硬件槽位而落到 Flash 软件断点、或使用模拟器(Simulator)时才需重新烧录恢复原指令。清理 .uvoptx 需 Keil 已关闭(否则被内存断点回写覆盖)。hard=True 走 BK * 之后会复核硬件断点单元(FPB)(fpb 字段):Keil 的逻辑表干净了、硬件里还留着启用项时,本工具不会报 ok——那正是 J-Link 一直报 "two breakpoints at the same address" 的成因(error_code=breakpoint-residue,含 enabled_addrs 与 next_actions)。FPB 读不到时如实标 unavailable,不当成清干净。 【参数】必填: 无;可选: include_uvoptx, hard 【调用示例】{} 【风险】高——不可逆:会改写目标 Flash/内存,或关闭/重启用户的 Keil 实例。执行前确认目标与工程正确。 【参数别名】include_uvoptx ← uvoptx/with_uvoptx;hard ← force/hard_clear。规范名以上方【参数】行为准;未列出的参数名会被拒绝,不会静默忽略
| Name | Required | Description | Default |
|---|---|---|---|
| hard | No | ||
| include_uvoptx | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations already mark destructiveHint=true and idempotentHint=true, but the description adds substantial beyond-annotation context: the exact mechanism (sending BK by address), the irreversible risk of rewriting Flash/memory or closing/restarting Keil, the FPB residue check with error_code=breakpoint-residue, and the requirement that Keil be closed for .uvoptx cleanup. No contradiction with annotations.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is long but front-loaded: core behavior first, then conditions, risk, parameter details, and aliases. Each section earns its place, and the structured headers make the dense information navigable for an agent.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a destructive tool with two optional booleans and a complex hardware/Keil interaction, the description covers prerequisites, failure modes, irreversible side effects, and parameter aliases. An output schema exists, so not detailing return values is acceptable; nothing critical is missing.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 0%, so the description carries the full burden, and it delivers: it documents include_uvoptx as clearing Keil-persisted .uvoptx breakpoints, hard as enabling FPB verification after BK *, lists aliases, and warns that unlisted parameter names are rejected. This fully compensates for the silent schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a specific verb and resource: '清除软件断点:清空本服务内部记录并逐个按确切地址发 BK', and distinguishes this all-breakpoints operation from sibling clear_breakpoint by the word '全部'. It also adds the optional .uvoptx cleanup target, making the tool's scope unambiguous.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description gives concrete conditions: include_uvoptx=True clears Keil-persisted breakpoints, clean .uvoptx requires Keil closed, and hard=True performs FPB verification after BK *. It also explains when reflashing is or is not needed. It does not explicitly name alternatives or when-not-to-use cases, so it falls just short of a 5.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
clear_breakpoint清除断点AIdempotent
清除断点。三种指定方式(任选其一):expr 传符号/地址;bp_id 传本服务内部 id;keil_number 传 Keil 界面/命令窗口 BL 里的真实断点编号。清除走命令窗口 BK:数据观察点按地址清不掉(BK <地址> 时 UVSOCK 回成功、窗口却报 error 72 invalid item number),必须按编号清除,故内部会自动把地址/符号解析成 Keil 编号再 BK <编号>,解析不出才回退按地址。bp_id 在本服务内无此 id 时会自动改按 Keil 真实编号处理并给出 note,不必再用 clear_all_*(hard=true) 一刀切。注意:清除断点同样走命令窗口并触发异步消息,清除后立即 run/step 前建议稍等。需已进入调试。 【参数】必填: 无;可选: expr, bp_id, keil_number 【调用示例】{} 【风险】中——会改变目标状态或占用共享资源(调试态/串口/Keil 实例),必要时可回退。 【参数别名】expr ← addr/address/expression/func/function/keyword/location/name/pattern/pc/query/symbol/target/var/variable;bp_id ← bp/breakpoint_id/id;keil_number ← keil_id/keil_no/num/number。规范名以上方【参数】行为准;未列出的参数名会被拒绝,不会静默忽略
| Name | Required | Description | Default |
|---|---|---|---|
| expr | No | ||
| bp_id | No | ||
| keil_number | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Beyond the annotations (readOnlyHint=false, destructiveHint=false), the description discloses critical behavioral details: the clearing happens via the BK command, data watchpoints cannot be cleared by address due to a Keil error, the tool automatically converts address/symbol to a Keil number with a fallback, unknown bp_id values trigger automatic fallback, and clearing triggers async messages. This is substantial transparency with no contradiction to annotations.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is long but densely packed with necessary edge-case knowledge. The first sentence front-loads the purpose, and the structure separates usage, risk, and aliases. The empty call example '{}' is a small waste, and the risk section partly echoes annotation information, but overall each segment earns its place.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The description covers all critical context: required debug state, all parameter modes, the watchpoint-clearing bug, automatic fallbacks, asynchronous message behavior, and a risk rating. Given that an output schema exists, no return-value description is needed, and there are no obvious gaps that would prevent an agent from invoking the tool correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Since schema description coverage is 0%, the description carries the full burden, and it delivers: it defines each parameter (expr for symbol/address, bp_id for internal service id, keil_number for Keil's actual breakpoint number), explains the fallback semantics, and documents parameter aliases while noting that unspecified names are rejected. This completely compensates for the bare schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's verb and resource: '清除断点' (clear breakpoint), and goes further by explaining the three ways to specify which breakpoint to clear. It distinguishes itself from the sibling clear_all_breakpoints by framing this as a targeted clear operation and explicitly advising against using clear_all_* for a single breakpoint.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description gives explicit usage guidance: three selection modes (expr, bp_id, keil_number), the prerequisite that debug must be entered, and a warning about async messages before issuing run/step. It also names the alternative clear_all_breakpoints and explains when not to use it (for a single breakpoint), making the choice between tools unambiguous.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
close_uvisionADestructive
关闭 Keil uVision 实例,配合 launch_uvision 实现 Keil 开关闭环。keep="all"(默认)关闭全部实例;keep="latest" / "oldest" 只保留一个实例(最新 / 最早启动的那个),其余关闭——用于把累积的多个同工程窗口收敛成一个,只开一个窗口调试。project 非空时只处理打开该工程的实例。force 默认 False:先优雅关闭(发送关闭消息),残留则自动强制终止;force=True 直接强制结束。返回 closed / kept / total_before / remaining。注意:会关闭 Keil 窗口(含人工查看中的),调用前确认无需保留。强制终止后立即重取进程列表可能短暂误报残留(本工具已轮询等待)。沙箱环境受权限/跨会话限制可能无法关闭,需在真实运行环境使用。 【参数】必填: 无;可选: force, keep, project 【调用示例】{} 【风险】高——不可逆:会改写目标 Flash/内存,或关闭/重启用户的 Keil 实例。执行前确认目标与工程正确。 【参数别名】force ← hard/kill;project ← path/proj/project_file/project_path/uvprojx;keep ← keep_one/keeponly/retain。规范名以上方【参数】行为准;未列出的参数名会被拒绝,不会静默忽略
| Name | Required | Description | Default |
|---|---|---|---|
| keep | No | all | |
| force | No | ||
| project | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Rich disclosure well beyond the annotations: warns that windows under manual viewing will be closed, details the graceful-close-then-force-terminate fallback flow for force=False, explains the polling wait to avoid false residue reports, flags sandbox permission/cross-session limitations, and labels the operation irreversible in the risk section. No contradiction with destructiveHint=true.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The core purpose is front-loaded and the flow from purpose to parameter behavior to return values is logical. The main paragraph is dense, and the risk section slightly repeats the window-closing warning already stated earlier. The call example is empty ({}), a minor missed opportunity given the parameter modes, but overall structure is organized and nearly all sentences earn their place.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Complete for a high-risk, mult-mode tool: covers all three optional parameters, return values (closed/kept/total_before/remaining, backed by an output schema), side effects on user-visible windows, edge cases (false residue after force kill), irreversible risk, and environment constraints. Nothing an agent needs to call it correctly is missing.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
With 0% schema description coverage, the description carries the full burden and compensates thoroughly: it explains the three keep values and their intent, force's default false→graceful→force escalation, and project's instance filtering. It also documents parameter aliases (force←hard/kill, project←path/proj/..., keep←keep_one/...) that help agents map variant names correctly.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
States a specific verb and resource ('Close Keil uVision instances') and explicitly pairs with launch_uvision to form a Keil on-off closed loop, which distinguishes it from its primary sibling. The keep semantics (all/latest/oldest) and project filtering make the exact scope unmistakable.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Explains when each keep mode should be used (converging accumulated same-project windows into one debug window) and when project-filtering applies. Names launch_uvision as the counterpart. It does not explicitly enumerate exclusions versus other siblings (e.g., restart_keil), but the pair relationship with launch_uvision gives sufficient routing context.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
diagnose一键诊断当前现场ARead-onlyIdempotent
聚合一次排查所需的所有现场信息:CPU 寄存器组(含 AAPCS 解读) + PC 处指令反汇编 + 源码上下文 + 完整调用栈 + 当前函数局部变量 + 指定关键全局变量,生成结构化现场报告。AI 接到 bug 报告后一次调用即可看清程序卡在哪、寄存器状态、正在执行什么指令、谁调进来的,避免多次 get_current_location/read_registers/disassemble/read_locals 往返。globals 可选,传关键全局变量名列表(数组或逗号/分号分隔字符串均可)。需已进入调试且配置 .axf。注意:聚合多个只读诊断,同样受中断上下文限制——停在 SysTick 中断/全速运行后手动 stop 时,局部变量与完整调用栈可能受限/为空。需已进入调试且配置 .axf。 【输出控制】本工具返回体可能较大,额外接受三个可选参数:compact=true(精简)/ max_lines=N(限制列表条数)/ full=true(强制全量)。默认都不传=行为不变;被裁掉的内容一定会在返回体的 output 字段里如实上报(truncated/dropped/trimmed/hint),不会静默丢数据。也可用环境变量 MDKDEBUG_COMPACT=1 / MDKDEBUG_MAX_LINES=N 设全局默认。 【参数】必填: 无;可选: globals, source_context, disasm_count, compact, max_lines, full 【调用示例】{} 【参数别名】globals ← expressions/exprs/names/variables/vars/watches;disasm_count ← code_lines/count/disasm。规范名以上方【参数】行为准;未列出的参数名会被拒绝,不会静默忽略
| Name | Required | Description | Default |
|---|---|---|---|
| full | No | 强制返回全量:忽略 compact/max_lines 与对应环境变量的默认值。当上面两项让你只看到部分数据、而你要据此下结论时,用它取回完整结果。 | |
| compact | No | 精简返回体:去掉空值字段,把列表元素中取值完全相同的字段提到 output.shared,并把 usage/note/hints 之类**说明性**长文本截断到 200 字符(数值与内容字段不动)。被裁掉的东西都会列在 output 里,绝不静默丢弃。不传则不改行为(受 MDKDEBUG_COMPACT 影响)。 | |
| globals | No | ||
| max_lines | No | 限制返回的列表条数(只作用于元素为对象的列表,如 results/items/tools):最多 N 条,其余丢弃并在 output.truncated/dropped/hint 里如实上报。0 或省略=不限(受 MDKDEBUG_MAX_LINES 影响)。 | |
| disasm_count | No | ||
| source_context | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations already declare readOnlyHint=true, idempotentHint=true, and destructiveHint=false. The description adds valuable behavioral context beyond that: it aggregates multiple read-only diagnostics, is subject to interrupt context limitations (locals/call stack may be empty), and never silently drops data (truncation is reported in output). It also discloses that unrecognized parameter names are rejected, not ignored. No contradiction with annotations.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is lengthy but well-structured with clear sections (purpose, limitations, output control, parameters, aliases). It front-loads the core purpose and includes necessary operational details without redundancy. Every sentence adds value, though the length is justified by the tool's complexity.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's complexity (6 optional parameters, output schema exists), the description covers purpose, prerequisites, limitations, output control behavior, and parameter aliases. The only gap is the unstated meaning of disasm_count and source_context, which are minor and inferable from context. The output schema handles return structure, so the description is largely complete for an agent to call it correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is only 50% (descriptions exist for full, compact, max_lines but not for globals, disasm_count, source_context). The description compensates partially: it explains globals (array or comma/semicolon string) and the output-control trio (compact/max_lines/full) in detail, but does not explain the semantics of disasm_count or source_context beyond their names and defaults. This is a moderate compensation, but not complete for all parameters.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool aggregates all on-site diagnostic information (registers, disassembly, source context, call stack, locals, globals) into a structured report. It explicitly names the alternatives it replaces (get_current_location/read_registers/disassemble/read_locals) and distinguishes itself as a one-call diagnostic aggregator, making its purpose unambiguous.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description explains when to use this tool: when an AI receives a bug report and needs a comprehensive snapshot in one call, avoiding multiple round trips. It also notes prerequisites (debug entered, .axf configured) and limitations (interrupt context may restrict locals/call stack). It doesn't explicitly say when NOT to use it, but the context and alternatives are clear enough for an agent to make a decision.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
dismiss_dialog读取并关闭阻塞 Keil 的模态对话框AIdempotent
把 Keil「有个模态框在挡路」补成「框里写什么、点哪个按钮」:枚举 UV4 的模态对话框(类名 #32770),读出正文(Static 控件)与全部按钮文字(Button 控件)并按按钮点击关闭。button 传按钮文字(如「确定」「重试」,支持部分匹配);不传则按 确定/OK/是/关闭/重试 的语义顺序自动挑,没有可点按钮时退化为 WM_CLOSE。title 可按标题筛(多个框时),index 取第几个(默认 0)。返回 {ok, dismissed, clicked, method, dialog{title,message,buttons}, remaining}。用法:命令不返回且 keil_health 报 modal_blocked_suspected=true 时调它——先看 dialog.message 知道 Keil 报了什么,再决定点哪个按钮,解除阻塞后重试原命令。注意:① 关框只解除阻塞,不等于问题已修(如正文说输出文件写不进去,要先解决占用/权限);② 指定 button 却匹配不到时不会擅自改点别的按钮,而是返回 button_not_found 并列出可用按钮。 【参数】必填: 无;可选: button, title, index 【调用示例】{} 【风险】中——会改变目标状态或占用共享资源(调试态/串口/Keil 实例),必要时可回退。
| Name | Required | Description | Default |
|---|---|---|---|
| index | No | ||
| title | No | ||
| button | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Even with annotations covering idempotency and non-destructiveness, the description adds meaningful behavioral detail: it extracts dialog text, auto-selects buttons by semantic order, falls back to WM_CLOSE, and returns button_not_found rather than silently clicking a different button. It also warns that dismissing the dialog does not fix the underlying problem, which is important context.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is dense but efficiently structured: the core behavior is front-loaded, parameters are explained inline, the return shape is included, and the warnings are compact. No sentence is redundant with the schema or annotations.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a tool with three optional parameters and an output schema, the description covers the triggering condition, parameter semantics, return fields, fallback behavior, and operational caveats. An agent has everything needed to invoke it correctly in the blocking-dialog scenario.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 0%, but the description fully compensates: button supports partial matching and auto-selection, title filters when multiple dialogs exist, and index selects which dialog to target. Every parameter is explained with behavior beyond its bare name and default value.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a specific action: enumerate UV4 modal dialogs, read their Static text and Button labels, and click a button to dismiss the blocking dialog. It clearly differentiates the tool from siblings like keil_command or restart_keil by targeting the modal-blocking scenario specifically.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description is explicit about when to use it: when a command does not return and keil_health reports modal_blocked_suspected=true. It also prescribes a workflow—read dialog.message first, choose a button, dismiss, then retry the original command—and explains the fallback behavior when no button matches.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
enter_debug进入调试模式AIdempotent
自动进入 Keil 调试模式(UV_DBG_ENTER)。若目标本来就在调试态(status=10 正在调试),不会报失败,而是返回 ok=true + already_in_debug=true + note,可省掉一轮 exit/enter;返回 ready/ready_waited_ms 表示已确认就绪。受工程 Load/Flash Download/Run-to-main 设置影响,属于有副作用的操作:若工程 Utilities 勾选了 Update Target before Debugging(.uvprojx 的 Utilities/Flash1/UpdateFlashBeforeDebugging=1),Keil 会在进入调试前自动把最新 .axf 下载进 Flash(等价一次烧录)——此时编译完直接 enter_debug 即可,不必先 flash_download;该选项为 0 时 Keil 不下载,板上可能仍是旧固件(可用 read_project_config 查该字段)。进入后即可设断点、读变量、运行控制。注意:若当前 Keil 是旧窗口、加载旧固件,进入后调试的是旧代码符号;建议改用 flash_debug 闭环(关旧Keil→编烧→重开→进调试)。受工程 Load/Flash Download/Run-to-main 设置影响,属有副作用操作。需 UVSOCK 已开启。真机实测:进入调试是异步的——命令返回成功时目标尚未挂载完成,约 0.6~0.7s 后才真正就绪,期间紧接的读内存/表达式/断点命令会返回 status=6(Target is not in debug mode)。本工具已自动轮询等待就绪(默认最多 6s),返回 ready 与 ready_waited_ms;若超时未就绪会给出 warning,此时先读内存会失败,请检查目标板连接或 Keil 是否弹窗待确认。看门狗防御(真机踩过):新会话/复位后 DBGMCU 的 IWDG/WWDG 冻结位会被清零,目标 halt 超过看门狗溢出时间(典型 1.626s)就会被看门狗复位、RAM 现场全丢。本工具默认在就绪后自动置位冻结位(freeze_watchdogs=true),返回 watchdog_freeze 供核对;万一失败会带 warning,此时请尽快手动调 watchdog_freeze(action="enable")。
【参数】必填: 无;可选: freeze_watchdogs
【调用示例】{}
【风险】中——会改变目标状态或占用共享资源(调试态/串口/Keil 实例),必要时可回退。
| Name | Required | Description | Default |
|---|---|---|---|
| freeze_watchdogs | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Beyond annotations (readOnlyHint=false, idempotentHint=true), the description discloses extensive behavioral details: async entry timing (~0.6-0.7s), automatic polling and ready status, watchdog freezing with fallback warning, and optional flash download side effects. It also warns about potential pitfalls like old symbol loading and suggests the flash_debug closed loop. This far exceeds what annotations provide.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is well-structured with sections and bold warnings, but it has notable redundancy: the sentence '受工程 Load/Flash Download/Run-to-main 设置影响,属于有副作用的操作' (or similar) appears twice, and the side-effect statement is repeated. While the detail is valuable, not every sentence earns its place, and the text could be tightened by ~15-20% without losing information.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's complexity (side effects, async behavior, watchdog interactions, failure modes), the description is remarkably complete. It covers return fields (ok, already_in_debug, ready, ready_waited_ms, watchdog_freeze), error conditions (status=6, timeout warnings), and recovery steps. Nothing essential is missing for correct invocation and interpretation.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
With schema coverage at 0% and only one parameter (freeze_watchdogs), the description fully compensates by explaining its purpose (freeze watchdog bits to prevent resets), the default behavior (auto-enable), and the failure handling (warning + manual call suggestion). This adds significant value beyond the bare Boolean type.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the action: automatically enters Keil debug mode (UV_DBG_ENTER). It distinguishes itself from siblings like exit_debug and flash_debug by explaining the entry mechanism and the alternative closed-loop workflow. The purpose is unambiguous and specific.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides explicit usage guidance: when to use (e.g., after compilation with UpdateFlashBeforeDebugging=1), when to avoid (if old firmware might be present, recommending flash_debug instead), and prerequisites (UVSOCK enabled). It also notes idempotent behavior when already in debug, saving an exit/enter cycle.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
env_check环境一致性体检(芯片 / SVD / 固件 / 符号 / D-Cache)ARead-onlyIdempotent
一键核对「工程与工具以为的目标」和「板上真实的目标」是否一致——跨仓库/跨板调试最毒的两类问题都在这里设防:①符号与板上固件不同源(PC 被解析成假符号);②SVD/内置寄存器表选错芯片(读出别的芯片布局下「看着像样」的值)。 输出包含:chip(实测 DBGMCU_IDCODE + CPUID 推出的型号/系列/置信度)、configured(工程 / 内置寄存器表 / 已加载 SVD 各自的系列,以及逐项 matched/mismatched/unknown 判定)、firmware_symbol(符号与板上固件的内容指纹比对)、dcache(D-Cache 是否使能)、last_flashed(本进程最近一次烧录的工程与 .axf)、problems / next_actions。 判据一律拿目标说话:读不到 IDCODE 就说 unknown,不拿工程配置冒充实测结果;allow_mismatch 只影响「后续外设工具要不要放行」,不改变这里的判定。 guard 字段告诉你器件守卫这次到底有没有生效:active=false 表示没能实测出芯片型号(多数是目标没在调试态),此时外设级读数没有型号核对保护,请自行核对型号——别把「体检没报错」当成「一定没问题」。 链路是懒连接的:只连 UVSOCK 不会进调试/停机/下载,可以放心先跑本工具看环境。 【参数】必填: 无;可选: project, link, content_check 【调用示例】{}
| Name | Required | Description | Default |
|---|---|---|---|
| link | No | auto | |
| project | No | ||
| content_check | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
It discloses important behavioral traits beyond the annotations: it reports 'unknown' when IDCODE cannot be read (not faking results), explains the guard field (active=false means no chip model verification), and warns that 'no error' does not guarantee correctness. It also clarifies that the tool is lazy-connected and won't alter debug state, complementing the readOnlyHint and idempotentHint annotations.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is long but well-structured, front-loading the core purpose, then detailing outputs, caveats, and finally parameters. It uses paragraphs and bullet points effectively, though it could be more concise while retaining the critical edge-case information.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a complex tool with detailed output fields and edge-case behaviors, the description is largely complete: it explains the output structure, safety, and failure modes. However, the lack of parameter explanations creates a gap for advanced usage, though the default call (empty object) is sufficient for the primary use case.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The description lists the optional parameters (project, link, content_check) but does not explain their purpose or effects. With schema description coverage at 0%, the agent receives no guidance on what these parameters control, making it hard to use them effectively beyond the default empty call.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description explicitly states the tool checks consistency between the expected target (from project/tools) and the actual target on the board, listing specific problem types (e.g., symbol/firmware mismatch, wrong SVD chip selection) and detailed output fields. It clearly distinguishes itself from sibling diagnostic tools like get_version or keil_command by serving a unique consistency-checking role.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides clear usage context (cross-repo/cross-board debugging, run first before debugging) and notes the lazy connection that safely avoids entering debug/stop/download. However, it does not explicitly mention when not to use it or compare it directly to alternative tools, leaving some inference to the agent.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
exit_debug退出调试模式AIdempotent
自动退出 Keil 调试模式(UV_DBG_EXIT)。注意:目标处于运行状态时退出会被拒(status=11),需先 stop 再 exit_debug。退出成功后会顺带释放宿主机串口监听占用的 COM 口(否则调试完了串口还占着,Keil 串口窗口/其他工具打不开,WinError=5);释放只放端口,已收日志仍保留、serial_read 继续可读,需要接着采集重新 serial_monitor_start() 即可。 【参数】无(直接调用) 【调用示例】{} 【风险】中——会改变目标状态或占用共享资源(调试态/串口/Keil 实例),必要时可回退。
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Beyond the annotations, the description discloses important behavioral details: rejection while the target is running, automatic release of the host COM port, retained logs, serial_read remaining readable, and the WinError=5 failure mode. It also labels the risk level, which is genuinely useful context.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is longer than minimal but every sentence carries operational value: precondition, error behavior, side effect, recovery, and risk. The section markers also make it scannable, though it could be tightened slightly.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a no-argument state-changing tool with an output schema, this description is complete: it covers when to call it, what to do first, what side effects occur, how to recover, and the risk profile. Nothing material needed for correct invocation is missing.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The tool has zero parameters and the schema documents this completely. The description reinforces it with '无(直接调用)' and an empty call example, which is sufficient for the no-parameter baseline.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description names a specific action and resource: 'automatically exit Keil debug mode (UV_DBG_EXIT)'. It also clearly distinguishes this from sibling operations like enter_debug, run, and stop by describing the exit transition and its side effects.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description gives clear usage context: stop the target first if it is running, otherwise exit is rejected with status=11. It also instructs the agent that serial_monitor_start() can be restarted if continued collection is needed, but it does not explicitly name alternative tools or state when not to use exit_debug.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_status查询调试/目标状态ARead-onlyIdempotent
查询当前调试状态:是否处于调试会话、目标是否在运行、以及 UVSOCK 状态码,并额外返回 symbol_file / symbol_mtime / symbol_stale(当前符号文件路径、时间戳,以及「符号是否已与本次调试会话不一致」——编译或烧录之后旧会话的符号即过期,继续求值会报 status 13 解析错误)与 serialization(串行化方式、并发竞争遥测、是否还有别的 mdkdebug 进程在抢同一 UVSOCK)。可用于判断可否安全读写内存。注意:UVSOCK 响应的 r_status 恒为 0,真实运行状态在 data 低字节(0=停止,1=执行中),本工具已正确解析。目标运行中可查状态,但此时不可安全读内存。 【参数】无(直接调用) 【调用示例】{}
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
The description adds substantial behavioral context beyond the readOnly/idempotent annotations: the UVSOCK r_status is always 0 and the real state is in the data low byte, symbol staleness semantics including status 13 errors, and serialization/concurrency telemetry about competing mdkdebug processes. These are non-obvious behaviors that an agent needs to interpret results correctly.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is longer than minimal but well-structured and front-loaded with the core purpose before diving into field-level detail. Every sentence adds useful information, including the UVSOCK quirk and memory-safety caveat, so the length is justified.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a zero-parameter tool with an output schema and strong annotations, the description covers all essential aspects: what is returned, what the returned fields mean, the notable UVSOCK parsing quirk, and when it is safe to act on the result. Nothing critical is missing.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The tool has zero parameters and the schema coverage is 100%. The description explicitly confirms there are no parameters and provides a direct call example, which is sufficient; baseline 4 applies because there are no parameter semantics to elaborate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly identifies the verb '查询' and the resource: current debug status, including session state, target running state, and UVSOCK status. It also specifies what the tool is useful for ('判断可否安全读写内存'), but it does not explicitly distinguish itself from siblings like session_state or target_info, so it stops short of full differentiation.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description gives clear usage context: it can be used to determine whether it is safe to read/write memory, and it warns that when the target is running, querying status is allowed but safe memory reads are not. It does not explicitly name alternative tools or state when not to use this one, so it earns a 4 rather than a 5.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_version查询调试插件版本ARead-onlyIdempotent
查询 Keil UVSOCK 插件的版本信息,返回十六进制版本串。注意:需 Keil 已启动且已开启 UVSOCK(Edit→Configuration→Other→UVSOCK Enabled→端口4823→重启Keil),否则连接失败并返回开启指引。 【参数】无(直接调用) 【调用示例】{}
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations already declare readOnly and idempotent behavior. The description adds meaningful behavioral context beyond that: the prerequisite of Keil/UVSOCK being active, and the failure mode where the tool returns enabling instructions instead of a version string.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is compact and front-loaded: purpose and return type first, followed by a necessary prerequisite note, then a structured parameter section. No redundant wording.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a zero-parameter read-only tool with an output schema, the description provides everything needed: what it returns, when it can succeed, and what happens on failure. The empty call example reinforces the no-argument contract.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
There are no parameters, and the schema covers 100% by being empty. The description explicitly states '无参数(直接调用)', which adds clarity beyond the empty schema and matches the baseline for a zero-parameter tool.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a specific verb ('查询') and resource ('Keil UVSOCK 插件的版本信息'), and adds the return format ('十六进制版本串'). This clearly differentiates it from sibling status/capability/session tools without requiring schema inspection.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description gives explicit operating context: Keil must be running and UVSOCK enabled, otherwise the call fails and returns setup guidance. It does not enumerate alternatives, but the usage context is clear and sufficient for this simple no-parameter tool.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
keil_command执行任意 Keil 命令窗口命令AIdempotent
把一条命令原样送进 Keil 命令窗口执行(走 UVSOCK 的 EXEC_CMD),并把命令窗口输出/报错一并带回来。本工具是「万能兜底」:当某个专用工具不覆盖你要的操作时,用官方命令直接做,不必等封装。
常用命令:BS <符号|地址> 下断点、BK <编号> 删断点、BL 列断点、BK * 全清、G 运行、G, main 运行到 main、T 单步(进)、P 单步(过)、O 单步(出)、EVAL <表达式> 求值、WS <变量> 加观察、RESET 复位、_RDWORD(0x地址) 读 32 位内存、printf("fmt", x) 打印到命令窗口、LOG >>文件 / LOG OFF 把命令窗口输出落盘。
三条真机实测的坑(务必看):
单步的官方缩写是
T/P/O;写Step/Tstep/Pstep会回*** error 34: undefined identifier(无窗口焦点时单步会退化成指令级,不进源码级)。命令报错不会反映在 UVSOCK 的 status 上(Keil 恒回 status=0)——本工具已解析命令窗口的
*** error N: message并自动给出错误码含义,判断成败请看返回里的 ok / errors,不要只看 status。一次只能一条命令(含换行/回车会被拒),多步请用 batch 或 batch_debug_script。 返回:ok / status / console(命令窗口新增行)/ errors(含 code+meaning+fix)/ reply。高风险:
BK *、RESET、G等会改变目标运行状态。 【参数】必填: command;可选: settle_ms, explain_errors 【调用示例】{"command": ""} 【风险】中——会改变目标状态或占用共享资源(调试态/串口/Keil 实例),必要时可回退。
| Name | Required | Description | Default |
|---|---|---|---|
| command | Yes | ||
| settle_ms | No | ||
| explain_errors | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations already say readOnlyHint=false and destructiveHint=false, and the description goes well beyond them: it discloses that UVSOCK status is unreliable, that errors must be read from ok/errors fields, that newlines/repeated commands are rejected, and that commands like BK *, RESET, and G change target state. There is no direct contradiction with annotations, though idempotentHint=true is optimistic for arbitrary commands like G.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Long but information-dense: core behavior is front-loaded, followed by a compact command cheat-sheet, three real-device pitfalls, return shape, risk note, and parameters. Each section earns its place and the formatting makes scanning easy.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given a low parameter count, no enums, and an existing output schema, the description covers invocation, return values, error semantics, risk, and alternatives. Nothing an agent needs to decide whether to call it and how to interpret the result is missing.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
With 0% schema description coverage, the description needed to compensate. It richly documents the command parameter with examples and valid syntax, but settle_ms and explain_errors are only listed as optional, with semantics left to inference from their names and defaults. This is acceptable for optional tuning parameters but not fully explicit.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Description states exact mechanism: send one raw command verbatim to Keil command window via UVSOCK EXEC_CMD and return output/errors. It also frames itself as a catch-all fallback when dedicated tools do not cover the operation, which clearly distinguishes it from specialized siblings.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Explicitly says to use this tool when dedicated tools do not cover the operation, warns that only one command at a time is accepted, and routes multi-step workflows to batch or batch_debug_script. It also lists high-risk commands, advising caution.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
keil_healthARead-onlyIdempotent
检查 Keil 调试通道的健康状态:UV4 进程是否存在、UVSOCK 端口是否监听、是否有模态对话框阻塞。返回 keil_alive / uv4_pids / port / port_listening / uvsock_ready / code / diagnosis / suggestion;mdkdebug_instances 给出串行化方式、并发竞争遥测(等待次数/最长等待/锁超时)与其他仍在驱动同一 UVSOCK 的 mdkdebug 进程(多个实例并存会互相穿插、静默吃掉写入,这是最隐蔽的一类故障);检测到 Keil 模态框时一并给出modal_dialogs[{title, message, button_texts}]——正文与可点按钮都有,知道框里写了什么、该点哪个(配套 dismiss_dialog 直接关框,不必再去界面手点)。用途:命令超时或「操作了没反应」时先调它,直接看清断在哪一环(keil_not_running / port_not_listening / port_occupied),而不是干等到超时;也可作为操作前后的廉价自检(纯 ctypes + socket 探测,Keil 未运行时也能正常返回)。 【参数】无(直接调用) 【调用示例】{}
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations already mark it read-only/idempotent/non-destructive, and the description adds meaningful operational facts: it is a pure ctypes+socket probe, safe even when Keil is absent, and it surfaces concurrency hazards from multiple mdkdebug instances that silently eat writes. It also details modal dialog output content, going well beyond annotation hints.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is long but front-loaded with the main check purpose and then layers return fields, failure modes, and usage guidance. Each section adds non-redundant operational value, with an explicit parameter note and example at the end.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a no-parameter health probe with annotations and an output schema, the description covers the diagnostic fields (including mdkdebug_instances contention data and modal_dialogs), the precise failure modes, and when to invoke it. There is no missing information an agent would need to select and call it correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The tool has zero parameters and the schema is empty; the description explicitly states 【参数】无(直接调用) and shows an empty call example. This removes any doubt that invocation requires no arguments, so the description is fully sufficient.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description opens with a specific verb and resource ('检查 Keil 调试通道的健康状态') and enumerates exactly what is probed: UV4 process, UVSOCK port, and modal dialog blocking. It distinguishes itself from generic siblings by defining its scope as health/diagnosis of the debug channel rather than command execution or environment setup.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
It gives explicit trigger conditions: call first when a command times out or appears unresponsive, and use as a cheap pre/post-operation self-check. It also clarifies that it remains useful even when Keil is not running, but it does not name exclusions or alternative sibling tools, so a 4 rather than 5.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
launch_uvisionA
可见方式启动 Keil uVision 并打开工程,供人工查看界面 / 调试准备。project 为 .uvprojx 路径,可省略以用默认工程。reuse(默认 true):已有打开同一工程的 Keil 窗口时复用该窗口并前置,不新开——真机实测 UV4.exe 并非单实例程序,反复调用本工具会累积出多个同工程窗口(曾达 6 个),因此默认复用;确需第二个窗口时才传 reuse=false。single(默认 true)=「只保留一个 Keil 窗口」的执行者:已经开着别的工程的窗口时直接拒绝(error_code=keil-multiple-instances,返回 open_instances 与下一步),不做「偷偷关掉再开」;已经开着同工程窗口时强制复用(reuse=false 也被否决,返回 reuse_forced=true);本次没给 project 且已有实例同样拒绝(无从比对就不猜)。确实要同时开多个窗口才传 single=false。返回值含 reused / pid / instances(当前同工程窗口数)。用户无需手动打开 Keil,AI 可通过本工具拉起;想看当前开了几个窗口用 list_uvision_instances,想把多余的收掉用 close_uvision(keep="latest")。uvsock_port:传端口号则给这次启动加官方开关 -s <端口>,让新实例在该端口上开 UVSOCK——当用户的 Keil 里 UVSOCK 没打开/端口被改过时,光拉起 Keil 仍连不上,这个参数能一步到位(注意 MCP 服务自身的 UVSOCK 端口也要一致)。no_layout=true 加 -sg 禁用 uvguix 布局文件:用户改过窗口布局、布局文件损坏导致 UV4 起得极慢或报错时用它绕开。
【参数】必填: 无;可选: project, reuse, uvsock_port, no_layout, single
【调用示例】{}
【风险】中——会改变目标状态或占用共享资源(调试态/串口/Keil 实例),必要时可回退。
【参数别名】project ← path/proj/project_file/project_path/uvprojx。规范名以上方【参数】行为准;未列出的参数名会被拒绝,不会静默忽略
| Name | Required | Description | Default |
|---|---|---|---|
| reuse | No | ||
| single | No | ||
| project | No | ||
| no_layout | No | ||
| uvsock_port | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Goes well beyond annotations: discloses that UV4.exe is not single-instance, repeated calls accumulate windows (observed up to 6), explains default reuse behavior, single-mode rejection logic with error_code and return fields (reuse_forced, instances), and the medium risk of changing target state or occupying shared resources. Annotations only provide flags; this gives concrete side effects and safeguards.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Though long, every sentence adds critical detail: purpose is front-loaded, then parameter semantics, return values, alternatives, risk, and aliases. Bold and structured formatting aid scannability. The empty call example is harmless and not redundant.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a tool with 5 optional parameters, no required params, no schema descriptions, and non-trivial multi-instance behavior, the description covers all parameter semantics, defaults, return values (reused/pid/instances), error behavior, risk, and prerequisite caveats (uvsock port alignment). It is self-sufficient for an agent to select and invoke correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 0%, so description fully compensates: each parameter (project, reuse, single, uvsock_port, no_layout) is explained with its default, purpose, and concrete effect (uvsock_port adds `-s <port>`, no_layout adds `-sg`). Also documents parameter aliases and that unlisted parameter names are rejected.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Description states a specific action ('launch Keil uVision and open project visibly for manual UI viewing/debug preparation'), names the resource (.uvprojx project), and distinguishes itself from siblings like list_uvision_instances and close_uvision which are for inspecting and closing windows, not launching.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Provides explicit when-to-use guidance: 'AI can launch via this tool', and routes to alternatives: 'to see how many windows are open use list_uvision_instances, to clean up excess use close_uvision(keep="latest")'. Also details precise conditions for reuse=false, single=false, uvsock_port, and no_layout.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
list_breakpoints列出断点ARead-onlyIdempotent
列出断点。返回两部分:① 本服务内部记录(breakpoints/内部 id,用于按 bp_id 清除);② real 字段——本会话 Keil 的真实断点表(解析命令窗口 BL 输出获得,含 Keil 断点编号、类型 exec/access、地址、CNT、enabled)。注意:真机实测本版 Keil 的 CNT 是断点的计数条件设置值(.uvoptx 的 break_if_rcount),不随命中递增,不能当命中次数用。real 才是板上实际生效的断点:.uvoptx 持久化断点、数据观察点都会出现在这里。注意清除数据观察点必须按 Keil 编号(按地址会报 error 72)。另附 uvoptx 字段暴露工程里 BK 清不掉、下次进调试会自动恢复的持久化断点。③ hardware 字段:直接读 Cortex-M 的硬件断点单元 FPB(FP_CTRL@0xE0002000 / FP_COMP0@0xE0002008),给出 check(clean/residue/unavailable)、启用的比较器与地址。real 是 Keil 的逻辑表、hardware 是硬件里实际写着的项——两者是两回事:BK * 之后 real 可能为空、FPB 里却还留着,J-Link 会一直报 "two breakpoints at the same address"。hardware.orphans 给出「硬件里有、real 里查不到」的地址(这类就是清不掉的残留);读不到 FPB 时为 unavailable,不当作「干净」(没测 ≠ 没有)。 【输出控制】本工具返回体可能较大,额外接受三个可选参数:compact=true(精简)/ max_lines=N(限制列表条数)/ full=true(强制全量)。默认都不传=行为不变;被裁掉的内容一定会在返回体的 output 字段里如实上报(truncated/dropped/trimmed/hint),不会静默丢数据。也可用环境变量 MDKDEBUG_COMPACT=1 / MDKDEBUG_MAX_LINES=N 设全局默认。 【参数】必填: 无;可选: compact, max_lines, full 【调用示例】{}
| Name | Required | Description | Default |
|---|---|---|---|
| full | No | 强制返回全量:忽略 compact/max_lines 与对应环境变量的默认值。当上面两项让你只看到部分数据、而你要据此下结论时,用它取回完整结果。 | |
| compact | No | 精简返回体:去掉空值字段,把列表元素中取值完全相同的字段提到 output.shared,并把 usage/note/hints 之类**说明性**长文本截断到 200 字符(数值与内容字段不动)。被裁掉的东西都会列在 output 里,绝不静默丢弃。不传则不改行为(受 MDKDEBUG_COMPACT 影响)。 | |
| max_lines | No | 限制返回的列表条数(只作用于元素为对象的列表,如 results/items/tools):最多 N 条,其余丢弃并在 output.truncated/dropped/hint 里如实上报。0 或省略=不限(受 MDKDEBUG_MAX_LINES 影响)。 |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations already mark the operation read-only, idempotent, and non-destructive, and the description adds substantial behavioral context beyond that: it warns that CNT is not a hit counter, that unavailable FPB reads must not be treated as clean, that orphaned hardware breakpoints can persist after BK *, and that truncated output is always reported rather than silently dropped.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The content is well organized into numbered sections and front-loaded with the main return structure, but it is quite long and includes tangential notes (e.g., how clear_breakpoint must use Keil numbers) and an internal inconsistency ('返回两部分' followed by three parts). Every sentence is informative, yet the description would benefit from tightening.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a complex read-only inspection tool, the description covers the internal, Keil, hardware, and persistence views, explains output-control behavior and truncation honesty, and supplies caveats needed to interpret results correctly. With an output schema present and annotations covering safety, no essential calling or interpretation information is missing.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100%, and each optional parameter already has a rich description explaining its effect and interaction with environment variables. The description repeats some of this in the output-control section, but per the rubric the schema does the heavy lifting, so no more than the baseline 3 is warranted.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description opens with a clear verb+resource statement ('列出断点') and enumerates the distinct result sections (internal records, Keil real table, and hardware FPB state), so an agent knows exactly what this tool returns. It separates this from set/clear breakpoint tools by focusing on inspection and even calls out Keil-vs-hardware domains.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The intended use as the read-only inspection counterpart to set_breakpoint/clear_breakpoint is implied rather than stated; there is no explicit when-to-use or when-not-to-use guidance versus siblings. The rich interpretation guidance (real vs hardware vs uvoptx) helps an agent understand results, but not when to choose this tool over an alternative.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
list_symbol_projects列出预登记候选符号工程ARead-onlyIdempotent
返回预登记的可切换符号工程(如 SVCRTOS_TEST 内核、mdk_test),含 .axf/.map 路径与 flash 地址段。AI 据此了解可切换的符号目标,并可与 set_symbol_file 配合把符号切到当前调试固件。flash 段用于 PC 自动匹配(辅助)。注意:仅列出本机存在的候选。 【输出控制】本工具返回体可能较大,额外接受三个可选参数:compact=true(精简)/ max_lines=N(限制列表条数)/ full=true(强制全量)。默认都不传=行为不变;被裁掉的内容一定会在返回体的 output 字段里如实上报(truncated/dropped/trimmed/hint),不会静默丢数据。也可用环境变量 MDKDEBUG_COMPACT=1 / MDKDEBUG_MAX_LINES=N 设全局默认。 【参数】必填: 无;可选: compact, max_lines, full 【调用示例】{}
| Name | Required | Description | Default |
|---|---|---|---|
| full | No | 强制返回全量:忽略 compact/max_lines 与对应环境变量的默认值。当上面两项让你只看到部分数据、而你要据此下结论时,用它取回完整结果。 | |
| compact | No | 精简返回体:去掉空值字段,把列表元素中取值完全相同的字段提到 output.shared,并把 usage/note/hints 之类**说明性**长文本截断到 200 字符(数值与内容字段不动)。被裁掉的东西都会列在 output 里,绝不静默丢弃。不传则不改行为(受 MDKDEBUG_COMPACT 影响)。 | |
| max_lines | No | 限制返回的列表条数(只作用于元素为对象的列表,如 results/items/tools):最多 N 条,其余丢弃并在 output.truncated/dropped/hint 里如实上报。0 或省略=不限(受 MDKDEBUG_MAX_LINES 影响)。 |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations already declare readOnlyHint and idempotentHint, and the description adds substantial operational context: output can be large, compact/max_lines/full control output size, truncation is always reported in the output field, and environment variables set global defaults. This goes well beyond the annotation metadata and contains no contradictions.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is longer than average, but it is well-structured with clear sections for purpose, output control, parameters, and an invocation example. The main purpose and caveat are front-loaded, and every block contributes actionable information.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
With an output schema present, the description does not need to enumerate return fields. It covers the purpose, returned content, companion tool, local-only limitation, output-size controls, truncation reporting, and environment variables — everything an agent needs to invoke this tool correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, and each parameter already has detailed descriptions. The description adds a concise operational summary, the default 'do nothing' behavior when omitted, and the environment-variable fallback, which slightly exceeds the schema without duplicating it wholesale.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a specific verb ('返回') and resource ('预登记的可切换符号工程'), and details the returned content (.axf/.map paths and flash address ranges). It also distinguishes the tool's role from siblings by explicitly linking it to set_symbol_file as a companion for switching symbol targets.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
It clearly explains when to use this tool: to discover switchable symbol projects on the local machine and to prepare for switching symbols with set_symbol_file. It notes the local-only caveat but does not explicitly name alternatives or state when not to use it, so it falls short of a 5.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
list_tools列出全部工具与必填参数ARead-onlyIdempotent
一次列出本服务的全部工具:名称、用途、必填/可选参数与最小调用示例(example_args 可直接照抄成 args)。AI 冷启动、或不确定某工具准确参数名时先调它——本服务的参数命名不统一(有 query/expr/addr/n_bytes 等),只靠 'Field required' 报错试错代价高;这里一次就能对齐。keyword 按工具名或用途子串过滤(如 keyword="breakpoint"、"mem"、"断点"),留空返回全部。 【输出控制】本工具返回体可能较大,额外接受三个可选参数:compact=true(精简)/ max_lines=N(限制列表条数)/ full=true(强制全量)。默认都不传=行为不变;被裁掉的内容一定会在返回体的 output 字段里如实上报(truncated/dropped/trimmed/hint),不会静默丢数据。也可用环境变量 MDKDEBUG_COMPACT=1 / MDKDEBUG_MAX_LINES=N 设全局默认。 【参数】必填: 无;可选: keyword, compact, max_lines, full 【调用示例】{} 【参数别名】keyword ← filter/name/query/search。规范名以上方【参数】行为准;未列出的参数名会被拒绝,不会静默忽略
| Name | Required | Description | Default |
|---|---|---|---|
| full | No | 强制返回全量:忽略 compact/max_lines 与对应环境变量的默认值。当上面两项让你只看到部分数据、而你要据此下结论时,用它取回完整结果。 | |
| compact | No | 精简返回体:去掉空值字段,把列表元素中取值完全相同的字段提到 output.shared,并把 usage/note/hints 之类**说明性**长文本截断到 200 字符(数值与内容字段不动)。被裁掉的东西都会列在 output 里,绝不静默丢弃。不传则不改行为(受 MDKDEBUG_COMPACT 影响)。 | |
| keyword | No | ||
| max_lines | No | 限制返回的列表条数(只作用于元素为对象的列表,如 results/items/tools):最多 N 条,其余丢弃并在 output.truncated/dropped/hint 里如实上报。0 或省略=不限(受 MDKDEBUG_MAX_LINES 影响)。 |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations already declare readOnlyHint=true, idempotentHint=true, destructiveHint=false, so the safety profile is covered. The description adds substantial behavior beyond that: output can be large, truncation (compact/max_lines/full) is always reported in the output field and never silently dropped, env-var defaults (MDKDEBUG_COMPACT/MDKDEBUG_MAX_LINES) influence behavior, and unlisted parameter names are rejected rather than silently ignored. This is exactly the kind of disclosure that prevents agent confusion.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Well-structured with clear section headers (【输出控制】【参数】【调用示例】【参数别名】) and front-loaded purpose. It is fairly long, but every section earns its place: output control, parameter clarity, and alias handling all prevent real agent errors. No filler.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Very complete for a meta-tool: purpose, when to use, output-control behavior, truncation reporting, env-var influence, parameter list, call example, and aliases are all covered. An output schema exists so return values need not be explained. No material gaps remain for an agent to call this correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 75%; keyword has no description in the schema (only a 'Keyword' title), but the description adds filtering semantics (substring match on tool name or purpose) with concrete examples ('breakpoint', 'mem', '断点') and aliases (filter/name/query/search). It also reinforces compact/max_lines/full semantics beyond the schema. Good compensation for the keyword gap.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
States a specific verb+resource+scope: '一次列出本服务的全部工具' (lists all tools of this service with name, purpose, required/optional params, and minimal call examples). It is unambiguously the meta/listing tool, clearly distinguished from the 40+ individual sibling tools. The cold-start purpose is explicit.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Explicitly states when to call: 'AI 冷启动、或不确定某工具准确参数名时先调它' (call first on cold start or when unsure of exact parameter names), with the rationale that parameter naming is inconsistent and trial-and-error with 'Field required' errors is costly. It does not enumerate explicit when-not-to-use cases, but for a listing tool the guidance is concrete and actionable.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
list_uvision_instancesARead-onlyIdempotent
列出当前所有 Keil uVision 实例:PID、启动时间、打开的工程、是否有窗口。用于确认是否残留了多个同工程窗口——UV4.exe 并非单实例程序,反复 launch_uvision / flash_debug 会累积实例而互不回收(真机上曾同时开着 6 个同工程窗口)。project 可选:只统计打开该工程的实例。count>1 时返回 note 提示收敛方式。收敛为一个窗口:close_uvision(keep="latest")。 【参数】必填: 无;可选: project 【调用示例】{} 【参数别名】project ← path/proj/project_file/project_path/uvprojx。规范名以上方【参数】行为准;未列出的参数名会被拒绝,不会静默忽略
| Name | Required | Description | Default |
|---|---|---|---|
| project | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Beyond the annotations (readOnlyHint, idempotentHint, destructiveHint), the description reveals the non-single-instance behavior of UV4.exe, potential instance accumulation, the note generated when count>1, and rejection of unrecognized parameters. This is meaningful behavioral context not otherwise available.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is long but efficiently ordered—purpose first, then use case, parameter details, and aliases. The anecdote about six instances is slightly extra but reinforces the problem domain. Every sentence contributes; there is no filler or redundant restating of the schema.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given that an output schema exists, the description covers the returned fields (PID, start time, project, window), the note behavior when count>1, and the optional projector filter. It also references the follow-up action close_uvision. This is sufficient for an agent to understand the tool's behavior and interpret its results.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 0%, so the description fully compensates: it defines the optional project parameter as a filter on the opened project, lists accepted aliases (path/proj/project_file/project_path/uvprojx), and explicitly states that unspecified parameter names are rejected. This gives the agent complete guidance for correct invocation.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a specific verb+resource: list all current Keil uVision instances with details (PID, start time, opened project, window presence). It also explains its purpose—checking for residual duplicate project windows—which distinguishes it from sibling tools like launch_uvision or close_uvision.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
It gives clear context: use when you need to confirm whether multiple project windows remain after repeated launches. It mentions the convergence action close_uvision(keep='latest') when count>1. It doesn't explicitly state exclusions (e.g., when not to use), but the read-only inspection role is implied and clear.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
mdk_guide环境自检与调试工作流引导ARead-onlyIdempotent
AI 落地的第一个工具:一键自检 Keil/UVSOCK/UV4/.axf/源码漂移/调试态/RTOS 类型,并返回推荐的调试工作流与各场景应调用的工具,避免 AI 盲目试错。返回 {environment:{...}, recommended_workflow:[...], scene_tools:{...}}。注意:建议 AI 落地第一件事先调本工具获取环境自检与工作流,再按场景选择工具;自检为无副作用只读操作,可在任意时刻调用。topic=tool, name=<工具名> 取回该工具被挪出上下文的完整说明(为省上下文,长描述在工具列表里只留一句话摘要,正文全文存在这里);topic=tool 不带 name 则列出全部已归档工具与描述档位。 【输出控制】本工具返回体可能较大,额外接受三个可选参数:compact=true(精简)/ max_lines=N(限制列表条数)/ full=true(强制全量)。默认都不传=行为不变;被裁掉的内容一定会在返回体的 output 字段里如实上报(truncated/dropped/trimmed/hint),不会静默丢数据。也可用环境变量 MDKDEBUG_COMPACT=1 / MDKDEBUG_MAX_LINES=N 设全局默认。 【参数】必填: 无;可选: topic, name, compact, max_lines, full 【调用示例】{}
| Name | Required | Description | Default |
|---|---|---|---|
| full | No | 强制返回全量:忽略 compact/max_lines 与对应环境变量的默认值。当上面两项让你只看到部分数据、而你要据此下结论时,用它取回完整结果。 | |
| name | No | ||
| topic | No | ||
| compact | No | 精简返回体:去掉空值字段,把列表元素中取值完全相同的字段提到 output.shared,并把 usage/note/hints 之类**说明性**长文本截断到 200 字符(数值与内容字段不动)。被裁掉的东西都会列在 output 里,绝不静默丢弃。不传则不改行为(受 MDKDEBUG_COMPACT 影响)。 | |
| max_lines | No | 限制返回的列表条数(只作用于元素为对象的列表,如 results/items/tools):最多 N 条,其余丢弃并在 output.truncated/dropped/hint 里如实上报。0 或省略=不限(受 MDKDEBUG_MAX_LINES 影响)。 |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations already cover read-only and idempotent. The description adds concrete behavioral details beyond annotations: it mentions that the return body may be large, that truncation reports dropped/trimmed/hints without silent loss, and that it can be called at any time without side effects. This enriches the safety and operational context.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is long but well-structured with explicit sections (【输出控制】,【参数】,【调用示例】). It front-loads the core purpose in the first sentence and avoids redundancy. The length is justified by the tool's complexity, and the information is compactly organized without redundant padding.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's complexity (5 optional params, rich output, truncation logic), the description covers the essential use cases, parameter behavior, output fields, and environment variables. An output schema also exists, reducing the need to describe return types. Minor gaps like error handling are acceptable for a well-scoped guide tool.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The description explains all five parameters in prose (topic, name, compact, max_lines, full) including usage examples and the behavior of environment variables. Since schema coverage is only 60% and name/topic lack schema descriptions, the description compensates well, explaining the semantics of topic=tool with and without name.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a specific verb+resource: it performs environment self-check and returns a recommended debug workflow plus scene-specific tools. It clearly differentiates itself from sibling tools by focusing on the diagnostic/workflow guidance, not just a single check (env_check) or viewer (view_guide).
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
It explicitly advises to call this tool first as an AI landing step, before selecting other tools. However, it does not name alternative tools or give explicit 'when not to use' conditions. The instruction is clear but lacks comparative routing against specific siblings.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
read_async_messages读取异步消息/报错ARead-onlyIdempotent
读取 Keil 异步消息与报错信息,来自 UVSOCK 推送的 UV_ASYNC_MSG(0x4000)。包含命令执行状态(status)与报错文本(如 '*** error 34: undefined identifier'、编译/烧录/调试失败的弹窗报错内容),用于闭环捕获 Keil 侧错误。clear 可选清空缓存。注意:报错为异步推送,先执行可能出错的操作再读;status 为 Keil 返回的错误码。 【参数】必填: 无;可选: clear 【调用示例】{} 【参数别名】clear ← drain/flush/reset。规范名以上方【参数】行为准;未列出的参数名会被拒绝,不会静默忽略
| Name | Required | Description | Default |
|---|---|---|---|
| clear | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
The description says clear optionally clears the cache, which modifies state, directly contradicting the readOnlyHint annotation that marks the tool as read-only. While it adds useful async context and error-code details, the contradiction makes the behavioral transparency score a 1.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is compact but information-dense, front-loading the core purpose and then adding structured parameter and alias notes. A slight redundancy exists between the prose and the parameter section, but it remains efficient.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The description covers what is read, when to read, the optional clear behavior, and the nature of the return content. Given the tool's simplicity and the presence of an output schema, it is mostly complete, though the readOnlyHint contradiction leaves a gap in behavioral expectations.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
With schema description coverage at 0%, the description fully compensates by explaining clear as an optional cache-clearing flag, listing aliases (drain/flush/reset), and noting that unlisted parameter names are rejected. This is complete for the single boolean parameter.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a specific verb and resource—reading Keil async messages/errors from UVSOCK, including status and error text. It clearly distinguishes this from sibling tools like read_console_output by naming the source and content type.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description gives clear context: use it after performing a potentially failing operation because errors are pushed asynchronously. It also states the purpose (capturing Keil-side errors), but it does not explicitly name alternatives or when not to use the tool.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
read_console_output读取命令窗口输出ARead-onlyIdempotent
读取 Keil 命令窗口(Command)的调试输出,来自 UVSOCK 推送的 UV_DBG_CMD_OUTPUT(0x5020) 异步消息。执行 EXEC_CMD / BL / EVAL / 断点 等命令后,其输出(如断点列表、EVAL 结果、printf 调试打印、错误行)通过本工具读取,实现调试信息闭环。clear 可选清空缓存。注意:输出为异步推送,需先执行命令再读;每次发送请求前会自动收集堆积的异步帧。 【参数】必填: 无;可选: clear 【调用示例】{} 【参数别名】clear ← drain/flush/reset。规范名以上方【参数】行为准;未列出的参数名会被拒绝,不会静默忽略
| Name | Required | Description | Default |
|---|---|---|---|
| clear | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations already mark the operation read-only and non-destructive, but the description adds meaningful behavior beyond that: output arrives via async push, accumulated frames are automatically collected before each request, and clear empties the cache. This materially helps an agent predict timing and side effects.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is front-loaded with the core purpose, then covers timing, parameter semantics, and aliases in a structured way. It repeats some schema information in the parameter section, but that redundancy is minor and the section layout helps scannability.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given this is a one-parameter, low-complexity read tool with an output schema available, the description covers the essential operational context: when to call it, how async output behaves, how caching works, and how to clear it. Nothing critical is missing for the agent to invoke it correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema only defines clear as a boolean with default false and no description (0% coverage). The description compensates by explaining that clear optionally clears the cache and listing aliases (drain/flush/reset), which is sufficient semantic guidance for this single parameter.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a specific verb and resource: reading Keil Command window debug output. It further identifies the exact async source message (UV_DBG_CMD_OUTPUT 0x5020) and the execution contexts that produce output, distinguishing it from generic siblings like read_async_messages or read_variable.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
It explicitly explains when to use the tool: after EXEC_CMD / BL / EVAL / breakpoint commands, and warns that output is async, so commands must be run first. It does not name alternative tools or state when not to use this tool, but the usage context is clear enough for an agent to route correctly.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
read_mem读取目标内存ARead-onlyIdempotent
从指定内存地址读取 n_bytes(别名 length,二者传其一)个字节。addr 支持十六进制(如 '0x20000000')、十进制,或符号名(如 'SystemCoreClock'、'svcrt_task_table'——自动查当前 .axf 符号表解析,命中时返回 addr_note 说明来源);读 App 侧符号可传 reloc_delta="0xF000"(或先用 set_reloc_delta 设全局),工具会把符号的链接地址偏到运行地址;显式数字地址不会被偏移;返回十六进制字节串及 ASCII 视图。脏读防护(verify,默认 "auto"):stop 之后紧跟的第一次读可能整帧返回全 0(真机实测 0x08022000 读出 16 个 00,重读即正确)——auto 会在「首帧整帧退化(全 0x00/全 0xFF)或距最近一次 stop 不足 1 秒」时自动复读,连续两次一致才采纳,并返回 read_confidence(high/low)、reread_count、reread_consistent、degenerate、since_stop_s;首帧是脏值时用 first_read_hex 留证、data_hex 换成可靠值并给 warning。verify=true 总是复读(强制确认),verify=false 关闭(大块搬运省时间);verify 可传字符串也可传 JSON 布尔(true/false 等价于 "true"/"false")。运行态读取(running,默认 "live"):目标全速运行时也能读(真机实测 SRAM 与外设寄存器都读得到,不必先 stop);运行态一律多复读一轮,两次不一致时给read_confidence=medium + read_unstable=true + while_running,并把「该地址本来就在被 CPU改写」与「这次读被运行中的目标打断了」两种可能都写明(不替你选一个)。要取某一瞬间的一致快照,用 running="halt"(停-读-走):会暂停目标再恢复,返回paused_ms / was_running / resumed / halt_note 如实交代代价,恢复失败会告警。**看到 read_confidence="low"/"medium" 或 degenerate 时不要据此下结论(例如「读到 0 就判定变量被清零」)。**勿越界读外设保留区,可先 query_memory_map 确认范围。 【输出控制】本工具返回体可能较大,额外接受三个可选参数:compact=true(精简)/ max_lines=N(限制列表条数)/ full=true(强制全量)。默认都不传=行为不变;被裁掉的内容一定会在返回体的 output 字段里如实上报(truncated/dropped/trimmed/hint),不会静默丢数据。也可用环境变量 MDKDEBUG_COMPACT=1 / MDKDEBUG_MAX_LINES=N 设全局默认。 【参数】必填: addr, n_bytes;可选: length, reloc_delta, verify, running, compact, max_lines, full(别名:n_bytes 也可写作 length) 【调用示例】{"addr": "0x20000000", "n_bytes": 16} 【参数别名】addr ← address/expression/location/name/pc/symbol/target;n_bytes ← bytes/count/nbytes/size。规范名以上方【参数】行为准;未列出的参数名会被拒绝,不会静默忽略
| Name | Required | Description | Default |
|---|---|---|---|
| addr | Yes | ||
| full | No | 强制返回全量:忽略 compact/max_lines 与对应环境变量的默认值。当上面两项让你只看到部分数据、而你要据此下结论时,用它取回完整结果。 | |
| length | No | ||
| verify | No | auto | |
| compact | No | 精简返回体:去掉空值字段,把列表元素中取值完全相同的字段提到 output.shared,并把 usage/note/hints 之类**说明性**长文本截断到 200 字符(数值与内容字段不动)。被裁掉的东西都会列在 output 里,绝不静默丢弃。不传则不改行为(受 MDKDEBUG_COMPACT 影响)。 | |
| n_bytes | No | ||
| running | No | live | |
| max_lines | No | 限制返回的列表条数(只作用于元素为对象的列表,如 results/items/tools):最多 N 条,其余丢弃并在 output.truncated/dropped/hint 里如实上报。0 或省略=不限(受 MDKDEBUG_MAX_LINES 影响)。 | |
| reloc_delta | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations give readOnlyHint=true, idempotentHint=true, destructiveHint=false; the description adds substantial behavioral context beyond those: the dirty-read protection with read_confidence levels, reread_count, reread_consistent, degenerate status, and since_stop_s; the behavior for running='live' vs running='halt' with paused_ms/resumed flags; recovery-failure warnings; and explicit instructions that low/medium confidence should not drive conclusions. This transparently discloses surprising real-world behavior (first-frame zeros, instability during live reads) that the annotations do not capture. No contradiction.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is dense and information-rich, front-loading the core purpose and then drilling into critical behaviors (dirty-read, running modes, output control). Every major sentence serves a functional purpose; the structure is logical (purpose → address formats → dirty-read → running modes → output control → parameters/examples). It is long but justified by the complexity of a memory-read tool with subtle consistency semantics.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a 9-parameter tool, the description is thorough across all dimensions: parameter meaning, behavioral caveats, output control, environment variables, and examples. The output schema further clarifies return fields. Even the edge case of a dirty first frame is documented with a warning. Nothing an agent needs to call this correctly is missing.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 33%, so the description carries significant burden for the 9 parameters. It clearly explains addr (with formats, hex/dec/symbol, and reloc_delta interaction), n_bytes/length alias, verify modes, running modes, and compact/max_lines/full with the environment-variable defaults. It also lists aliases. This adds meaning well beyond the schema, and while more detail could be given for reloc_delta's concrete semantics, the description answers the essential usage questions.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
States a specific verb (read), resource (memory at an address), and quantity (n_bytes), with distinctive scoping: address formats, symbol resolution, relocation offsets for App-side symbols, and a dirty-read auto-reread mechanism. This clearly differentiates read_mem from its siblings such as read_variable (which targets debugger variables) and read_console_output (console text).
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Gives explicit conditions across multiple scenarios: when to use reloc_delta, how to avoid dirty reads (verify auto mode with automatic retries, thresholds for degenerate frames), how to obtain a consistent snapshot (running='halt'), and when NOT to conclude from low-confidence reads. It also references query_memory_map for range validation and notes the App-side symbol offset flow via set_reloc_delta.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
read_variable按变量名查询变量地址与内容ARead-onlyIdempotent
按变量名查询变量的内存地址与当前内容(值),支持数组等类型。内部用 '&变量名' 取地址、'变量名' 取值、'sizeof(变量名)' 取大小,AI 无需手写取地址表达式即可定位变量。name 为变量名(如 'SData_UA'、'timer.sec'、'arr');count 可选:>0 时按数组逐元素读 name[0..count-1] 返回 elements;返回 {address, value, value_type, size_bytes, elements, memory_hex}。读 App 侧变量(运行期重定位过)时传 reloc_delta="0xF000",或先调 set_reloc_delta 设一次全局偏移:工具会把符号的链接地址 + 偏移当作运行地址去读,返回 link_address / run_address,不必再手工换算(此时 value 按小端整数解析内存,浮点看 value_as_float)。符号解析双轨(批次48):Keil 表达式这条路读不到时(static 变量、符号漂移、停在不相关位置),会自动改走 .axf 符号表地址 + read_mem 兜底,返回 fallback=".axf 符号表 + read_mem" 与 fallback_reason 说明为什么换了轨道;两条都不通就如实报错,不会给一个像样的假值。若返回 value_suspect/value_warning(读回整帧全 0x00/全 0xFF),不要据此判定「变量被清零」——先用 reloc_check 校验 reloc_delta 是否与实际布局相符。适合先查地址/数组内容,再配合 read_mem/write_mem 进一步读写。注意:需目标暂停(运行中读取会失败/错位);依赖 .axf 调试符号。刚停止瞬间取值可能读到脏值。 【参数】必填: name;可选: count, read_memory, reloc_delta 【调用示例】{"name": "SData_UA"} 【参数别名】name ← arr/expression/func/function/keyword/location/pattern/query/symbol/target/var/variable/varname;count ← items/length/n/num。规范名以上方【参数】行为准;未列出的参数名会被拒绝,不会静默忽略
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| count | No | ||
| read_memory | No | ||
| reloc_delta | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations only say read-only/idempotent/non-destructive. The description adds major behavioral detail: internal address/value/sizeof expressions, reloc_delta handling for App-side variables, fallback to .axf symbol table plus read_mem, fallback_reason, the value_suspect warning, and dirty values right after stop. This is strong value beyond the annotations.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is long but information-dense, front-loading purpose and parameter rules before caveats. Almost every sentence adds value, though the parameter/alias list partially repeats content already in the schema and could be tightened.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
It covers prerequisites (paused target, .axf symbols), failure modes (fallback, both paths failing, all-zero frame warning), return fields (address, value, value_type, size_bytes, elements, memory_hex), and the intended workflow with read_mem/write_mem. Given the tool's complexity, nothing essential is missing.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 0%, so the description carries the burden. It explains name with examples, count with array indices and elements, and reloc_delta with the offset and returned link_address/run_address. The only gap is read_memory, which appears in the parameter list but has no semantic explanation.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a precise verb+resource: query a variable's memory address and current value by variable name, including array support. It also differentiates itself from siblings like read_mem/write_mem by explaining that it resolves symbols automatically and is meant to locate addresses before raw memory access.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
It gives clear usage context: '适合先查地址/数组内容,再配合 read_mem/write_mem 进一步读写' and explicitly warns that the target must be paused and .axf debug symbols are required. It lacks a full when-not-to-use comparison against calc_expression or list_symbol_projects, so it falls just short of an explicit exclusion list.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
reset复位目标ADestructiveIdempotent
复位目标 MCU(变量回到初值、断点保留)。行为说明(真机实测,与旧描述不同):复位后目标停在复位向量、处于停止态,程序不会自行往下跑——必须再调 run(或 run_timeout / run_to_line)才会开始执行;实测复位后 get_status 返回"已停止",正因为不 run 就没有任何串口输出。返回带 state_after_reset(stopped/running)与 stopped_after_reset 说明这一点;run_after=true 可在复位成功后自动 run(等价于复位后自己再调一次 run),适合「重新跑一遍看串口输出」的场景。 【参数】必填: 无;可选: run_after 【调用示例】{} 【风险】高——不可逆:会改写目标 Flash/内存,或关闭/重启用户的 Keil 实例。执行前确认目标与工程正确。
| Name | Required | Description | Default |
|---|---|---|---|
| run_after | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
The description goes far beyond the annotations (destructiveHint=true, readOnlyHint=false) by disclosing the exact post-reset state (stopped at reset vector), the need for an explicit run, the get_status result, and the irreversible nature (rewrites flash/memory or restarts Keil). It also explains the run_after parameter's behavior.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is structured with bold headers (行为说明, 参数, 调用示例, 风险) and front-loads the core purpose and critical behavioral change. Every sentence adds value, and the risk warning is clearly highlighted.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a destructive, irreversible operation, the description covers the reset behavior, return fields (state_after_reset, stopped_after_reset), parameter semantics, call example, and risk warning. Even though an output schema exists, the description adds critical context about the return values and post-reset state.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 0%, so the description fully compensates by explaining run_after: optional, default false, and its purpose (auto-run after reset). The example {} clarifies that no parameters are required.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Description states a specific action (reset target MCU), the resource (target MCU), and clarifies that variables return to initial values while breakpoints are preserved. It clearly distinguishes the purpose from siblings like run or stop.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Explicitly explains that after reset the target stops at the reset vector and requires a subsequent run call, and notes run_after for auto-run scenarios. It doesn't explicitly list alternatives for when not to use it, but the context (e.g., '重新跑一遍看串口输出') provides clear usage guidance.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
reset_connectionA
只重置 UVSOCK 连接(不重启 Keil):丢弃当前 socket 与全部残留接收缓冲,下次调用自动重新建连。用于长连接会话被弄脏(调试会话残留、异步消息堆积、模态框阻塞后)导致后续命令连续超时的场景——以前只能「关掉 Keil 再开」,现在可以先用本工具原地复位;复位无效再上 restart_keil。 【参数】必填: 无;可选: reason 【调用示例】{} 【风险】中——会改变目标状态或占用共享资源(调试态/串口/Keil 实例),必要时可回退。 【参数别名】reason ← message/note/why。规范名以上方【参数】行为准;未列出的参数名会被拒绝,不会静默忽略
| Name | Required | Description | Default |
|---|---|---|---|
| reason | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
The annotations only declare readOnlyHint=false, destructiveHint=false, etc., which provide no positive safety profile. The description compensates fully: it notes the tool changes target state, may occupy shared resources (debug state/serial/Keil instance), and that it is reversible ('可回退'). It also explicitly says it does not restart Keil, avoiding a major misunderstanding. No contradiction with annotations is present.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is well-structured and front-loaded: it states the core purpose first ('只重置 UVSOCK 连接'), then the usage scenario and alternative, followed by a compact parameter/risk/alias section. Every sentence serves a purpose—no filler or repetition. The length is appropriate for the amount of critical context it provides.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a non-annotated tool with a single optional parameter and an existing output schema, the description covers the essential operational context: purpose, usage triggers, side effects, risk level, rollback possibility, parameter acceptance rules, and distinction from alternatives. The output schema handles return values, so no extra explanation is needed. Nothing critical is missing.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema has one optional parameter 'reason' with a default and no description. The description lists the parameter as optional, provides alias mappings (reason ← message/note/why), and states that unlisted parameter names are rejected. However, it does not explain what the 'reason' parameter actually controls or how it affects behavior. While this is helpful, it does not fully compensate for the 0% schema description coverage, so a mid-range score is warranted.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a specific verb-resource pair: 'reset UVSOCK connection (not restart Keil)', and explicitly distinguishes it from the sibling tool 'restart_keil'. It also explains the mechanism (discarding socket and residual receive buffers) and the scenario it addresses. This is far beyond a vague or tautological statement.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description clearly indicates when to use this tool: when a long-lived session is dirty (debug residue, async message buildup, modal dialog blocking) causing timeout failures. It also explicitly compares to the alternative ('previously only close and reopen Keil, now try this first; if it fails, use restart_keil'), giving a clear decision path.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
restart_keilADestructive
一键重启 Keil 并重建调试通道:关闭所有 Keil 实例 → 以脱离父进程的方式重新拉起并打开工程 → 等待 UVSOCK 端口监听 → 重置连接。把「Keil 死了 / 会话脏了只能人工关掉再开」整条恢复流程变成一次调用。project 为 .uvprojx 路径(省略用默认工程);force=True 直接强制结束残留实例;wait_ready 为等待 UVSOCK 监听的秒数(默认 20)。返回各阶段结果与最终健康快照。注意:会关闭所有 Keil 实例(含人工查看中的窗口),未保存的调试会话/源码改动可能丢失,调用前请确认。 【参数】必填: 无;可选: project, force, wait_ready 【调用示例】{} 【风险】高——不可逆:会改写目标 Flash/内存,或关闭/重启用户的 Keil 实例。执行前确认目标与工程正确。 【参数别名】project ← path/proj/project_file/project_path/uvprojx;force ← hard/kill;wait_ready ← wait/wait_uvsock。规范名以上方【参数】行为准;未列出的参数名会被拒绝,不会静默忽略
| Name | Required | Description | Default |
|---|---|---|---|
| force | No | ||
| project | No | ||
| wait_ready | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
The description discloses several behaviors beyond the destructiveHint annotation: it closes ALL Keil instances, including windows the user may be viewing, and warns that unsaved debug sessions or source changes may be lost. It also details the relaunch process (detached from parent process) and the UVSOCK wait mechanism, plus it states the return of phase results and a final health snapshot. This goes well beyond simply saying 'destructive' and gives the agent a precise mental model of side effects.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is thorough and well-structured, starting with the main purpose and then breaking down the workflow, parameters, risk, and aliases. It is longer than a typical description but every section adds essential operational detail. The front-loading of the core purpose and the use of labeled sections (【参数】, 【风险】, 【参数别名】) make it scannable. It is slightly verbose but not wasteful.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's complexity—it orchestrates multiple steps and has destructive side effects—the description covers all necessary aspects: the actions performed, the parameters, the return behavior, the risks, and the aliases. The presence of an output schema reduces the burden of describing return values, and the description still states what it returns ('各阶段结果与最终健康快照'). An agent has enough information to call it correctly and safely.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema provides no descriptions (coverage 0%), so the description carries the full burden. It explains each parameter: 'project 为 .uvprojx 路径(省略用默认工程)', 'force=True 直接强制结束残留实例', and 'wait_ready 为等待 UVSOCK 监听的秒数(默认 20)'. It also lists parameter aliases, preempting naming mismatches. This fully compensates for the schema's lack of detail.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: '一键重启 Keil 并重建调试通道' (restart Keil and rebuild debug channel). It enumerates the exact sequence of actions (close all instances, relaunch with project, wait for UVSOCK, reset connection) and explains that it packages the entire recovery workflow into one call. This is specific and distinguishes it from siblings like close_uvision, launch_uvision, and reset_connection, which each handle only a portion of the process.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides context on when to use: '把「Keil 死了 / 会话脏了只能人工关掉再开」整条恢复流程变成一次调用' – i.e., when Keil is dead or the session is dirty. It also warns about destructive effects (closing all instances, losing unsaved changes), which informs the decision to avoid using it casually. However, it does not explicitly name alternative tools or state when NOT to use it in favor of more granular operations (e.g., reset_connection for a simple reset). The guidance is clear but not explicitly comparative.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
run全速运行A
让目标 MCU 全速运行(启动执行)。注意:run 后目标全速运行,此时读内存/寄存器/表达式会失败或错位(异步消息堆积),需先 stop 再读。目标运行期间 UVSOCK 会推送异步消息。若期望'运行到某断点停住',请以 get_current_location 实测 PC 停靠位置为准,run 本身返回的停靠信息不可信(PC 可能为脏值)。关于'看不到现象':调试是 halt 式的——只要 MCP/Keil 保持调试连接,目标要么被挂起、要么在被断点拦停,外设现象(LED、串口输出、周期动作)会随之停滞,这是调试的本质而非工具缺陷。要看真实运行现象,请在 run 之后不要再 stop/读内存/读寄存器,让目标自由运行;需要恢复观察时先 exit_debug(退出调试后目标按复位/运行设置自由执行)。 【参数】无(直接调用) 【调用示例】{} 【风险】中——会改变目标状态或占用共享资源(调试态/串口/Keil 实例),必要时可回退。
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Adds substantial behavior beyond the annotations (readOnlyHint=false, idempotentHint=false): the async message pileup that corrupts memory/register reads while running, the unreliable dirty PC value in run's return, the halt-type debug nature where peripherals stall while the debugger is connected, and the UVSOCK async message push. These are critical, non-obvious behaviors that annotations cannot express. No contradiction with annotations — mutation semantics match readOnlyHint=false.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Front-loaded with the core purpose, then caveats, then the free-run guidance. Each section carries genuinely useful information for correct use. It is on the verbose side — the 看不到现象 philosophical explanation of halt-type debugging could be tightened — but for a debug tool with these non-obvious behaviors, the length is largely justified and every sentence earns its place.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Complete for a tool of this complexity: output schema covers return values, annotations cover the safety profile, and the description thoroughly covers the behavioral gotchas (async pileup, dirty PC, halt-type semantics, free-run procedure) plus the medium risk and call example. Nothing an agent needs to call it correctly is missing.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Zero parameters with 100% schema coverage (trivially, an empty schema), so the baseline of 4 applies. The description explicitly notes 无(直接调用) and shows the empty call example, confirming no parameters need explanation. Nothing more is needed.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
States a specific action — 让目标 MCU 全速运行(启动执行) — with a clear resource (target MCU) and verb (full-speed run/start execution). It implicitly distinguishes itself from siblings like step (single-step) and run_timeout (timed run), and the title 全速运行 reinforces the purpose. Nothing is vague or tautological.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Provides strong contextual guidance: warns that reading memory/registers after run will fail and that stop is required first, and instructs using get_current_location to verify PC position instead of trusting run's returned stop info, plus exit_debug for free-running. However, it never explicitly routes to named siblings (e.g., 'use step for single-stepping' or 'use run_timeout for bounded runs'), so the when-to-use vs alternative guidance is rich but not fully explicit.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
run_timeout运行一段时间后自动暂停A
让目标 MCU 全速运行 timeout_ms 毫秒后自动暂停,并返回停靠位置(文件行+源码+完整调用栈)。用于验证时序 / 观察运行 N 毫秒后的状态。timeout_ms 默认 1000。时长以分段字段给出,别混用:requested_run_ms 是你请求的运行时长;actual_run_ms 是实测「run 返回 → 发 stop」的间隔(Windows 定时器粒度约 15.6ms,请求 137ms 时实测常在 140~155ms,属 sleep 精度而非工具延迟);stop_wait_ms 是 stop 之后等目标确认停止的耗时(这才是 wait_stopped.waited_ms 的含义,它与 timeout_ms 无关,不要当运行时长用);total_ms 是整次调用总耗时。halt 落点还受 UVSOCK 往返影响,毫秒级精度要求请改用 DWT 周期计数或 GPIO 打点。注意:到点 stop 后会轮询确认目标真正停止(stop 是异步生效的)才读 PC;若未能确认停止,返回 stopped=false + warning 且不返回停靠位置,避免把陈旧 PC(常量落复位附近 0x0800024c 之类)误当成停靠点。另外真机实测:halt 后首次读到的 PC 常是上一次 halt 的残留值(LR/SP 已是新值),故读取按'连续采样收敛'判定(连续两次 PC/LR/SP 一致才采纳),返回 pc_confidence=high/low;low 表示采样未收敛或复查发现目标其实仍在运行,PC 不可信,请重试。返回里始终带 pc_confidence 与 stop_verified:stop_verified=false 表示「没能确证目标已停」,此时绝不要把任何地址当停靠点(真机踩过:报出 HAL_Init / 连续同一个地址,而目标其实在跑)。若你怀疑目标没停或反复复位,请改用 wait_breakpoint(等断点命中)或 read_variable / 串口输出交叉确认。到点常停在 SysTick 等中断上下文,此时局部变量与调用栈层数可能受限/为空,AAPCS 寄存器解读不适用。需已进入调试且配置 .axf。 【参数】必填: 无;可选: timeout_ms 【调用示例】{} 【风险】中——会改变目标状态或占用共享资源(调试态/串口/Keil 实例),必要时可回退。 【参数别名】timeout_ms(毫秒) ← duration/duration_ms/duration_s/max/max_ms/max_s/ms/timeout/timeout_s/wait/wait_ms/wait_s;带 _s/_ms 的别名按后缀换算(_s=秒、_ms=毫秒)。规范名以上方【参数】行为准;未列出的参数名会被拒绝,不会静默忽略
| Name | Required | Description | Default |
|---|---|---|---|
| timeout_ms | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With annotations offering only false flags valuation-description carries full behavioral burden delivered richly: it discloses asynchronous stop confirmation, stale PC residue, convergence-based sampling, pc_confidence/stop_verified semantics, Windows timer granularity, UVSOCK effects, and SysTick interruption context limitations. It also clearly states preconditions (must be in debug mode with .axf configured).
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is long but front-loaded with the core behavior and then structured into important caveats, parameter details, aliases, and risk. It is densely informative, though a few concepts (e.g., stale PC and stop_verified=false warnings) are reiterated, creating slight redundancy.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's complexity and the output schema existence, the description is exceptionally complete: it explains return fields, failure modes, when not to trust results, alternatives, side effects, and preconditions. Nothing an agent needs to call this safely and interpret results correctly is missing.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 0%, but the description fully compensates: timeout_ms default is 1000, aliases with unit conversion are listed, and the output timing fields (requested_run_ms, actual_run_ms, stop_wait_ms, total_ms) are carefully distinguished to prevent misuse. For the single optional parameter, semantics are complete.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Description opens with a specific verb+resource: runs the target MCU at full speed for timeout_ms then auto-pauses, returning a stop location with file line, source, and full call stack. It states the intended use (verifying timing / observing state after N ms), clearly differentiating it from related run/stop/wait_breakpoint tools.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
It explicitly says when to use the tool (timing verification / observing state after a fixed duration) and warns against relying on it for millisecond-level precision, recommending DWT cycle counting or GPIO toggling instead. It also instructs to switch to wait_breakpoint or read_variable/serial output when the target might not have stopped or is repeatedly resetting.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
session_state跨会话状态:保存/读取上次调试上下文A
把「这次调试是怎么配起来的」落盘成 state.json,供下个会话接续,解决 MCP 工具无状态、会话一断上下文全丢的问题(最典型的是符号文件漂移:接着上次调试却加载了别的 .axf,表达式集体解析失败)。记录内容:默认工程、符号文件、调试会话标记、内部断点/数据断点清单、串口端口与波特率、SVD 器件、snapshot_diff 基线等。action:show(默认,看当前上下文与磁盘态差异)/ save(落盘,旧文件自动备份为 .bak)/ load(读回;apply=true 才执行可恢复动作)/ clear(删除,需 confirm=true)。两条约定:① 只存观察到的,采不到的字段标 available=false 与原因,不填默认值假装成功;② load 默认只对比不应用,apply=true 也只恢复主机侧可逆项(目前仅符号文件切换),断点/内存/运行态等目标侧状态永不自动重放。路径可用 path 指定,或用环境变量 MDKDEBUG_STATE_FILE,默认 ~/.mdkdebug/state.json。 【输出控制】本工具返回体可能较大,额外接受三个可选参数:compact=true(精简)/ max_lines=N(限制列表条数)/ full=true(强制全量)。默认都不传=行为不变;被裁掉的内容一定会在返回体的 output 字段里如实上报(truncated/dropped/trimmed/hint),不会静默丢数据。也可用环境变量 MDKDEBUG_COMPACT=1 / MDKDEBUG_MAX_LINES=N 设全局默认。 【参数】必填: 无;可选: action, path, apply, confirm, compact, max_lines, full 【调用示例】{} 【风险】中——会改变目标状态或占用共享资源(调试态/串口/Keil 实例),必要时可回退。
| Name | Required | Description | Default |
|---|---|---|---|
| full | No | 强制返回全量:忽略 compact/max_lines 与对应环境变量的默认值。当上面两项让你只看到部分数据、而你要据此下结论时,用它取回完整结果。 | |
| path | No | ||
| apply | No | ||
| action | No | show | |
| compact | No | 精简返回体:去掉空值字段,把列表元素中取值完全相同的字段提到 output.shared,并把 usage/note/hints 之类**说明性**长文本截断到 200 字符(数值与内容字段不动)。被裁掉的东西都会列在 output 里,绝不静默丢弃。不传则不改行为(受 MDKDEBUG_COMPACT 影响)。 | |
| confirm | No | ||
| max_lines | No | 限制返回的列表条数(只作用于元素为对象的列表,如 results/items/tools):最多 N 条,其余丢弃并在 output.truncated/dropped/hint 里如实上报。0 或省略=不限(受 MDKDEBUG_MAX_LINES 影响)。 |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
All annotations are false (readOnlyHint, openWorldHint, idempotentHint, destructiveHint), so the description carries the full behavioral burden — and it over-delivers. It discloses the destructive clear action (requires confirm=true), reversal path (.bak backup, '必要时可回退'), the honesty convention (unobservable fields marked available=false, never faked to default), and the output-truncation guarantee (truncated/dropped/trimmed/hint always reported, data never silently dropped). The only tension is clear-action vs destructiveHint=false, but the confirm gate, .bak backup, and re-creatable state file make this guarded destructive behavior, so I do not treat it as a contradiction.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is dense but well-sectioned (purpose, content, actions, conventions, path, output-control, params, risk) and front-loaded with the core purpose and the key problem it solves. The output-control section is verbose relative to its importance, and the section markers are a bit processor-like, but every section carries genuinely useful information for a 7-parameter complex tool, so it earns its length.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's complexity (7 params, 4 actions, env-var fallbacks, output truncation, risk) the description covers nearly everything: purpose, recorded content, all action semantics, two behavioral conventions, path resolution, output control, and a medium-risk disclosure. An output schema exists so return-shape details are covered. The one gap is a call example of {} that gives the agent no concrete invocation template — a minor omission against an otherwise complete definition.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is only 43% — action, path, apply, confirm have titles but no descriptions. The description compensates for exactly these gaps: it enumerates action values (show/save/load/clear) with semantics, explains apply=true recovery scope, requires confirm=true for clear, and gives path resolution (path param vs MDKDEBUG_STATE_FILE env var vs ~/.mdkdebug/state.json default). The schema already documents compact/max_lines/full. This is solid supplementation of the weaker schema fields, though not exhaustive on every parameter.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a specific verb+resource: persist/load debug configuration (state.json) to carry context across MCP sessions, and names the concrete problem it solves (symbol file drift, .axf mismatch causing expression failures). It lists the exact recorded content (project, symbol file, breakpoints, serial port, SVD device, snapshot_diff baseline), which clearly differentiates it from siblings like get_status, wait_state, target_info, and direct debug mutators (set_breakpoint, run, reset). Purpose is unambiguous and distinct.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description gives a clear lifecycle guide: show (default) to inspect current-vs-disk difference, save with .bak auto-backup, load with apply=false for compare-only and apply=true for recoverable items, clear requiring confirm=true. It explicitly states when load applies versus not (host-side reversible items only; target-side state never auto-replayed). It does not name sibling alternatives or state when NOT to use the tool, but given no sibling overlaps with cross-session persistence, the per-action guidance is strong enough to earn a 4.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
set_breakpoint设置断点ADestructiveIdempotent
在指定符号或地址处设置软件断点。expr 可为函数名/变量名(如 'main')或地址(如 '0x08001034')。返回是否成功。地址路径与符号路径做同一套归一:入参地址若带 Thumb 位(bit0=1,常见于函数指针)会自动按偶地址下断并返回 thumb_bit_stripped/address_normalized——真机实测 Keil 的 BS 对奇数地址一律报 error 57: illegal address,而符号名路径经 calc_expression 拿到的是偶地址,所以只有裸地址会踩这个坑。设断点失败时返回 diagnosis(错误码含义 + 地址落在哪个区 + 是否在 .axf 覆盖范围 + 下一步建议)。另外:设断点走命令窗口 BS,会触发 Keil 异步推送断点消息,紧随其后的命令响应可能被污染(本工具已改为先 calc_expression 取地址再 BS 0xaddr);设断点后立即 run/step 前需稍等异步消息落地。需已进入调试且配置 .axf。
【参数】必填: expr;可选: 无
【调用示例】{"expr": "main"}
【风险】高——不可逆:会改写目标 Flash/内存,或关闭/重启用户的 Keil 实例。执行前确认目标与工程正确。
【参数别名】expr ← addr/address/expression/func/function/keyword/location/name/pattern/pc/query/symbol/target/var/variable。规范名以上方【参数】行为准;未列出的参数名会被拒绝,不会静默忽略
| Name | Required | Description | Default |
|---|---|---|---|
| expr | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Beyond the destructiveHint annotation, it discloses the Thumb-bit normalization behavior, Keil error 57 on odd addresses, asynchronous message pollution after BS, the need to wait before run/step, and the diagnosis payload on failure. These are exactly the non-obvious behavioral traits an agent needs.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is long but structured with bolded key points, parameter/example/risk/alias sections, and no filler. It earns its length because the tool is high-risk and has several platform-specific edge cases, though it remains denser than strictly necessary.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the high-risk mutation context, the description covers prerequisites, operand semantics, return behavior, failure diagnosis, operational ordering caveats, and risk. With an output schema present, nothing essential is missing for correct invocation.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
With 0% schema coverage, the description carries the full burden and succeeds: it explains expr accepts symbol names or addresses with formatting examples, documents normalized outputs, lists parameter aliases, and warns that unknown parameter names are rejected rather than ignored.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description opens with a specific verb-resource pair: '在指定符号或地址处设置软件断点' and immediately gives examples of expr (function/variable name or address). This clearly distinguishes it from sibling tools like clear_breakpoint and list_breakpoints.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
It states clear prerequisites ('需已进入调试且配置 .axf') and gives a concrete call example. It does not explicitly name alternatives or when not to use it, but the operational context is unambiguous.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
set_symbol_file设置/切换当前调试符号文件AIdempotent
运行时切换调试符号文件,解决符号绑定错误(find_symbol/get_current_location/断点行号解析到错误的 .axf)问题。path 支持 .axf(完整 DWARF 行号/局部变量)或 .map(函数/全局符号地址,无行号)。加载成功返回符号条目数;失败给出明确错误(文件不存在/无DWARF/格式不支持)。注意:建议 AI 落地后先 list_symbol_projects 查看候选,再 set_symbol_file 切到当前正在调试的固件符号,避免符号漂移误判。 【参数】必填: path;可选: 无 【调用示例】{"path": "path/to/firmware.axf"} 【风险】中——会改变目标状态或占用共享资源(调试态/串口/Keil 实例),必要时可回退。 【参数别名】path ← axf/axf_path/file/symbol_file。规范名以上方【参数】行为准;未列出的参数名会被拒绝,不会静默忽略
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
注释提供 readOnlyHint=false、idempotentHint=true、destructiveHint=false,描述补充了风险'会改变目标状态或占用共享资源(调试态/串口/Keil 实例)',并说明可回退,增加了注释之外的上下文。还说明了成功/失败返回行为,但可进一步详述具体错误类型。
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
描述信息密度高,开头即点明目的,随后提供参数、示例、风险和别名,结构清晰。虽然长度较长,但每部分均有价值,没有冗余。略微分散但整体组织良好。
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
鉴于工具涉及状态变更和资源占用,描述覆盖了使用场景、参数语义、风险、回退方式以及返回内容,结合输出 schema 和注释,信息完整。没有遗漏关键事项。
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
schema 覆盖率为 0%,但描述详细解释了 path 参数支持 .axf 和 .map 的语义差异,以及支持的文件格式细节,远超 schema 仅定义类型。还列出了参数别名,帮助理解参数用途。
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
描述明确指出该工具用于'运行时切换调试符号文件',并具体说明解决符号绑定错误问题,动词和资源清晰。与兄弟工具如 list_symbol_projects 有明显区分,后者用于查看候选,而本工具用于切换,目的明确。
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
描述明确建议先使用 list_symbol_projects 查看候选,再使用本工具切换,并说明避免符号漂移的时机。还提供了 path 支持 .axf 或 .map 的格式选择,以及调用示例,使用指南非常具体。
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
step单步执行A
单步执行。mode 可选:'into'(单步进入)、'over'(单步跳过)、'out'(跳出)、'instruction'(指令级)。默认 'into'。注意:单步瞬间读 PC 可能读到 SRAM 脏值(已用 FLASH 区段过滤修复)。在中断/异常 handler 内单步或 SP/LR 回溯可能层数受限;'out' 在函数入口处不可靠(Keil 可能无法正确跳出),若卡住可改用 run_to_line 跳到函数返回行。需已进入调试且配置 .axf(source 级单步)。 【参数】必填: 无;可选: mode 【调用示例】{} 【风险】中——会改变目标状态或占用共享资源(调试态/串口/Keil 实例),必要时可回退。 【参数别名】mode ← kind/over_or_into/type。规范名以上方【参数】行为准;未列出的参数名会被拒绝,不会静默忽略
| Name | Required | Description | Default |
|---|---|---|---|
| mode | No | into |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
The annotations already declare readOnlyHint=false, destructiveHint=false, and idempotentHint=false, so the description does not need to restate that. It does add valuable behavioral context: it warns about potential dirty PC values due to SRAM, limitations when stepping inside handlers, and the unreliability of 'out' at function entry. This goes beyond the annotations, providing critical runtime behavior details that an agent needs to know.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is reasonably concise, with key information front-loaded (what it does and modes). It uses structured sections for parameters and risk, which aids scanning. However, it includes some redundant content like the list of modes repeated in the main description and later in the alias section, but that's minor. The warning about dirty PC is valuable and placed after the modes, which is acceptable.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given that there is an output schema, the description does not need to explain return values. The tool is a complex debug operation, and the description covers preconditions ('需已进入调试且配置 .axf'), potential pitfalls (dirty PC, reliability issues), and fallback suggestions. It also provides risk level and parameter aliases, making it complete for an agent to use correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema coverage is 0%, so the description must compensate. The description explains the 'mode' parameter thoroughly, listing all possible values ('into', 'over', 'out', 'instruction') with their meanings and the default. It also explains the aliases for mode. This is comprehensive, despite the minimal schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states the verb '单步执行' (single-step execution) and the resource (the target). It is clear that this tool executes one step in a debug session. However, it does not explicitly distinguish it from sibling tools like 'run' or 'run_to_line' (mentioned in the description but not present in the sibling list), which could confuse an agent about when to use step vs. run. The description does reference 'run_to_line' as an alternative, providing some differentiation.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description gives explicit guidance on when to use each mode and when not to, including alternatives. It says 'out' is unreliable at function entry and suggests using 'run_to_line' as an alternative. It also states the precondition that the tool requires being in debug mode with an .axf configured. This is excellent usage guidance.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
stop暂停执行(含停止确证)AIdempotent
暂停目标 MCU 的执行(进入断点/挂起状态),此时才可安全读内存/寄存器/表达式。停止是异步生效的:命令返回不代表目标已停(真机实测 stop 回 ok 后紧跟的 get_status 仍报"执行中"),这期间读到的内存/寄存器可能是脏值或陈旧值。本工具默认在 stop 之后轮询确认(verify=true),返回 stopped / stop_verified / waited_ms / state_after_stop:stop_verified=false 表示没能确证目标已停,此时不要读内存/寄存器、也不要据其下结论,可重试 stop 或稍后再读(与 run_timeout 的 stop_verified 同一口径)。verify=false 则只发命令不做确认(快,但需自行承担读到脏值的风险)。看门狗防御(真机踩过):暂停期间目标虽不跑代码,看门狗(IWDG)仍在计数——新会话/复位后 DBGMCU 冻结位会被清零,halt 超过溢出时间就被复位、RAM 现场全丢。本工具默认在 stop 后自动置位 DBGMCU 的 IWDG/WWDG 冻结位(freeze_watchdogs=true),返回 watchdog_freeze 字段供核对(含 all_frozen);不需要可传 freeze_watchdogs=false。 【参数】必填: 无;可选: verify, timeout, freeze_watchdogs 【调用示例】{} 【风险】中——会改变目标状态或占用共享资源(调试态/串口/Keil 实例),必要时可回退。
| Name | Required | Description | Default |
|---|---|---|---|
| verify | No | ||
| timeout | No | ||
| freeze_watchdogs | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Beyond the annotations, the description reveals critical runtime behavior: stop is asynchronous, verification is polled by default, unverified stops may yield stale/dirty values, and watchdog freeze bits are managed to prevent reset during halt. This is substantial context beyond idempotentHint/readOnlyHint.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is long but organized with bolded warnings and sectioned parameter/risk notes. It front-loads the core purpose and then layers necessary caveats. Some repetition and extra detail could be trimmed, but most content earns its place for a tool with async and watchdog behavior.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The description covers the main action, async semantics, verification failure protocol, watchdog risks, default parameters, return field names, and risk level. It is sufficient for an agent to call the tool correctly and avoid unsafe memory reads.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The description adds real meaning for verify and freeze_watchdogs, including defaults, consequences, and return implications. However, timeout appears only in the parameter list and schema default, with no explanation of its unit or effect. Given schema description coverage is 0%, this is a noticeable gap.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description opens with a precise statement: '暂停目标 MCU 的执行(进入断点/挂起状态)' and connects it to safe memory/register/expression reads. This clearly distinguishes it from sibling operations like run, step, or reset, and from read-type tools.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
It explicitly says when to use stop (before safe memory/register reads) and when not to proceed ('stop_verified=false 此时不要读内存/寄存器'). It also gives alternatives: retry stop, read later, and references run_timeout's same stop_verified convention.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
target_info查询目标器件信息(芯片型号/Flash/RAM)ARead-onlyIdempotent
查询目标芯片信息:实时读 DBGMCU->IDCODE 寄存器得到 DEV_ID/REV_ID 并映射到型号,返回标称 Flash/RAM 容量与内存布局。排查“资源吃紧/选错型号/容量不符”时先调它。idcode 实时读取需已进入调试(内存读依赖调试会话);非调试态仅返回静态布局信息。注意:DEV_ID = IDCODE 低12位(&0x0FFF)、REV_ID = 高16位、IDCODE 为小端字节序(本工具已正确解析);实时读 IDCODE 需已进入调试,非调试态仅返回静态布局信息。未收录型号返回标称容量 None + 提示按丝印确认。 【参数】无(直接调用) 【调用示例】{}
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Beyond the readOnly/idempotent/destructive annotations, the description discloses the debug-session dependency for live IDCODE reads, the static fallback in non-debug mode, endianness handling, bit-field mapping, and the behavior for unknown models. This is valuable context the annotations do not provide.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The purpose and usage guidance are front-loaded, but the debug-session requirement is stated verbatim twice)Skip, adding unnecessary redundancy. The empty call example is also low-value given an empty schema.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The description covers invocation mode requirements, fallback behavior, edge cases like unknown chips, and result semantics. Since an output schema exists, return structure is already handled; nothing needed to call this tool correctly is missing.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The tool has zero parameters and the schema coverage is 100%, so there is nothing extra to clarify. The description explicitly confirms no arguments are needed and gives an example empty call, which fits the 0-param baseline.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a specific action: query target chip info by reading DBGMCU->IDCODE, mapping DEV_ID/REV_ID to a model, and returning nominal Flash/RAM capacity and memory layout. This is clearly distinct from siblings like read_mem or get_version.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
It explicitly says to call this tool first when troubleshooting resource pressure, wrong chip model, or capacity mismatch, and it clarifies debug vs non-debug behavior. However, it does not name alternative sibling tools or state when not to use it.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
toolset工具面装卸(按组按需加载工具)AIdempotent
本服务的工具按 11 个组划分,另有一个 nano 极简档(只暴露十几个最短入口),默认只暴露 core 组(调试核心 + 环境引导),其余组用到时现装——这样上下文里只放当前真正用得上的工具描述,工具多的时候这是省上下文的主要手段。action=status 看当前暴露了哪些组、各组多少个、还差什么;action=load 把 toolsets 指定的组装回来(例:toolsets=mem,trace,toolsets=all 一次全装,toolsets=nano 极简);action=unload 把某组收起来(例:toolsets=trace)。可用组与含义:core 调试核心/引导、mem 内存进阶、symbol 符号反汇编、build 编译烧录、serial 串口、advanced 异常/watch/SVD、toolchain 非MDK构建、target 目标档案、ocd OpenOCD、trace SWO/RTT/变量时间线、rtos 任务感知。装卸后工具面立即变化,但很多 MCP 客户端缓存了工具列表:若装完仍报未知工具,先重新拉一次 tools/list 再调。list_tools / get_version / capabilities / toolset 这四个永远保留。小上下文模型:先 tools_groups() 看有哪些组,再 tools_load(group=...) 现装;或直接以 MDKDEBUG_TOOLSETS=nano 启动,只暴露十几个最短入口。 【参数】必填: 无;可选: action, toolsets 【调用示例】{} 【风险】中——会改变目标状态或占用共享资源(调试态/串口/Keil 实例),必要时可回退。
| Name | Required | Description | Default |
|---|---|---|---|
| action | No | status | |
| toolsets | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations declare idempotentHint=true, readOnlyHint=false, destructiveHint=false. The description adds valuable context beyond these: the medium-risk note ('会改变目标状态或占用共享资源'), the caching caveat (client tool lists may be stale, re-pull tools/list), and the immediate tool-surface change behavior. This enriches the agent's understanding of side effects and failure modes beyond what annotations convey.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is information-dense and every section earns its place (group list, caching caveat, small-context model), but it is presented as a long continuous block of text with minimal visual hierarchy. Bold markers help somewhat, yet the density makes it hard to scan quickly. It would benefit from bullet points or clearer section separation while retaining the same content.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
An output schema exists, so return-value documentation is not required. For a metadata/config tool of this complexity, the description is thorough: it covers available groups, action semantics, caching workaround, always-retained tools, and the nano startup path. Minor gaps remain around explicit response format and the distinction from tools_load, but nothing critical is missing for correct invocation.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0% and the two parameters have no enums or descriptions. The description compensates fully: it explains action=status/load/unload with concrete examples (toolsets=mem,trace, toolsets=all, toolsets=nano) and enumerates all valid group values with meanings. The agent can invoke this tool correctly without any additional parameter documentation.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a specific purpose: dynamically load/unload tool groups to manage context, listing all 11 groups plus the nano profile. It clearly differentiates the core concept (group-based tool surface management) from siblings by explaining the default-core-then-load-on-demand model, and explicitly names the always-retained tools (list_tools / get_version / capabilities / toolset). The verb-resource pair (load/unload groups) is precise and distinguishes it from tools_load and tools_groups.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description explains the overall model (default core group, load others when needed) and the small-context pattern, referencing tools_groups() and tools_load() as alternatives. However, it creates ambiguity: the small-context section recommends using tools_load() for loading while this tool itself supports action=load, without explicitly stating when to prefer one over the other. Context is present but exclusions/alternatives are not crisply delineated.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
tools_groups列工具分组与当前装载(精简)ARead-onlyIdempotent
列出工具分组(含 nano 极简档)与当前是否已装进上下文。group 留空给总览;给了组名则列出该组工具名。小上下文模型从这里挑组,再 tools_load(group=...) 装上。 【参数】必填: 无;可选: group 【调用示例】{}
| Name | Required | Description | Default |
|---|---|---|---|
| group | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations already declare readOnlyHint, idempotentHint, and destructiveHint, covering the safety profile. The description adds behavioral context beyond annotations by explaining the effect of the group parameter (empty gives overview, provided gives tool names) and that it reports loading status. It doesn't contradict annotations, and while it doesn't detail error cases, the added parameter behavior is valuable.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is two concise sentences plus a parameter summary and example, with the core purpose front-loaded. Every sentence earns its place, and the call example is minimal and useful. No fluff or redundancy.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
With a single optional parameter, an output schema present, and strong annotations, the description covers the essential usage. It explains the parameter behavior and the relationship to tools_load. It doesn't detail return format, but given the output schema exists, that's acceptable. It could mention edge cases (e.g., invalid group name) but these are not critical for basic usage.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema provides no description for 'group' (0% coverage), so the description fully compensates by explaining the exact behavior: empty gives an overview, a group name lists the tools in that group. This is a clear, complete explanation of the parameter's meaning, going well beyond the schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool lists tool groups and whether they are currently loaded, and differentiates itself from the sibling tools_load by explaining the flow (pick a group here, then load it). The verb 'list' and resource 'tool groups' are specific, and it mentions the 'nano minimal profile' as part of the grouping, distinguishing it from a generic listing tool.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description gives clear context: it tells small-context models to pick a group here and then load with tools_load, and explains the behavior for empty vs. provided group. However, it doesn't explicitly state when NOT to use this tool or mention alternatives like list_tools, so it lacks explicit exclusions. The usage context is clear but not fully comparative.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
tools_load按组装载工具(含 nano 极简档)AIdempotent
把 group 指定的组装进工具面(unload=true 则收起)。group 可写单个组名、逗号分隔多个、或 all / nano。装完若客户端仍报未知工具,重新拉一次 tools/list(客户端会缓存工具列表)。 【参数】必填: 无;可选: group, unload 【调用示例】{} 【风险】中——会改变目标状态或占用共享资源(调试态/串口/Keil 实例),必要时可回退。
| Name | Required | Description | Default |
|---|---|---|---|
| group | No | ||
| unload | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Beyond the annotations, the description explicitly discloses that this tool changes target state and may occupy shared resources like debug/serial/Keil instances, assigns a medium risk level, and notes that rollback is possible. It also discloses the client-side caching behavior and the need to re-pull tools/list, providing valuable operational transparency.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is compact and front-loaded with the core action, then covers syntax, caching behavior, and risk. The bracketed parameter/example/risk sections are efficient, though the empty call example '{}' adds little value and the risk note is somewhat verbose.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a tool with two optional parameters)Skip the redundant text, the description provides all needed context: valid group values, unload semantics, client caching caveat, risk profile, and rollback note. An output schema exists, so return-value details are not the description's burden; the tool can be invoked correctly based on this description alone.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, so the description must compensate. It does: it explains valid values for group (single, comma-separated, all, nano) and gives unload=true the meaning of retracting/collapsing the loaded group. It does not fully explore combinations like unload with all/nano, but the essential semantics are present.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a specific action: load the specified group into the active tool surface, with unload=true to retract. It clearly distinguishes the tool's scope by explaining valid group values (single, comma-separated, all, nano) and the unload behavior, making its purpose unambiguous.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies when to use it (loading/unloading tool groups) and provides a practical follow-up action when the client still reports unknown tools, including the client caching caveat. However, it does not explicitly state when to prefer this over sibling tools like tools_groups or list_tools, nor does it name exclusions or alternatives.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
view_guide可视化用法与 spec 说明(怎么把数据变成页面)ARead-onlyIdempotent
view_render 的说明书:怎么把采集结果变成页面、五种视图各画什么、以及自己写 spec 的完整字段(想把算法输出、自定义信号画出来时用)。
topic:howto(默认,一步出图与数据来源)/ views(五种视图各适合回答什么)/ spec(自写 spec 的字段与单位约定)/ limits(页面边界与大数据代价)/ all(全部)。
先看 howto:多数场景不需要读 spec——采集工具的返回原样传进 data 就够了。自写 spec 时时间单位一律 µs,且 limits 要写「这说明不了什么」,不要写成结论。
【参数】必填: 无;可选: topic
【调用示例】{}
| Name | Required | Description | Default |
|---|---|---|---|
| topic | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations already declare readOnlyHint=true, idempotentHint=true, and destructiveHint=false, so the agent knows this is a safe, side-effect-free operation. The description adds context about the content of the guide (e.g., the note about writing limits as 'this doesn't explain much' rather than a conclusion), but it doesn't disclose any behavioral traits beyond what annotations cover. The bar is lower because annotations are rich; the description adds some value but not substantial behavioral detail.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is dense but well-structured: it opens with the purpose, then lists topics and gives practical guidance, and ends with parameter and example. Every sentence adds value, and it's appropriately concise for a guide tool. Slightly dense formatting but still readable.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a guide tool with one optional parameter and an output schema (present), the description covers all necessary information: purpose, topic enumeration, usage recommendations, and parameter details. It also includes specific formatting conventions (µs units) and warns about limits phrasing. Nothing an agent needs to call it correctly is missing.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema has one optional parameter 'topic' with no description and 0% coverage, but the description fully compensates by enumerating all valid values (howto, views, spec, limits, all) with their meanings and defaults. It also notes the parameter is optional and provides a call example, giving the agent complete information to select the right topic.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool is a manual for view_render, covering how to turn collected data into pages, the five view types, and how to write custom specs. It explicitly names the resource (view_render) and the three main functions, distinguishing it from sibling tools like mdk_guide (a general MDK guide) and view_render itself.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides topic-based usage guidance: it recommends starting with howto for most cases, and lists when to use views, spec, limits, and all. It also advises that most scenarios don't require reading spec, and gives a concrete tip about spec units. It doesn't explicitly compare with alternatives, but the tool's purpose as a guide for view_render makes the usage context clear.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
view_render把采集结果渲染成人能看懂的单文件网页A
把已有的采集结果渲染成一个可交互的单文件 HTML(深色主题、可缩放/平移/回放),给人看「问题出在哪、场景长什么样」——不必再手写网页。渲染层是固定的:同一类数据画出来长得一样,看图的人不用每次重新适应。
最常用的一步调用:把采集工具的返回原样丢进 data(不用先转格式,工具自己认):
· trace_swd_read / trace_buff_dump / trace_eventrec → 事件时间线:上下文泳道、切换竖线(放大显示切向谁)、中断进出、异常标记、丢失断口;
· trace_scope_read(或自己拼 {t:[…], 变量:[…]})→ 变量波形(bool/enum 自动阶梯);
· trace_pcsample / trace_profile / coverage_read → 函数热点排行;
· trace_eventrec 的 items(Event Statistics)→ 每个事件的耗时排行;
· trace_record(action="read") → 函数进入/退出时间线;
· 自己写 {kind:"timeline|scope|bars|report", …} → 展示算法/自定义信号。
数据大时先落盘:trace_swd_read(out_file="trace.json") 拿到几万条事件时,别再把它塞回对话,改传 data_file="trace.json"(省 token,也避免截断)。
params:view=auto|timeline|scope|bars|report(默认 auto 认数据不认人);names="0x10=switch,1=led_task" 给 id 起人名;top=热点头条数;out=输出路径(默认 ./mdkdebug_views/-<时间戳>.html);title/subtitle 写进页面抬头。
认不出就报错、不画空图(error_code=view-unknown-data/view-bad-)。返回 counts 是画了什么,badges 是页面顶部的关键数,next 是给人看的操作提示;返回 path 直接交给用户,浏览器(file://)打开即可,页面*无外部依赖、无需联网。
一次快照,不会自动刷新:数据变了要重新渲染。页面上「这说明不了什么」那栏是边界声明(图上没有的=没被记录/没插桩,不等于没发生),讲结论前先看它。
只想讲清一个问题(结论+证据+图)用 report:sections 里的 view 可以直接嵌采集结果。
【参数】必填: 无;可选: data, data_file, view, title, subtitle, names, top, max_events, out
【调用示例】{}
【风险】中——会改变目标状态或占用共享资源(调试态/串口/Keil 实例),必要时可回退。
| Name | Required | Description | Default |
|---|---|---|---|
| out | No | ||
| top | No | ||
| data | No | ||
| view | No | auto | |
| names | No | ||
| title | No | ||
| subtitle | No | ||
| data_file | No | ||
| max_events | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
The description thoroughly discloses behavioral traits beyond annotations. It states the tool is not read-only (annotations readOnlyHint=false), mentions the risk of changing target state or occupying shared resources, notes that it produces a one-time snapshot (no auto-refresh), and explains the boundary statement in the page. This adds significant context that annotations alone do not provide.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is long but well-structured with bullet points and bold headings. It front-loads the core purpose and then details parameters and usage. Every sentence adds value, and the formatting makes it scannable. It's appropriately sized for the tool's complexity, though it could be slightly trimmed without losing essential guidance.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The description covers the tool's return values (counts, badges, next, path), explains error behavior, gives usage examples, and provides risk and boundary notes. It is complete for an agent to invoke it correctly without needing to inspect the schema or other docs.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
With schema_description_coverage at 0%, the description compensates by explaining most parameters: data, data_file, view (with options), names, top, out, title/subtitle. It provides concrete formats and defaults (e.g., out default path). However, it does not explain 'max_events' or the exact structure of custom data objects, so it's not fully comprehensive.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool renders existing collected results into an interactive single-file HTML with specific themes and interactions. It explicitly distinguishes it from other tools by saying it's for visualization, not data capture, and lists accepted data types and output formats. This is a specific verb+resource that differentiates it from siblings like view_guide.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
It provides explicit context on when to use the tool (after data collection) and how to call it with examples for various data types. It gives guidance on handling large data (using data_file to avoid token truncation) and when to use the 'report' view for focused explanations. However, it does not explicitly name alternative tools or say when NOT to use it, though the context is clear enough for an agent to select it appropriately.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
wait_breakpoint等待断点命中(带超时)ARead-onlyIdempotent
带超时地等待目标停在断点上:轮询目标状态,一旦停止就读取 PC(含收敛判定与「是否真的停住」复查),回落到源码位置,返回 hit / hit_address / hit_count / waited_ms。用来确证「App 是否真的调用到内核某函数」,不必再靠读 PC 猜、也不必手工循环 get_status。symbol 传符号名(如 svcrt_ptable_lookup,自动解析为地址);address 传 0x 地址;两者都不传时用工程 .uvoptx 里的持久化断点作候选(use_project_breakpoints 控制)。命中后返回里直接带 file/line/callstack,并累计该地址命中次数(breakpoint_stats 可查全部)。只认「本次等待期间新发生的停止」:若调用时目标已停着(典型——刚被 run_timeout 停在某行再调本工具),那次停止不计为命中,会返回 hit=false、stop_is_new=false、ran_during_wait=false 且 note 说明「目标在等待期间未曾运行」,避免把「进来时已停」误报成「等到了断点命中」。故正确用法是先 run(或 reset 后 run)再调本工具;调用时先给一个很短的宽限窗口确认目标是真想跑(run 是异步命令,响应会滞后),若窗口内没见运行且 PC 相对调用时没有移动,才判为旧停止。注意:命中判定为「目标已停止 且 PC 等于候选地址」(自动兼容 Thumb 位),并额外支持数据观察点命中——数据断点触发时 PC 不等于观察地址,判定链路按证据强度递减:① 等待前后各读一次 Keil 断点表的 CNT,某条 CNT 增加即为命中项;② 读 DFSR(0xE000ED30):等待开始前先清零(DFSR 为 W1C),命中后若 DWTTRAP(bit2) 置位即判为观察点命中,并用 DWT_COMPn 定位命中的是哪个观察点——这是硬件证据;真机实测(UVSOCK@4823 + STM32F401)本版 Keil 的 BL CNT 是断点计数条件设置值、不随命中递增,此时由 ② 接手;③ ①② 都取不到时才退化为「目标已停止 + PC 不在任何代码候选 + 存在观察点」推断为观察点命中。返回 hit_kind(code/watch)、hit_confidence(verified=有 PC/CNT/DFSR 实际证据,inferred=纯推断)、hit_entry(source 字段:pc/cnt/dfsr/inferred)、dfsr / dfsr_note(DFSR 原始值与解读)与 cnt_note(说明判定依据强度);候选来源除 symbol/address/.uvoptx 外,还包含本服务 set_watchpoint 设的数据观察点,以及在无其他候选时取 Keil 真实断点表(list_breakpoints.real)中的执行断点;若本该命中却一直不停,先用 list_breakpoints / list_uvoptx_breakpoints 确认断点存在且启用(App 侧重定位后运行时地址与符号地址不同,应传实际运行地址)。需已进入调试。另附 reset_loop 字段(批次67):同一断点在 3 秒内命中 ≥3 次时,判定「这是不是复位循环在重跑启动」——suspected=true 表示有复位证据(命中在 Reset_Handler / SP 等于向量表里的 initial SP / CYCCNT 回退),false 表示没到阈值,null 表示反复命中了但主机侧分不清复位循环与正常热循环(这时要人工核对启动时序,别硬猜)。判据来自镜像基址处的向量表(anchor 字段给出 image_base / initial_sp / reset_handler 及合法性校验)。与 repeat_warning 不是一回事:repeat_warning 说的是「同一 PC 连续出现,疑似 halt 残留值,别当反复复位看」,两者前提与结论都不同,不可互相顶替。 【参数】必填: 无;可选: symbol, address, timeout_s, poll_ms, use_project_breakpoints, project, reloc_delta 【调用示例】{} 【参数别名】symbol ← addr/expression/func/function/keyword/location/name/pattern/pc/query/target/var/variable;timeout_s(秒) ← duration/duration_ms/duration_s/max/max_ms/max_s/seconds/timeout/timeout_ms/wait/wait_ms/wait_s;poll_ms(毫秒) ← interval/interval_ms/interval_s/poll/poll_interval_ms/poll_s;带 _s/_ms 的别名按后缀换算(_s=秒、_ms=毫秒)。规范名以上方【参数】行为准;未列出的参数名会被拒绝,不会静默忽略
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | No | ||
| address | No | ||
| poll_ms | No | ||
| project | No | ||
| timeout_s | No | ||
| reloc_delta | No | ||
| use_project_breakpoints | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
The description discloses detailed behavioral traits, such as clearing DFSR (a write operation) and accumulating hit counts, which directly contradict the annotations readOnlyHint=true and idempotentHint=true. Since it explicitly describes non-read-only side effects, this is a clear annotation contradiction.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is extremely long and dense, covering many edge cases and technical details. While it is well-organized and front-loaded with the main purpose, it is not concise; several paragraphs could be trimmed or moved to auxiliary documentation without losing essential guidance.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's complexity, the description is remarkably complete: it covers preconditions (must be in debug), stale-stop handling, hit detection algorithms, data watchpoint support, confidence levels, reset-loop detection, fallback tools, and return value semantics. An agent would be well-equipped to invoke this tool correctly without further clarification.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, and the description compensates by thoroughly explaining each parameter: symbol vs address vs project breakpoints, timeout_s, poll_ms, use_project_breakpoints, project, and reloc_delta. It also provides alias mappings and unit conversions, far exceeding the sparse schema titles.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states exactly what the tool does: wait with a timeout for the target to stop at a breakpoint, poll status, read PC with convergence checks, and return hit/hit_address/hit_count/waited_ms. It explicitly distinguishes itself from manually reading PC or looping get_status, making its purpose clear and distinct from siblings.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description gives explicit when-to-use guidance: it is for confirming an App actually reached a kernel function, and recommends using run (or reset+run) before calling. It also warns that a pre-existing stop will not count, and suggests checking list_breakpoints if the breakpoint never hits, clearly directing the agent to alternatives.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
wait_state等待目标进入指定状态(通用等待)ARead-onlyIdempotent
轮询等待目标进入某个状态,把「等待 + 超时 + 现场」三件事一次做完,省掉 AI 自己 sleep + get_status 的轮询循环(那种循环既慢又容易在超时后不知道现场是什么)。state 取值:stopped(已停下,含 halt 后)、running(执行中)、not_debugging(未进入调试)、expr(表达式成立,需配 expr 参数,如 expr="uwTick > 1000" 或 expr="state == 3",非 0 即视为成立)。timeout_s 默认 10;poll_ms 默认 200。返回 matched(是否等到)、elapsed_s、polls、observed(最终观测到的状态)、以及超时时的 timeout_kind(timeout=等到了时间还没到目标状态 / unreachable=调试通道本身连不上 / never_debugging=目标停在 not_debugging 但你等的是调试态)。不要用它替代 wait_breakpoint:断点命中要用 wait_breakpoint(它认断点 id 与命中计数,比轮询 PC 更可靠);本工具适合「等标志位/等变量变化/等目标自己停下来」这类含糊等待。
【参数】必填: 无;可选: state, timeout_s, poll_ms, expr
【调用示例】{}
| Name | Required | Description | Default |
|---|---|---|---|
| expr | No | ||
| state | No | stopped | |
| poll_ms | No | ||
| timeout_s | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With annotations present (readOnlyHint=true, idempotentHint=true, destructiveHint=false), the bar is lower, yet the description still adds substantial behavioral context: polling loop behavior, timeout semantics, the three distinct timeout kinds (timeout/unreachable/never_debugging), and the expr truthiness rule ('non-zero counts as valid'). This informs the agent about failure modes the annotations don't cover.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is dense but front-loaded with the core purpose and never pads. Every sentence earns its place given the four-state semantics, timer defaults, return-value explanation, and sibling distinction. Only the trailing empty '【调用示例】{}' is mildly redundant; overall this is efficient, not bloated.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a complex poll-with-timeout tool having 4 parameters, 4 states, expr syntax, and a sibling to disambiguate, the description covers everything an agent needs: what it does, valid states, expr format, defaults, return values with timeout_kind meanings, and when not to use it. The presence of an output schema covers return structure, and the description adds the semantic layer on top.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0% and no parameter has enums, so the description carries the full burden — and it delivers. It explains every state value's meaning, the expr format with working examples (expr="uwTick > 1000"), the non-zero truth rule, and restates defaults (timeout_s=10, poll_ms=200). The description fully compensates for the empty schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
States a specific verb with a defined resource ('poll-wait for target to enter a state') and fully enumerates the valid states (stopped, running, not_debugging, expr) with inline semantics. It explicitly differentiates itself from sibling wait_breakpoint ('don't use it as a replacement'), so an agent can select it without inspecting either schema.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Gives explicit when-to-use guidance ('wait for flag / variable change / target stopping') AND explicit when-not-to ('don't replace wait_breakpoint', which is called out by name with the reason: breakpoint id + hit count is more reliable than polling PC). The alternative tool is named and the discriminating condition is stated directly.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
write_mem写入目标内存ADestructiveIdempotent
向指定内存地址写入字节。data_hex 为十六进制字节串(偶数长度),如 'de ad be ef' 或 'deadbeef'(自动去空格)。返回实际写入长度,并默认做写后回读校验(verify=true,返回 verified/readback_hex):并发写入、目标运行中、或写只读/未擦写区域时,写入可能被静默忽略——verified=false 即明确告诉你「写下去了但没生效」,不要据此推断目标行为(如误判为看门狗复位)。addr 支持十六进制/十进制/符号名。运行态写入(running,默认 "live"):目标全速运行时也能写(回读校验会告诉你有没有落地),但写入可能被 CPU 后续改写或缓存回行覆盖;要确保写进去就生效,用 running="halt"(停-写-回读-走,返回 paused_ms / was_running / resumed / halt_note)。写外设寄存器/关键内存有副作用,写入前确认地址与值正确(可先 read_mem 备份)。 【参数】必填: addr, data_hex;可选: verify, running 【调用示例】{"addr": "0x20000000", "data_hex": "deadbeef"} 【风险】高——不可逆:会改写目标 Flash/内存,或关闭/重启用户的 Keil 实例。执行前确认目标与工程正确。 【参数别名】addr ← address/expression/location/name/pc/symbol/target;data_hex ← bytes/data/hex/value。规范名以上方【参数】行为准;未列出的参数名会被拒绝,不会静默忽略
| Name | Required | Description | Default |
|---|---|---|---|
| addr | Yes | ||
| verify | No | ||
| running | No | live | |
| data_hex | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Beyond the destructiveHint annotation, it discloses that writes can be silently ignored under concurrency/running/read-only/unerased conditions, that verified=false means the write did not land, and that live writes may be overwritten by the CPU or cache lines. It also discloses side effects including closing or restarting Keil instances.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Dense but well organized: purpose, verification semantics, running modes, parameter block, example, risk warning, and aliases. Nothing feels like filler, and the most important scoping/risk information appears early.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
It covers behavior, result semantics, side effects, return fields, and failure modes, which is strong for a complex destructive operation. It does not explicitly state prerequisites such as requiring an active debug session or connected target, a minor gap compared with the richness of the rest.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
With 0% schema description coverage, the description fully compensates: it explains addr accepts hex/decimal/symbol names, data_hex must be even-length hex with spaces optionally stripped, verify defaults to true, and running selects live vs halt behavior. Aliases and a concrete JSON example further reduce ambiguity.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Opens with a concrete verb and resource: write bytes to a specified memory address. It is clearly distinguished from read_mem and other debug-control siblings, and the rest of the text is entirely on-topic.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Gives explicit when-to-use guidance: it warns that live writes may be overwritten and directs use of running="halt" when guaranteed effect is required, and points to read_mem for backup. It also says not to interpret verified=false as target behavior such as watchdog reset, an explicit misuse exclusion.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
44 tool updates
v0.1.8- First observed
batch_debug_script - First observed
calc_expression - First observed
capabilities - First observed
clear_all_breakpoints - First observed
clear_breakpoint - First observed
close_uvision - First observed
diagnose - First observed
dismiss_dialog - First observed
enter_debug - First observed
env_check - First observed
exit_debug - First observed
get_status - First observed
get_version - First observed
keil_command - First observed
keil_health - First observed
launch_uvision - First observed
list_breakpoints - First observed
list_symbol_projects - First observed
list_tools - First observed
list_uvision_instances - First observed
mdk_guide - First observed
read_async_messages - First observed
read_console_output - First observed
read_mem - First observed
read_variable - First observed
reset - First observed
reset_connection - First observed
restart_keil - First observed
run - First observed
run_timeout - First observed
session_state - First observed
set_breakpoint - First observed
set_symbol_file - First observed
step - First observed
stop - First observed
target_info - First observed
tools_groups - First observed
tools_load - First observed
toolset - First observed
view_guide - First observed
view_render - First observed
wait_breakpoint - First observed
wait_state - First observed
write_mem
TDQS
Scored across 44 tools
绝大多数工具都有清晰不同的目标,例如 set_breakpoint、clear_breakpoint、list_breakpoints 分别独立;但存在少量概念重叠,如 read_console_output 与 read_async_messages、calc_expression 与 read_variable、wait_breakpoint 与 wait_state,不过描述中明确区分了它们各自的适用场景。keil_command 作为通用后备工具,覆盖范围广,但被定义为万能的兜底,所以整体仍可区分。
工具名称基本遵循 动词_名词 的下划线风格,如 set_breakpoint、list_symbol_projects、enter_debug 等,但存在少量例外,如 keil_command、env_check、mdk_guide 没有严格的动词前置,命名风格略有混用。总体一致,没有大小写混淆,可读性好。
44 个工具数量明显偏多,超出了建议的 3-15 个常规范围,但服务器提供了工具分组机制(core、mem、symbol、serial 等)和按需加载工具(toolset、tools_load),以减轻上下文负担。考虑到涉及 Keil 调试的全面功能(会话、内存、符号、断点、Keil 管理、批处理等),该数量还算契合整体目的,但仍有精简空间。
该工具面覆盖了嵌入式调试的完整生命周期:调试会话管理(enter/exit/run/stop/step/reset)、内存和变量读写(read_mem、write_mem、calc_expression、read_variable)、断点操作(set/clear/list/all-clear)、符号文件管理(set_symbol_file、list_symbol_projects)、诊断聚合(diagnose、env_check、target_info)、Keil 实例管理(launch/close/restart/health)、批处理执行以及会话持久化(session_state)。没有明显缺失的关键操作。
Maintenance
Related MCP Connectors
MCP server for progressive tool usage at any scale (see https://klavis.ai)
Flash and run real firmware on physical embedded dev boards from an AI agent, over MCP.
- ArcjetOAuthcom.arcjet
An MCP server for Arcjet - the runtime security platform that ships with your AI code.
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Related MCP Servers
- AlicenseAqualityDmaintenanceAn MCP server that enables AI assistants to control GDB debugging sessions, including breakpoint management, thread analysis, and variable inspection, using the GDB/MI protocol.221MIT
- AlicenseAqualityCmaintenanceStateful 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.4110MIT
- AlicenseNot gradedqualityCmaintenanceAn MCP server that provides comprehensive debugging capabilities for J-Link debuggers, enabling memory, flash, register, and RTT operations through AI assistants.34MIT
- AlicenseCqualityAmaintenanceMCP server for AI-assisted MCU and embedded firmware debugging. It connects to real hardware via debug probes, inspects CPU/memory/peripherals, manages Keil builds, and provides structured evidence for fault diagnosis.196MIT