Skip to main content
Glama
zademy
by zademy

Batch Execute & Search

ctx_batch_execute
Destructive

Run multiple related commands in one call, auto-index their output, and pass queries to get matching sections back in the same round trip—avoiding sequential command runs.

Instructions

Run multiple commands in ONE call. Every command's output is auto-indexed into the knowledge base; pass queries and the matching sections come back in the same round trip. Concurrency parallelizes the fetch phase only — derivation still belongs in code, so add a processing command that consumes indexed output and prints just the answer.

WHEN:

  • You have 3+ related commands you would otherwise run sequentially (multi-issue lookups, git log + diff + blame, multi-file reads, multi-region cloud queries)

  • You want to gather AND query in one round trip — pass queries so matching sections come back inline

  • You want to parallelize I/O-bound work — pass concurrency 2-8 (network calls, gh CLI, cloud APIs, multi-repo git reads)

  • Combined output is large enough that a later ctx_search pass would itself be expensive

WHEN NOT:

  • Single command with no follow-up query — run it in the sandbox tool directly

  • CPU-bound or stateful commands — keep concurrency at 1 (npm test, build, lint, port-binding servers, lock-file holders, anything racing on the same resource)

RETURNS: Auto-indexed section list per command label, plus top matches per query. Raw output is NOT echoed in full.

EXAMPLE: ctx_batch_execute( commands: [ {label: "issue 1", command: "gh issue view 1"}, {label: "issue 2", command: "gh issue view 2"} ], queries: ["root cause", "proposed fix"], concurrency: 2 )

Input Schema

NameRequiredDescriptionDefault
cwdNoOptional working directory for all shell commands in this batch.
queriesYesSearch queries to extract information from indexed output. Use 5-8 comprehensive queries. Each returns top 5 matching sections with full content. This is your ONLY chance — put ALL your questions here. No follow-up calls needed.
commandsYesCommands to execute as a batch. Output is labeled with the section header. Default order is sequential; pass concurrency>1 to run in parallel (output stays in input order).
timeoutMsNoMax execution time in MILLISECONDS — timeoutMs: 120000 is two minutes, timeoutMs: 120 is 0.12 seconds. When omitted, the host's own RPC timeout governs where it has one; on hosts that do not bound a call (Pi, Antigravity CLI) a generous server-side default applies per command. With concurrency=1, a value you pass is a shared budget across commands; with concurrency>1, it is applied per-command.
concurrencyNoMax commands to run in parallel (1-8, default: 1). Use 4-8 for I/O-bound batches (network, gh, curl, multi-repo git reads). Keep at 1 for CPU-bound (npm test, build, lint) or stateful commands (ports, locks). >1 switches to per-command timeouts (no shared budget) and individual `(timed out)` blocks instead of cascading skip.
query_scopeNoScope for `queries` (default: `batch`). `batch` searches ONLY the chunks produced by this batch's commands — useful when you want answers about the just-fetched output. `global` searches the entire persistent index (same scope as ctx_search) — useful when you want the batch commands to enrich context and the queries to also surface related prior knowledge in one round trip.batch

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv2.0.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=false, destructiveHint=true and openWorldHint=true, so the safety profile is covered. The description adds genuinely useful behavior the annotations cannot convey: output is auto-indexed rather than echoed in full, concurrency parallelizes only the fetch phase, and derivation should be a separate processing command. It does not warn about side effects of arbitrary shell execution, which the destructive annotation implies but never explains.

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?

Front-loaded with the core action, then cleanly partitioned into WHEN / WHEN NOT / RETURNS / EXAMPLE blocks, so scannability is high. It is on the long side for an MCP description and the EXAMPLE partly repeats the schema, but nearly every line carries routing or behavioral value.

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 six-parameter, no-output-schema tool that spawns arbitrary shell commands, the description covers returns (indexed sections plus top query matches, raw output not echoed), concurrency semantics, timeout switching between shared and per-command budgets, and a worked example — everything an agent needs to invoke it 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 coverage is 100%, so the baseline is 3, but the description adds real guidance beyond it: a strategy for `queries` ('use 5-8 comprehensive queries', 'your ONLY chance'), a narrower concurrency range than the schema's 1-8 (2-8 for I/O-bound), and the rule that derivation belongs in code rather than in the queries. Minor tension in the concurrency range but not a real conflict.

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 opening sentence states a specific verb and scope ('Run multiple commands in ONE call') and immediately distinguishes the tool's dual nature — batch execution plus auto-indexed search — from the single-command sibling ctx_execute. An agent can route correctly without opening the schema.

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?

Explicit WHEN/WHEN NOT sections name concrete triggers (3+ related commands, gather-and-query in one round trip, I/O-bound work) and concrete exclusions (single command with no follow-up, CPU-bound/stateful work), including the specific remedy (use the sandbox tool directly, keep concurrency at 1).

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