Skip to main content
Glama
smk-h

embedded-mcp-toolkit

by smk-h

adb_shell_exec

Run ADB shell commands and retrieve their output using marker-based completion detection. Send one command per session at a time; open extra sessions for parallel tasks.

Instructions

Send a command to an ADB 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 ADB shell 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 adb_shell_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 adb_shell_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. First observedv0.2.2

TDQS

A4.4/5.0
Behavior4/5

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

With no annotations present, the description carries the behavioral disclosure burden. It does well by revealing the single-channel constraint, the risk of output interleaving/corruption, and the automatic completion-detection (marker/prompt) mechanism. It does not mention timeout fallback behavior or what happens when a command keeps running, though the timeoutMs parameter description covers much of that detail.

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 description is concise and front-loaded: first sentence states the action, second explains the combined write+read behavior, and the IMPORTANT warning is clearly separated. Every sentence earns its place without fluff.

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?

For a command-execution tool with no output schema, the description provides the critical context: it returns the command output, detects completion, and warns about serialization. The timeoutMs parameter description adds deep guidance on duration estimates. The only minor gap is not describing the exact output format (e.g., combined stdout/stderr or exit code), but the description is otherwise sufficient.

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 100%, including rich timeoutMs guidance, so the schema already carries the parameter meaning. The main description adds little about parameters beyond saying a command is sent, but the baseline of 3 is appropriate because the schema fully documents session_id, command, clear, and timeoutMs.

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 states a specific verb and resource: 'Send a command to an ADB shell session and wait for the output.' It also clarifies how it differs from sibling read/write tools by saying it 'Combines write + read in one call' with automatic completion detection. This makes the tool's role unambiguous and distinguishable from adb_shell_write, adb_shell_read, and adb_shell_send_ctrl.

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 gives explicit concurrency guidance: do not issue concurrent commands to the same session, wait for the previous command to finish, and open multiple sessions via adb_shell_open for parallel execution. It also clearly frames the tool as a command-response wrapper rather than a raw streaming channel, which helps an agent choose between this and write/read siblings.

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