Skip to main content
Glama

Batch Execute & Search

ctx_batch_execute

Execute multiple shell commands in one call, auto-index output, and search with multiple queries to retrieve answers directly without follow-up calls.

Instructions

Execute multiple commands in ONE call, auto-index all output, and search with multiple queries. Returns search results directly — no follow-up calls needed.

THIS IS THE PRIMARY TOOL. Use this instead of multiple ctx_execute() calls.

One ctx_batch_execute call replaces 30+ ctx_execute calls + 10+ ctx_search calls. Provide all commands to run and all queries to search — everything happens in one round trip.

PARALLELIZE I/O: For I/O-bound batches (network calls, slow API queries, multi-URL fetches), ALWAYS pass concurrency: 4-8 — speeds up by 3-5x on real workloads. ✅ Use concurrency: 4-8 for: gh API calls, curl/web fetches, multi-region cloud queries, multi-repo git reads, dig/DNS, docker inspect. ❌ Keep concurrency: 1 for: npm test, build, lint, image processing (CPU-bound), or commands sharing state (ports, lock files, same-repo writes). Example: [gh issue view 1, gh issue view 2, gh issue view 3] → concurrency: 3. Speedup depends on workload — applies to I/O wait, not CPU work.

THINK IN CODE — NON-NEGOTIABLE: When commands produce data you need to analyze, count, filter, compare, or transform — add a processing command that runs JavaScript and console.log() ONLY the answer. NEVER pull raw output into context to reason over. Concurrency parallelizes the FETCH; THINK IN CODE owns the PROCESSING. One programmed analysis replaces ten read-and-reason rounds. Pure JavaScript, Node.js built-ins (fs, path, child_process), try/catch, null-safe.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
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).
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.
timeoutNoMax execution time in ms. When omitted, no server-side timer fires — the MCP host's RPC timeout governs. With concurrency=1, the value (when set) 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.
Behavior4/5

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

With no annotations, the description must disclose all behavioral traits. It explains auto-indexing, direct result return, concurrency behavior, and the 'THINK IN CODE' paradigm. While it covers most aspects, it omits details on error handling or what happens when a command fails, slightly reducing completeness.

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?

The description is structured with clear sections (primary tool, parallelize I/O, think in code) and front-loaded with purpose. While some repetition exists in the 'THINK IN CODE' section, each sentence serves a purpose and overall it is well-organized.

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?

Given no output schema and tool complexity, the description covers batch execution, search output, concurrency trade-offs, and processing paradigm. It lacks explicit error handling details and limits on commands/queries, but overall provides sufficient context for correct invocation.

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%, providing a baseline of 3. The description adds value by explaining that queries are the only chance for search, timeout behavior changes with concurrency, and concurrency examples for various workloads. This goes beyond the schema's basic descriptions.

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 clearly states the tool executes multiple commands in one call, auto-indexes output, and returns search results directly. It distinguishes itself from sibling tools like ctx_execute (single command) and ctx_search (search only), making its unique value explicit.

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 explicitly labels this as the PRIMARY tool over ctx_execute and provides detailed guidance on when to use concurrency (I/O-bound vs CPU-bound) with examples. It also instructs that queries must be comprehensive as no follow-up calls are possible.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mksglu/context-mode'

If you have feedback or need assistance with the MCP directory API, please join our Discord server