Skip to main content
Glama

Get File Contents

get_file_contents
Read-onlyIdempotent

Read raw file or directory tree contents from a GitLab repository at a branch, tag, or commit to inspect source code and configuration files.

Instructions

Read the raw content of a specific file or directory tree from a repository at a designated branch, tag, or commit ref. Use when inspecting current repository source code or configs. Do NOT use for reviewing diffs between branches (use 'get_merge_request_changes') or viewing commit diffs (use 'get_commit').

Input Schema

NameRequiredDescriptionDefault
refNoBranch name, tag, or commit SHA (default: default branch / HEAD)
end_lineNoOptional 1-based end line to slice content
file_pathYesPath to the file or directory in repo (e.g. 'pom.xml', 'docs/README.md', or 'src' for directory tree)
project_idYesProject numeric ID (e.g. 31) or namespace path (e.g. 'group/project-name'). URL-encoding is handled automatically.
start_lineNoOptional 1-based start line to slice content
outline_onlyYesWhen true, extract and return only high-level symbol declarations (classes, functions, interfaces, methods, types) with their line numbers instead of full content (default: false)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv3.2.0
    • changedInput schema / properties / file_path / description
      Previous value: -"Path to the file or directory in repo (e.g. 'pom.xml' or 'docs/README.md')"New value: +"Path to the file or directory in repo (e.g. 'pom.xml', 'docs/README.md', or 'src' for directory tree)"
  2. Changed4 schema fields changedv3.1.0
    • addedInput schema / properties / end_line
      Added value: +{
      +  "description": "Optional 1-based end line to slice content",
      +  "type": "number"
      +}
    • addedInput schema / properties / outline_only
      Added value: +{
      +  "default": false,
      +  "description": "When true, extract and return only high-level symbol declarations (classes, functions, interfaces, methods, types) with their line numbers instead of full content (default: false)",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / start_line
      Added value: +{
      +  "description": "Optional 1-based start line to slice content",
      +  "type": "number"
      +}
    • changedInput schema / required
      Previous value: -[
      -  "project_id",
      -  "file_path"
      -]New value: +[
      +  "project_id",
      +  "file_path",
      +  "outline_only"
      +]
  3. First observedv2.0.0

TDQS

A4.4/5.0
Behavior4/5

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

Annotations already declare readOnlyHint, idempotentHint, non-destructive, and closed-world, so the safety profile is covered. The description adds useful behavioral context beyond that: it can read either a file or a whole directory tree, and it operates at an arbitrary ref. It does not mention output size limits or truncation behavior for large files, which is the main remaining gap.

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?

Three sentences, zero filler, with the core purpose front-loaded before the use and anti-use guidance. Every sentence earns its place.

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 should ideally hint at return shape, but it does convey that content may be a directory tree or symbol outline. Combined with fully documented params and rich annotations, the definition is nearly complete; only large-file/truncation behavior is unaddressed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so every parameter including ref, file_path, start_line/end_line, and outline_only is already documented in the schema. The description mentions ref types and directory trees but adds no syntax or format detail beyond the schema, so the baseline of 3 applies.

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 ('Read') and resource ('raw content of a specific file or directory tree from a repository') with the scope qualifier of ref (branch, tag, or commit). It explicitly names the sibling tools it is not (get_merge_request_changes, get_commit), so an agent can differentiate 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?

Gives an explicit use case ('inspecting current repository source code or configs') plus two negative exclusions that name the alternative tools for diff review and commit diffs. This is textbook when/when-not/alternatives guidance.

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