Skip to main content
Glama

一键诊断当前现场

diagnose
Read-onlyIdempotent

Collect CPU registers, disassembly, source context, call stack, local variables, and key globals into one structured report, so you can pinpoint where code is stuck without multiple debugger calls.

Instructions

聚合一次排查所需的所有现场信息: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。规范名以上方【参数】行为准;未列出的参数名会被拒绝,不会静默忽略

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fullNo强制返回全量:忽略 compact/max_lines 与对应环境变量的默认值。当上面两项让你只看到部分数据、而你要据此下结论时,用它取回完整结果。
compactNo精简返回体:去掉空值字段,把列表元素中取值完全相同的字段提到 output.shared,并把 usage/note/hints 之类**说明性**长文本截断到 200 字符(数值与内容字段不动)。被裁掉的东西都会列在 output 里,绝不静默丢弃。不传则不改行为(受 MDKDEBUG_COMPACT 影响)。
globalsNo
max_linesNo限制返回的列表条数(只作用于元素为对象的列表,如 results/items/tools):最多 N 条,其余丢弃并在 output.truncated/dropped/hint 里如实上报。0 或省略=不限(受 MDKDEBUG_MAX_LINES 影响)。
disasm_countNo
source_contextNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.8

TDQS

A4.3/5.0
Behavior5/5

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.

Conciseness4/5

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.

Completeness4/5

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.

Parameters3/5

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.

Purpose5/5

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.

Usage Guidelines4/5

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.