Skip to main content
Glama

Batch Read

batch_read

Read multiple files at once under a shared token budget. Pass known content hashes to skip unchanged files and receive only diffs, saving tokens while keeping large codebases searchable.

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 large enough to come back summarized carries none: a summary 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

TableJSON 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 meets it: it discloses hash-based deduplication (files collapse to an `unchanged` count or a diff), summarization of large files with no `content_hash`, smallest-first read order, `skipped` behavior under budget pressure, and root-relative path resolution. An agent can predict edge-case behavior it has never seen.

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?

Eight sentences, but each carries a distinct behavioral fact (budget sharing, sibling routing, hash dedup, summaries, ordering, skipping, recovery, root path) with no repetition. Longer than minimal, but the density is justified by the tool's complexity and every sentence earns its place.

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 complex tool with 4 parameters, budget dynamics, and no output schema, the description is complete: it explains what comes back in each case (full text with `content_hash`, `unchanged` counts, diffs, summaries, `skipped`, `root`) and how to recover skipped files. Nothing an agent needs to invoke it correctly or interpret its response is missing.

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 enriches parameter meaning: it explains that `known_hashes` changes the response shape (collapse to `unchanged`/diff) and that `max_total_tokens` drives the smallest-first ordering and `skipped` behavior. This goes beyond the schema's per-parameter descriptions without restating syntax already covered there.

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?

Opens with a specific verb+resource+constraint — 'Read several files at once under a shared token budget' — which immediately distinguishes it from single-file `read` and names `warm` as the alternative for searchability. The scope is unambiguous and the tool is clearly differentiated from siblings.

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?

Gives explicit routing guidance: 'To make files searchable without reading them at all, use `warm` instead' names the alternative and the condition that selects it, and 'Recover anything skipped with `read` using `offset`/`limit`' provides the fallback path. The cost comparison to single `read` calls clarifies when batching is the right choice.

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