Skip to main content
Glama

Parse Frame

parse_frame
Read-onlyIdempotent

Parse protocol frame hex into structured fields with byte offsets and raw hex evidence, automatically detecting direction for Modbus, FINS, MELSEC, and S7. Handles malformed frames without errors, providing diagnostic details.

Instructions

把一帧报文 hex 逐字段结构化解析 (不需要连接设备)。

每个字段带 byte_offset 与 raw_hex 证据; 支持正常请求/响应与异常 响应帧; 畸形帧不抛错, 而是尽量解析并在 errors 里说明哪里坏 —— "解析失败的方式"本身是诊断证据。 direction: "auto" 按帧结构判别, 也可显式传 "req" / "resp"。 frame_format (仅 melsec): "3e_binary" / "3e_ascii" / "4e_binary" / "4e_ascii"。

  • modbus: 异常帧/非 12 字节按响应, 12 字节按请求 (fc05/06 的响应 与请求逐字节相同, 任一解释一致)

  • fins: TCP 命令 0x00 按请求 / 0x01、0x02 按响应; 0x04 按 FINS ICF bit6 判别 (响应置位)

  • melsec: 副头部 50 00/54 00 按请求, D0 00/D4 00 按响应 (ASCII 帧 "5000"/"5400"/"D000"/"D400" 同理)

  • s7: rosctr=0x01 (Job) 按请求, 0x03 (Ack_Data) 按响应; 显式传 direction 时按传入值

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
protocolYes
directionNoauto
frame_hexYes
frame_formatNo3e_binary

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
validNo
errorsNo
fieldsNo
protocolYes
directionYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.4.0

TDQS

A4.6/5.0
Behavior4/5

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 safety profile is covered. The description adds valuable behavioral context beyond annotations: it states that malformed frames are parsed best-effort and errors are reported as diagnostic evidence, that direction auto-detection follows protocol-specific heuristics, and that explicit direction overrides auto-detection. It does not describe output structure in detail, but an output schema exists, so that burden is reduced. Minor gap: no mention of rate limits or large-frame handling, but not essential for a read-only parser.

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 dense but well-structured: a one-sentence summary, then a paragraph on error behavior, then a bulleted list of protocol-specific direction rules. Every sentence earns its place, and the most important scoping info (no device connection, structured parsing) is front-loaded. It is longer than the typical description, but the length is justified by the protocol-specific rules that are essential for correct invocation. Slight deduction for density that may require careful reading.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (4 protocols, direction auto-detection, malformed-frame handling) and the presence of an output schema, the description is complete. It covers what the tool does, when to use it, how parameters behave, and what happens on malformed input. The output schema handles return-value documentation. An agent has everything needed to select and invoke this tool correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

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 the direction parameter's 'auto' default and explicit 'req'/'resp' values, and it explains frame_format's allowed values ('3e_binary'/'3e_ascii'/'4e_binary'/'4e_ascii') and that it only applies to melsec. It does not explain protocol or frame_hex in detail, but those are self-evident from the tool name and description. The description adds meaning beyond the bare schema, though it could have explicitly listed protocol values.

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 opens with a specific verb and resource: '把一帧报文 hex 逐字段结构化解析' (parse a frame's hex into structured fields per field), and immediately distinguishes itself from device interaction by noting '不需要连接设备' (no device connection needed). It clearly differentiates from siblings like validate_frame (which validates) and parse_pcap (which parses captures), and the protocol-specific direction rules further clarify its scope.

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?

The description provides explicit when-to-use guidance: it handles normal request/response frames and abnormal response frames, and it explicitly states that malformed frames do not throw but are parsed best-effort with errors reported. It also gives detailed protocol-specific direction auto-detection rules for modbus, fins, melsec, and s7, and notes that frame_format only applies to melsec. This is far beyond minimal usage guidance.

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