Skip to main content
Glama

Batch Read

batch_read

Read multiple files at once within a shared token budget to avoid many separate read calls; unchanged files collapse to counts or diffs using known hashes, and oversized files are skipped.

Instructions

Read several files at once under a shared token budget.

Cheaper than many single read calls. To make files searchable without reading them at all, use warm instead — this tool returns their text. Pass known_hashes and each file you still hold collapses to an unchanged count, or to a diff when it moved on disk; the rest come back in full with their content_hash. A file over max_size comes back as a map (see read) and carries none: a map is not the file. Smallest files are read first, and a file too big for the remaining budget is listed under skipped while smaller ones keep being read. Recover anything skipped with read using offset/limit. Paths are relative to the root the response names, when there is one worth naming.

Input Schema

NameRequiredDescriptionDefault
pathsYesThe files to read — a comma-separated list, a JSON array, or glob patterns (expanded for you).
priorityNoOptional paths to read first, ahead of the remaining files. Ordering only — a priority file still has to fit the budget, and is skipped like any other when it does not.
known_hashesNoJSON object mapping a path to the `content_hash` you still hold for it, e.g. `{"src/a.py": "8f3c..."}`. Any file you cannot vouch for this way is sent in full.
max_total_tokensNoTotal token budget shared across the whole batch.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv0.6.0
    • addedInput schema / properties / known_hashes
      Added value: +{
      +  "default": "",
      +  "description": "JSON object mapping a path to the `content_hash` you\nstill hold for it, e.g. `{\"src/a.py\": \"8f3c...\"}`. Any file you\ncannot vouch for this way is sent in full.",
      +  "type": "string"
      +}
    • changedInput schema / properties / priority / description
      Previous value: -"Optional paths to read first, ahead of the remaining files."New value: +"Optional paths to read first, ahead of the remaining files.\nOrdering only — a priority file still has to fit the budget, and is\nskipped like any other when it does not."
    • changedOutput schema / (root)
      Previous value: -{
      -  "properties": {
      -    "files": {
      -      "anyOf": [
      -        {
      -          "items": {
      -            "properties": {
      -              "content": {
      -                "anyOf": [
      -                  {
      -                    "type": "string"
      -                  },
      -                  {
      -                    "type": "null"
      -                  }
      -                ],
      -                "default": null,
      -                "title": "Content"
      -              },
      -              "from_cache": {
      -                "anyOf": [
      -                  {
      -                    "type": "boolean"
      -                  },
      -                  {
      -                    "type": "null"
      -                  }
      -                ],
      -                "default": null,
      -                "title": "From Cache"
      -              },
      -              "hint": {
      -                "anyOf": [
      -                  {
      -                    "type": "string"
      -                  },
      -                  {
      -                    "type": "null"
      -                  }
      -                ],
      -                "default": null,
      -                "title": "Hint"
      -              },
      -              "path": {
      -                "anyOf": [
      -                  {
      -                    "type": "string"
      -                  },
      -                  {
      -                    "type": "null"
      -                  }
      -                ],
      -                "default": null,
      -                "title": "Path"
      -              },
      -              "status": {
      -                "anyOf": [
      -                  {
      -                    "type": "string"
      -                  },
      -                  {
      -                    "type": "null"
      -                  }
      -                ],
      -                "default": null,
      -                "title": "Status"
      -              },
      -              "tokens": {
      -                "anyOf": [
      -                  {
      -                    "type": "integer"
      -                  },
      -                  {
      -                    "type": "null"
      -                  }
      -                ],
      -                "default": null,
      -                "title": "Tokens"
      -              },
      -              "truncated": {
      -                "anyOf": [
      -                  {
      -                    "type": "boolean"
      -                  },
      -                  {
      -                    "type": "null"
      -                  }
      -                ],
      -                "default": null,
      -                "title": "Truncated"
      -              }
      -            },
      -            "title": "BatchReadFile",
      -            "type": "object"
      -          },
      -          "type": "array"
      -        },
      -        {
      -          "type": "null"
      -        }
      -      ],
      -      "default": null,
      -      "title": "Files"
      -    },
      -    "skipped": {
      -      "anyOf": [
      -        {
      -          "items": {
      -            "properties": {
      -              "est_tokens": {
      -                "anyOf": [
      -                  {
      -                    "type": "integer"
      -                  },
      -                  {
      -                    "type": "null"
      -                  }
      -                ],
      -                "default": null,
      -                "title": "Est Tokens"
      -              },
      -              "hint": {
      -                "anyOf": [
      -                  {
      -                    "type": "string"
      -                  },
      -                  {
      -                    "type": "null"
      -                  }
      -                ],
      -                "default": null,
      -                "title": "Hint"
      -              },
      -              "path": {
      -                "anyOf": [
      -                  {
      -                    "type": "string"
      -                  },
      -                  {
      -                    "type": "null"
      -                  }
      -                ],
      -                "default": null,
      -                "title": "Path"
      -              },
      -              "truncated": {
      -                "anyOf": [
      -                  {
      -                    "type": "boolean"
      -                  },
      -                  {
      -                    "type": "null"
      -                  }
      -                ],
      -                "default": null,
      -                "title": "Truncated"
      -              }
      -            },
      -            "title": "BatchReadSkipped",
      -            "type": "object"
      -          },
      -          "type": "array"
      -        },
      -        {
      -          "type": "null"
      -        }
      -      ],
      -      "default": null,
      -      "title": "Skipped"
      -    },
      -    "summary": {
      -      "anyOf": [
      -        {
      -          "properties": {
      -            "files_read": {
      -              "anyOf": [
      -                {
      -                  "type": "integer"
      -                },
      -                {
      -                  "type": "null"
      -                }
      -              ],
      -              "default": null,
      -              "title": "Files Read"
      -            },
      -            "files_skipped": {
      -              "anyOf": [
      -                {
      -                  "type": "integer"
      -                },
      -                {
      -                  "type": "null"
      -                }
      -              ],
      -              "default": null,
      -              "title": "Files Skipped"
      -            },
      -            "hint": {
      -              "anyOf": [
      -                {
      -                  "type": "string"
      -                },
      -                {
      -                  "type": "null"
      -                }
      -              ],
      -              "default": null,
      -              "title": "Hint"
      -            },
      -            "tokens_saved": {
      -              "anyOf": [
      -                {
      -                  "type": "integer"
      -                },
      -                {
      -                  "type": "null"
      -                }
      -              ],
      -              "default": null,
      -              "title": "Tokens Saved"
      -            },
      -            "total_tokens": {
      -              "anyOf": [
      -                {
      -                  "type": "integer"
      -                },
      -                {
      -                  "type": "null"
      -                }
      -              ],
      -              "default": null,
      -              "title": "Total Tokens"
      -            },
      -            "truncated": {
      -              "anyOf": [
      -                {
      -                  "type": "boolean"
      -                },
      -                {
      -                  "type": "null"
      -                }
      -              ],
      -              "default": null,
      -              "title": "Truncated"
      -            },
      -            "unchanged": {
      -              "anyOf": [
      -                {
      -                  "items": {
      -                    "type": "string"
      -                  },
      -                  "type": "array"
      -                },
      -                {
      -                  "type": "null"
      -                }
      -              ],
      -              "default": null,
      -              "title": "Unchanged"
      -            },
      -            "unchanged_count": {
      -              "anyOf": [
      -                {
      -                  "type": "integer"
      -                },
      -                {
      -                  "type": "null"
      -                }
      -              ],
      -              "default": null,
      -              "title": "Unchanged Count"
      -            }
      -          },
      -          "title": "BatchReadSummary",
      -          "type": "object"
      -        },
      -        {
      -          "type": "null"
      -        }
      -      ],
      -      "default": null
      -    },
      -    "truncated": {
      -      "anyOf": [
      -        {
      -          "type": "boolean"
      -        },
      -        {
      -          "type": "null"
      -        }
      -      ],
      -      "default": null,
      -      "title": "Truncated"
      -    }
      -  },
      -  "title": "BatchReadResponse",
      -  "type": "object"
      -}New value: +null
  2. Changed3 schema fields changedv0.5.1
    • addedInput schema / properties / max_total_tokens / description
      Added value: +"Total token budget shared across the whole batch."
    • addedInput schema / properties / paths / description
      Added value: +"The files to read — a comma-separated list, a JSON array, or\nglob patterns (expanded for you)."
    • addedInput schema / properties / priority / description
      Added value: +"Optional paths to read first, ahead of the remaining files."
  3. Addedv0.4.5

