Skip to main content
Glama

frame_parse

Parse custom binary frames from hex data by header and length field, with optional checksum. Reports parsing failures and remaining bytes to avoid silent data loss.

Instructions

通用二进制帧解析:按「帧头 + 长度字段」切帧,可选逐帧校验。

单片机自定义协议(上位机抓到的 hex 流)对不上时用。参数都能少填就少填: frame_parse("AA 55 04 01 02 03 04 AA 55 02 05 06") frame_parse("AA 55 04 01 02 03 04", header="AA55", checksum="sum8") frame_parse("01 03 04 00 0A 00 0B 9B F6", checksum="crc16_modbus") header 不给则须给 length_offset(长度字段相对帧首的偏移)。 checksum 可选 "none"/"sum8"/"crc16_modbus"。 ★ 切不出来(找不到帧头 / 长度越界 / 帧被截断)会逐条报出并附剩余字节, 绝不静默丢数据——静默丢帧是这类工具最危险的错。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
endianNobig
headerNo
checksumNonone
data_hexYes
max_framesNo
length_sizeNo
length_offsetNo
length_includes_headerNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full behavioral burden, and it does disclose a strong trait: failures (missing header, length out of bounds, truncated frame) are reported individually with leftover bytes and never silently dropped. That is exactly the kind of context an agent needs. It does not mention the max_frames cap or how endianness/length_size affect parsing, so it is not fully complete.

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?

Front-loads the mechanism, follows with a tight when-to-use line, then three illustrative one-line calls, and closes with the critical no-silent-drop warning. Every element earns its place and the examples substitute effectively for prose parameter explanations.

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?

An output schema exists, so return values need no prose. The description covers purpose, use condition, the header/length_offset dependency, checksum options, and error behavior, which is strong for an 8-param tool. The remaining gap is the four undocumented tuning parameters (endian, max_frames, length_size, length_includes_header).

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 description coverage is 0% across 8 parameters, so the description must compensate and it only partly does. It explains header, length_offset (offset relative to frame start), and the checksum enum values (none/sum8/crc16_modbus), but endian, max_frames, length_size, and length_includes_header are left undocumented anywhere.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource (generic binary frame parsing) plus the mechanism (header + length field splitting, optional per-frame checksum). This implicitly distinguishes it from protocol-specific siblings like modbus_parse and nmea_parse, but never names them explicitly, so an agent must infer the boundary.

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?

Gives a concrete use condition: custom MCU protocol hex streams that don't line up. It also states the parameter-filling advice (fill as little as possible) and the header/length_offset dependency. It stops short of explicitly routing to or away from the sibling parsers (modbus_parse, nmea_parse), so alternatives are implied rather than stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.