Skip to main content
Glama

写入目标内存

write_mem
DestructiveIdempotent

Write bytes to a memory address with readback verification, confirming the write actually took effect; optionally halt the target to ensure the write lands.

Instructions

向指定内存地址写入字节。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。规范名以上方【参数】行为准;未列出的参数名会被拒绝,不会静默忽略

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addrYes
verifyNo
runningNolive
data_hexYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.8

TDQS

A4.9/5.0
Behavior5/5

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.

Conciseness5/5

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.

Completeness4/5

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.

Parameters5/5

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.

Purpose5/5

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.

Usage Guidelines5/5

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.