Skip to main content
Glama
Akxan
by Akxan

Read a file from GitHub

github_get_file
Read-onlyIdempotent

Fetch text file contents from a GitHub repository branch or commit. Returns content, SHA, size, and file URL, with offset-based pagination for large files.

Instructions

Read a text file from a repository branch. Returns content, sha, size and the file's URL. Files of any size are readable (the blob API is used past GitHub's 1 MB contents limit), but only maxBytes are returned per call: page through a large content bundle with the nextOffset of a truncated reply, or change it in place with github_commit_files edits instead of reading it whole. Binary files are refused.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
refNoBranch, tag or commit; defaults to the default branch.
pathYesPath inside the repository, e.g. 'src/pages/index.astro'.
repoYesRepository as 'owner/name', e.g. 'octocat/my-site'.
offsetNoByte offset to start at (use the nextOffset of a truncated reply). Never splits a UTF-8 character.
maxBytesNoMost bytes of file content to return in one call, so a huge file cannot flood the answer. Above ~100 KB the server's own result cap may trim the reply further.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv0.10.0
    • addedInput schema / properties / maxBytes
      Added value: +{
      +  "default": 100000,
      +  "description": "Most bytes of file content to return in one call, so a huge file cannot flood the answer. Above ~100 KB the server's own result cap may trim the reply further.",
      +  "maximum": 300000,
      +  "minimum": 1000,
      +  "type": "integer"
      +}
    • addedInput schema / properties / offset
      Added value: +{
      +  "default": 0,
      +  "description": "Byte offset to start at (use the nextOffset of a truncated reply). Never splits a UTF-8 character.",
      +  "maximum": 9007199254740991,
      +  "minimum": 0,
      +  "type": "integer"
      +}
    • addedInput schema / properties / path / description
      Added value: +"Path inside the repository, e.g. 'src/pages/index.astro'."
  2. Changed1 schema field changedv0.5.1
    • removedInput schema / additionalProperties
      Removed value: -false
  3. First observedv0.3.0

TDQS

A4.9/5.0
Behavior5/5

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

Annotations already signal read-only, idempotent, non-destructive behavior. The description adds substantial behavioral context: large files are handled via the blob API, responses are capped by maxBytes, pagination is done through nextOffset, binary files are refused, and the returned fields are enumerated. This goes well beyond the annotations without contradicting them.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is compact and well structured: it opens with the core action and return shape, then covers large-file behavior, pagination, and the editing alternative in a single dense sentence. Every clause adds necessary information and no content is redundant with the schema or annotations.

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?

With no output schema, the description covers the return contract (content, sha, size, URL), explains the pagination mechanism, notes the size limits, and warns about binary files. An agent has enough context to call this tool correctly or route to github_commit_files when appropriate.

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?

The schema already documents all 5 parameters at 100% coverage, so the baseline is 3. The description adds value by framing offset and maxBytes as a pagination workflow and explaining why a large file should not be read entirely, which helps an agent choose appropriate values. It does not fully replace the schema, but it deepens understanding of the parameter interaction.

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 states a specific verb and resource ('Read a text file from a repository branch') and lists the return fields ('content, sha, size and the file's URL'). It clearly distinguishes itself from siblings like github_list_dir and github_search_code, and the explicit 'Binary files are refused' sharpens its scope.

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?

It gives clear directional guidance: use this for reading text files, avoid binary files, and when the goal is to edit a huge file, use github_commit_files instead of reading it whole. This explicitly names an alternative and an exclusion condition, which is more than most tool descriptions provide.

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