TDQS

A4.8/5.0
Behavior5/5

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

With no annotations, the description carries the full burden and does so richly: shared token budget, cheapest-first read order, skipped files when the remaining budget is too small, known_hashes collapsing to `unchanged` or diff, content_hash return, and max_size files coming back as a map without a hash. These are exactly the operational behaviors an agent needs before calling.

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 lead sentence is front-loaded and the rest is dense but purposeful. It is longer than typical, yet each sentence adds operational detail about alternatives, budget behavior, hashes, or skips; only the final root-path sentence feels slightly awkward.

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?

No output schema and no annotations, so the description must explain return behavior — and it does: full content with content_hash, unchanged counts, diffs, map results for oversized files, and a `skipped` list. Combined with 100% schema coverage for inputs, an agent has enough to call this 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 already 100%, so the baseline is 3. The description adds real cross-parameter meaning beyond the schema: known_hashes produces an unchanged count or a diff when the file changed, priority is ordering-only and still budget-constrained, and skipped files can be recovered via `read` offset/limit.

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?

States a specific verb and resource plus the key constraint: read several files at once under a shared token budget. It also distinguishes itself from `read` (single, offset/limit) and `warm` (searchable without full text), so an agent can tell the siblings apart without opening schemas.

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 alternatives are named with conditions: 'Cheaper than many single `read` calls' for batching, `warm` when files should be searchable without being returned, and `read` with offset/limit to recover skipped files. When-to-use and when-to-use-something-else are both covered.

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