execute_and_capture
Run a shell command, capture its stdout/stderr into a searchable buffer, and get a compact JSON summary with status, duration, and token counts—avoiding prompt flooding from noisy output.
Instructions
Runs a shell command, captures stdout/stderr, indexes it, and returns a compact versioned JSON summary without flooding the prompt context with thousands of lines. The summary includes status, duration, sizes, approximate token counts, truncation, signals, and optional named metrics.
Use this for noisy tests, builds, logs, and other output that benefits from
bounded capture and later search. Direct command execution is usually
faster for a small, targeted inspection; use capture once output may be
noisy, large, or uncertain. This is an advisory routing heuristic, not an
enforced threshold. Before running, verify the
command, intended repository, and working directory: an omitted cwd
inherits the server process directory, and symlinks or shell expansion can
target a different path than expected. This tool bounds output but does
not validate command intent, path identity, or filesystem safety.
Args: command: Shell command line to execute. cwd: Optional working directory for command execution; pass an explicit validated path for repository-sensitive commands. label: Optional human-readable description/label for this capture. content_type: Content type hint - 'auto' (default, detects diff/log/text), 'diff', 'log', or 'text'. max_output_bytes: Maximum command output retained (default: configured buffer byte limit). timeout_seconds: Optional maximum runtime; timed-out commands return exit code 124.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cwd | No | ||
| label | No | ||
| command | Yes | ||
| content_type | No | auto | |
| timeout_seconds | No | ||
| max_output_bytes | No | ||
| structured_metrics | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |