Skip to main content
Glama
smk-h

embedded-mcp-toolkit

by smk-h

serial_exec

Send a command to a serial shell session and wait for its output, using automatic completion detection. Enables reliable interactive control of remote embedded devices via serial console.

Instructions

Send a command to a serial shell session and wait for the output. Combines write + read in one call, with automatic completion detection (marker/prompt). IMPORTANT: Do NOT issue concurrent commands to the same session_id — the serial console is a single channel; concurrent calls will interleave output and corrupt results. Always wait for the previous command to finish before sending the next one. If you need parallel execution, open multiple sessions via serial_open.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
clearNoBuffer clear flag: 1 (default) = clear buffer before collecting, 0 = append to buffer
commandYesThe command to send to the shell
timeoutMsNoExecution cap in ms — MANDATORY on every call: estimate the command's expected runtime and pass it; omit it ONLY when the user explicitly says not to pass a timeout. Suggested estimates: basic instant commands (ls/pwd/echo/cat small files/ip addr/uname) 3000-5000, never above 10000; output-heavy commands (cat large files, dmesg/journalctl with long output, log dumps) 20000-30000; medium tasks (apt install, dd, service restart) 30000-120000; reboot/reset/power-cycle up to 120000; streaming/resident commands (ping/logcat/top, or sampling a fixed window of live output) 10000 (Ctrl+C auto-sent to stop). Do NOT pass 300000 — the 5-minute value is the internal safety-valve fallback only, not a suggested estimate; if a command genuinely needs longer than ~2min, pass an explicit larger value. If omitted, safety-valve defaults apply: resident commands 10000ms (sampling, Ctrl+C sent on timeout), other commands 300000ms (5min fallback, NO interrupt sent — the command may still be running, terminate via send_ctrl if needed). Timeout type is annotated in the returned output.
session_idYesThe session ID returned by serial_open

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv2.0.0
    • removedInput schema / properties / delay
      Removed value: -{
      -  "description": "Minimum polling duration in milliseconds (default: 1000), kept for backward compat",
      -  "type": "number"
      -}
    • removedInput schema / properties / maxDuration
      Removed value: -{
      -  "description": "Execution cap in ms — ALWAYS estimate and pass a timeout matching the command's expected runtime; do not omit it. Suggested ranges: instant info commands (ls/ip addr/cat/echo) 3000-5000; medium tasks (apt install, dd, service restart) 30000-120000; long builds/flashes (make, flash_image) up to 600000; streaming/resident commands (ping/logcat/top, or sampling a fixed window of live output) 10000 (Ctrl+C auto-sent to stop). If omitted, safety-valve defaults apply: resident commands 10000ms (sampling, Ctrl+C sent on timeout), other commands 300000ms (5min fallback, NO interrupt sent — the command may still be running, terminate via send_ctrl if needed). Timeout type is annotated in the returned output.",
      -  "type": "number"
      -}
    • addedInput schema / properties / timeoutMs
      Added value: +{
      +  "description": "Execution cap in ms — MANDATORY on every call: estimate the command's expected runtime and pass it; omit it ONLY when the user explicitly says not to pass a timeout. Suggested estimates: basic instant commands (ls/pwd/echo/cat small files/ip addr/uname) 3000-5000, never above 10000; output-heavy commands (cat large files, dmesg/journalctl with long output, log dumps) 20000-30000; medium tasks (apt install, dd, service restart) 30000-120000; reboot/reset/power-cycle up to 120000; streaming/resident commands (ping/logcat/top, or sampling a fixed window of live output) 10000 (Ctrl+C auto-sent to stop). Do NOT pass 300000 — the 5-minute value is the internal safety-valve fallback only, not a suggested estimate; if a command genuinely needs longer than ~2min, pass an explicit larger value. If omitted, safety-valve defaults apply: resident commands 10000ms (sampling, Ctrl+C sent on timeout), other commands 300000ms (5min fallback, NO interrupt sent — the command may still be running, terminate via send_ctrl if needed). Timeout type is annotated in the returned output.",
      +  "type": "number"
      +}
  2. Changed1 schema field changedv1.3.0
    • changedInput schema / properties / maxDuration / description
      Previous value: -"Override execution duration in ms. Default varies by command type: resident commands (ping/logcat/top/...) 10000 (sampling, Ctrl+C sent on timeout), normal commands 300000 (5min fallback, no interrupt sent). Action on timeout still follows resident classification regardless of this value."New value: +"Execution cap in ms — ALWAYS estimate and pass a timeout matching the command's expected runtime; do not omit it. Suggested ranges: instant info commands (ls/ip addr/cat/echo) 3000-5000; medium tasks (apt install, dd, service restart) 30000-120000; long builds/flashes (make, flash_image) up to 600000; streaming/resident commands (ping/logcat/top, or sampling a fixed window of live output) 10000 (Ctrl+C auto-sent to stop). If omitted, safety-valve defaults apply: resident commands 10000ms (sampling, Ctrl+C sent on timeout), other commands 300000ms (5min fallback, NO interrupt sent — the command may still be running, terminate via send_ctrl if needed). Timeout type is annotated in the returned output."
  3. Addedv1.0.3
  4. Removedv1.0.1
  5. Changed2 schema fields changedv1.0.1
    • changedInput schema / properties / delay / description
      Previous value: -"Wait time in milliseconds before reading output (default: 1000)"New value: +"Minimum polling duration in milliseconds (default: 1000), kept for backward compat"
    • addedInput schema / properties / maxDuration
      Added value: +{
      +  "description": "Max execution time in ms before auto-interrupting with Ctrl+C (default: 10000)",
      +  "type": "number"
      +}
  6. First observedv0.2.2

TDQS

A5/5.0
Behavior5/5

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

With no annotations provided, the description bears the full burden of behavioral disclosure, and it delivers: it exposes the single-channel interleaving hazard, automatic completion detection, timeout safety-valve defaults, Ctrl+C auto-send for resident commands, and the fallback to send_ctrl. This is unusually transparent for a serial execution tool.

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?

The main description is front-loaded and every sentence earns its place: purpose, completion detection, and the critical concurrency warning. The lengthy timeoutMs guidance is dense, categorized, and necessary for correct invocation rather than filler. The structure is practical and scannable.

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?

For a tool with no annotations and no output schema, the description covers the non-obvious aspects an agent needs to call it safely: concurrency constraints, timeout selection, completion detection, resident-command behavior, and recovery via send_ctrl. The only minor omission is a detailed return-format description, but 'wait for the output' plus the note that timeout type is annotated in returned output are sufficient for selection and invocation.

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?

Schema coverage is already 100%, but the description adds substantial meaning, especially for timeoutMs: suggested ranges by command type, warning against 300000, and default behaviors when omitted. It also clarifies the clear flag's role ('clear buffer before collecting' vs 'append to buffer') indirectly through schema context, though the main added value is the timeout guidance.

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: 'Send a command to a serial shell session and wait for the output.' It further distinguishes itself from sibling serial_write/serial_read by stating it 'Combines write + read in one call, with automatic completion detection.' An agent can clearly tell this from the other serial and shell tools.

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?

It explicitly warns against concurrent commands on the same session_id, instructs the agent to wait for prior commands, and gives the exact alternative for parallel needs: 'open multiple sessions via serial_open.' This provides clear when-to-use and when-not-to-use guidance beyond any schema field.

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