Skip to main content
Glama

Get file contents

get_file_contents
Read-only

Reads file contents from a Forgejo, Codeberg, or Gitea repository by owner, repo, and path, with optional ref and line range; also lists directory contents.

Instructions

Read a file's contents from a repository (owner/repo/path, optional ref); decodes text, lists directories. Optional start_line/end_line take a 1-indexed inclusive window, clamped to the file; total_lines is always reported so you can page through a large file instead of pulling it whole.

Input Schema

NameRequiredDescriptionDefault
refNoBranch, tag, or commit to read from. Defaults to the repository's default branch.
pathYesPath to the file within the repository, e.g. `src/main.rs`.
repoYesRepository name.
ownerYesRepository owner — user or organization.
end_lineNoLast line to return, 1-indexed and inclusive. Omit to read to the end of the file.
start_lineNoFirst line to return, 1-indexed and inclusive. Omit to start at the top of the file.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.22.0

TDQS

A4.3/5.0
Behavior4/5

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

With readOnlyHint/openWorldHint already covering safety, the description adds real behavioral detail: content is decoded as text, ranges are clamped to the file, and total_lines is always returned. It doesn't cover binary/large-file failure modes or authorization errors, so it is not exhaustive.

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?

One dense but front-loaded sentence-plus-clause with no filler; the paging hint is the last thing an agent needs and arrives last. Slightly compressed — the 'decodes text, lists directories' clause is terse enough to need a second read.

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?

With no output schema, the description still conveys the shape of the return (decoded text plus total_lines) and how to page it. Missing only peripheral detail such as error or non-text file handling.

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 baseline is 3; the description goes further by explaining the clamping behavior and the inclusive 1-indexed window rationale, which the schema doesn't state. It says nothing extra about ref/owner/repo beyond what the schema already documents.

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+resource ('Read a file's contents from a repository') with the identifier triple spelled out, plus two meaningful behaviors (text decoding, directory listing). An agent can distinguish it from get_repo_tree or get_commit 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 Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives a clear operating context: use a start_line/end_line window to page a large file 'instead of pulling it whole,' and notes it lists directories. It stops short of naming explicit alternatives (e.g., get_repo_tree for recursive listings) or exclusions.

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