plctap
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
| PLCTAP_ALLOW_WRITE | No | Write tools are not registered by default (safety gate). Set to 'true' to enable write tools. | false |
| PLCTAP_IDLE_TIMEOUT_SEC | No | Idle connection reclamation seconds. | 30 |
| PLCTAP_DEFAULT_TIMEOUT_MS | No | Network timeout in milliseconds. | 2000 |
| PLCTAP_POOL_MAX_PER_TARGET | No | Maximum connection pool size per target. | 2 |
Instructions
Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.
This server publishes no instructions, or was last inspected before Glama recorded them.
Capabilities
Features and capabilities supported by this server
Protocol revision2025-11-25
| Capability | Details |
|---|---|
| tools | {
"listChanged": true
} |
| logging | {} |
| prompts | {
"listChanged": false
} |
| resources | {
"subscribe": false,
"listChanged": false
} |
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| list_protocolsA | 列出本 server 支持的工业协议及其能力。 返回每个协议的端口提示、地址模型、数据类型和品牌线索, Agent 可据此推断 "这个设备该用什么协议" 而无需问用户。 不确定协议名时先调用本工具。 不确定协议/端口时先调用 detect_device。 |
| probe_deviceA | 测试能否连上 PLC 并通信, 失败时给出层级归因。 reachable = 传输层可达 (TCP 已建立; 设备回异常响应也算在线)。 failure_class 取:
|
| plc_readA | 从 PLC 读取数据区并按数据类型解释。 address/count 为通用地址与数量, 语义由协议决定:
datatype 取 uint16/int16/float32, None 返回原始 16 位值 + 所有常见数据类型的多解释 (interpretations 字段), 便于 Agent 识别正确的数据类型。 byteorder 仅影响 float32 寄存器对顺序 (big=ABCD, little=DCBA)。 options: 协议特有参数, 由各协议 adapter 自行定义与校验。 用 list_protocols 查看每个协议的 read_options 说明。 |
| plc_browseA | 浏览地址空间: 从 node 展开一层子节点 (诊断场景的"列目录")。 返回 {node, children, total, shown, truncated}: children 每项含 node_id / display_name / node_class; 超出输出预算时 truncated=true 且 total 给出全量数 —— 需要更深层级就对着子 node_id 再调一次。 默认从 Objects 文件夹 (ns=0;i=85) 起步; 对 plc_read 前先摸清 设备地址空间结构时用。 当前仅 OPC UA 支持 (会话协议无帧概念, browse 是它的"读目录"形态); 其他协议用 list_protocols 的 read_options 直接构造地址。 输出预算: 单次最多 200 个子节点 (约 30KB), 防止大地址空间撑爆上下文。 |
| diagnoseA | 综合观测给出结构化的故障候选结论 (确定性规则, 不编故事; 全程只读)。 三种证据可任意组合 (至少给一种):
|
| parse_frameA | 把一帧报文 hex 逐字段结构化解析 (不需要连接设备)。 每个字段带 byte_offset 与 raw_hex 证据; 支持正常请求/响应与异常 响应帧; 畸形帧不抛错, 而是尽量解析并在 errors 里说明哪里坏 —— "解析失败的方式"本身是诊断证据。 direction: "auto" 按帧结构判别, 也可显式传 "req" / "resp"。 frame_format (仅 melsec): "3e_binary" / "3e_ascii" / "4e_binary" / "4e_ascii"。
|
| validate_frameA | 对一帧报文跑规范校验清单, 逐项 pass/fail (不需要连接设备)。 Modbus TCP: MBAP 长度一致性、协议号、功能码、unit 范围、PDU 自洽、数量/地址边界、异常码 (Modbus TCP 无 CRC, RTU 才有)。 FINS/TCP: magic、TCP 长度自洽、TCP 命令合法、error 字段、 FINS 端结码、载荷完整性。 MELSEC 3E: 副头部、数据长度自洽、命令/软元件代码、结束代码。 direction 取 req 或 resp。 |
| parse_pcapA | 解析 Wireshark 导出 pcap: 按 TCP 流聚合载荷 -> 按协议切帧 -> 逐帧 parse_auto。 每个流返回完整帧序列 (带结构化解析) 与尾部半帧 (partial, 截断也是 诊断信息)。protocol 缺省时按"完整帧数最多的协议"自动判别。 需要可选依赖 scapy (uv sync --extra eval)。大批量帧场景比逐条 frame_hex 高效得多。 输出受 64KB token 预算约束: 超出时按流序/帧序装帧并截断, 末尾追加 一条 flow 以 "truncated:" 开头的 sentinel 流 (frames 为空, 带 total/shown 计数)。需要其余帧时用 protocol= 过滤或拆分 pcap 再解析。 |
| start_listenerA | 起钓鱼模式监听: 待测设备只能当 client 时, 立假 server 钓出它的帧行为。 mode 三档: record_only=只收帧不回复 (纯被动) / respond_normal=对读类 请求回最小"正常响应" (数据恒 0, 目的只是让设备继续吐帧, 非通用模拟器) / inject_errors=正常回帧但按 faults 列表轮转注入确定性故障 (评测语料 生产 + 诊断引擎回归)。 faults (仅 inject_errors): modbus 可选 exception/bad_length/truncate, fins/melsec 可选 end_code/bad_length, 全协议通用 garbage。 收下的帧用 get_listener_frames 取, 再喂 parse_frame/diagnose。 port=0 由系统分配, 返回实际端口。建议收满样本后 stop_listener, 并提醒用户恢复设备原配置。 |
| stop_listenerA | 停掉指定端口的监听, 返回收/发帧统计。 |
| get_listener_framesA | 取监听收下的帧 (direction/peer/frame_hex), 供 parse_frame/diagnose 分析。 取最新 limit 条; 环形缓冲硬上限 1000 条 (limit 超限自动截到缓冲 大小, limit<=0 返回空) —— 输出量受 limit 与缓冲上限双重约束。 |
| start_proxyA | 起透明代理: 上位机 → 代理 → 真实 PLC, 透传同时按协议分帧录制双向帧。 现场联调时把上位机目标地址改成本代理, 无需 Wireshark 即可拿到全部 交互帧 (get_proxy_frames), 再喂 parse_frame/diagnose 做在线分析。 protocol 当前支持 modbus/fins/melsec (S7 TPKT 分帧暂不支持); listen_port=0 由系统分配。代理是诊断设施: 只透传与录制, 不改写帧。 |
| stop_proxyA | 停掉指定端口的代理, 返回录制统计 (c2s/s2c 帧数)。 |
| get_proxy_framesA | 取代理录制的双向透传帧 (direction: c2s=上位机→PLC, s2c=PLC→上位机)。 取最新 limit 条; 环形缓冲硬上限 1000 条 (limit 超限自动截到缓冲 大小, limit<=0 返回空)。 |
| detect_deviceA | 设备自动识别: 给定 host 自动扫端口并判定协议 (v0.4, 全程只读)。 流程: 并发扫描候选端口 (缺省 102/502/2000/2404/44818/4840/5007/6000/9600/9601, 单端口连接预算 0.5s) -> 开放端口并发跑已注册协议 probe 指纹 (单协议预算 timeout_ms/1000, 缺省 0.8s; 个别协议有独立预算如 opcua 的完整会话握手) -> high 候选按协议做一次最小读验证 (deep=True 缺省; 成功升级 verified, 失败留痕保持 high; deep=False 跳过验证读)。 只读保证: 全程只发握手帧 + 最小读帧, 不写任何数据; 且识别 ≠ 可访问 —— 例如 S7 PUT/GET 被关闭时识别照样成功, 读 DB 仍可能失败。 返回 DetectResult: candidates 按置信度降序 (同级先验匹配端口优先, next_step 可直接作为 plc_read 调用), unknown_services 为开放但 已注册协议都不认识的端口 (可用 start_listener 钓帧分析)。 |
Prompts
Interactive templates invoked by user choice
| Name | Description |
|---|---|
No prompts | |
Resources
Contextual data attached and managed by the client
| Name | Description |
|---|---|
No resources | |
TDQS
Scored across 15 tools
Each tool targets a distinct diagnostic phase: protocol listing, frame parsing/validation, live probing, data reading/browsing, capture via proxy/listener, and final diagnosis. Even the two capture retrieval tools (get_proxy_frames vs get_listener_frames) are clearly separated by capture source, and parser/validator/diagnose have non-overlapping purposes.
Most tools follow a clear verb_noun snake_case pattern (list_protocols, validate_frame, probe_device, parse_frame, start_listener, stop_proxy). The only minor deviation is plc_read and plc_browse, which invert the pattern to noun_verb, but the pair is internally consistent and still readable.
15 tools is at the upper edge of the well-scoped range but every tool earns its place in the diagnostic workflow: detection, parsing, validation, capture, reading, browsing, and analysis. There is no redundancy or padding, and the count matches the breadth of the industrial protocol domain.
The tool surface covers the full diagnostic lifecycle: detect/probe devices, parse and validate frames, capture live traffic via proxy or listener, retrieve captured frames, browse address spaces, read PLC data, and produce structured diagnoses. The read-only focus is consistent and intentional, with no dead ends in the workflow.