Skip to main content
Glama
igordev96
by igordev96

Read a file at a specific ref

get_file
Read-only

Read file contents from any GitLab branch, tag, or commit without checking it out. Uses cached mirrors or your clone for read-only inspection of other refs.

Instructions

Return the contents of a file at a given branch, tag, or commit WITHOUT checking it out. Use this to inspect files on a branch other than the one currently checked out. Give either url — a GitLab web link, whose #L12-20 line anchor is honoured — or both ref and path. The repository is mirrored locally on first use and refreshed when it goes stale, or, for a project registered with add_repo, read from your own clone. The result reports the resolved commit and the last sync time. If the copy cannot be refreshed, the cached copy answers and the result says the refresh failed.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
refNoBranch, tag, or commit SHA, e.g. 'develop' or 'fix/PROJ-7608'. Required unless `url` is given.
urlNoA GitLab web link, e.g. 'https://gitlab.example.com/group/repo/-/blob/develop/src/index.tsx#L12-20'. Replaces ref, path and (usually) project; the host must be GITLAB_HOST.
pathNoFile path inside the repository, forward slashes, e.g. 'src/index.tsx'. Required unless `url` is given.
projectNoGitLab project path, e.g. 'group/subgroup/repo'. Defaults to GITLAB_DEFAULT_PROJECT, or to the URL's project.
max_bytesNoMaximum bytes of content to return (default 200000). Ignored when a line range is asked for, which needs the whole file.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.10.1

TDQS

A4.5/5.0
Behavior5/5

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

Annotations only carry readOnlyHint=true and openWorldHint=false; the description goes well beyond that by disclosing the mirror-on-first-use / refresh-when-stale model, the add_repo clone path, the stale-cache fallback when refresh fails, and that the result reports the resolved commit and sync time. This is exactly the extra behavioral context the annotations cannot supply, and it is consistent with openWorldHint=false.

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 scope constraint is front-loaded, and each subsequent sentence carries distinct information (addressing modes, the mirror lifecycle, the failure fallback). A few sentences are dense and could be split, but there is no filler or repetition.

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, the description usefully sketches the return payload (resolved commit, last sync time) and the degraded-refresh case, and it covers all five parameters' roles. A fully 5 definition might specify the content/encoding shape or the error behaviour when neither url nor ref+path is supplied, but the critical calling information is present.

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, but the description adds genuine semantics: the `url` alternative to `ref`+`path`, that a `#L12-20` line anchor is honoured, that the URL usually overrides project, and that project falls back to GITLAB_DEFAULT_PROJECT or the URL's project. It does not explain max_bytes interaction beyond what the schema already says.

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 precise verb and resource ('Return the contents of a file at a given branch, tag, or commit') and adds the differentiator 'WITHOUT checking it out', which separates it from diff_file, list_tree, and get_commit. An agent can pick this tool out of the sibling list without opening a 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 operative condition: 'Use this to inspect files on a branch other than the one currently checked out.' It also explains how to address the file (url vs ref+path) and when the local mirror versus your own registered clone is used. It does not name a sibling alternative or state when NOT to use it, so it falls short of a 5.

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