Skip to main content
Glama

get_file_contents

Read-only

Retrieve file or directory contents from a GitLab project by specifying path and ref. Use to fetch known resources without modifying data.

Instructions

Get contents of a file or directory from a GitLab project. Use this for a known resource or result; choose the corresponding list or search tool when you need to discover multiple resources. It is read-only and does not mutate GitLab data; missing resources, invalid identifiers, insufficient permission, and rate limits are returned as errors. When project_id or group_id is accepted, provide the numeric ID or complete URL-encoded path described by the schema; use required identifiers and pagination fields exactly as documented.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
refNoBranch/tag/commit to get contents from
pathNoAlias of file_path
jmespathNoOptional JMESPath expression filtering the JSON result before return.
file_pathNoPath to the file or directory. Takes precedence over 'path' when both are provided
project_idNoProject ID or URL-encoded path (optional; falls back to env)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv2.1.66
    • addedInput schema / properties / jmespath
      Added value: +{
      +  "description": "Optional JMESPath expression filtering the JSON result before return.",
      +  "type": "string"
      +}
  2. Addedv2.1.18
  3. Removedv2.1.14
  4. Addedv2.1.11
  5. Removedv2.1.10
  6. Changed5 schema fields changedv2.1.9
    • removedInput schema / additionalProperties
      Removed value: -false
    • changedInput schema / properties / file_path / description
      Previous value: -"Path to the file or directory"New value: +"Path to the file or directory. Takes precedence over 'path' when both are provided"
    • addedInput schema / properties / path
      Added value: +{
      +  "description": "Alias of file_path",
      +  "type": "string"
      +}
    • changedInput schema / properties / project_id / description
      Previous value: -"Project ID or complete URL-encoded path to project"New value: +"Project ID or URL-encoded path (optional; falls back to env)"
    • removedInput schema / required
      Removed value: -[
      -  "file_path"
      -]
  7. First observedv1.0.0

TDQS

A4.3/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=true, and the description reinforces this while adding useful behavior: missing resources, invalid identifiers, insufficient permission, and rate limits are returned as errors. This is valuable context beyond the structured annotations, though it partially duplicates the read-only hint.

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?

Three sentences with the core purpose and usage guidance front-loaded. The description is efficient, but some boilerplate like 'exactly as documented' and the duplication of the readOnlyHint annotation keep it just short of perfect conciseness.

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?

For a read-only fetch tool with no required parameters and no output schema, the description covers selection criteria, error behavior, and identifier formatting. It leaves the exact shape of file versus directory output somewhat implicit, but the name and first sentence convey the core return type adequately.

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 the schema already documents all parameters and the baseline is 3. The description adds little beyond that, mostly reiterating identifier-format guidance already present in the schema and mentioning group_id even though it is not a schema parameter.

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 action ('Get contents of a file or directory') with a clear resource scope ('from a GitLab project'). It also distinguishes itself from list/search siblings by positioning itself as the tool for a known resource or result rather than discovery.

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?

Explicitly instructs to use this tool for a known resource/result and to choose the corresponding list or search tool when discovering multiple resources. This gives a usable decision rule for tool selection without leaving the agent to infer when this tool applies.

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

Deploy Server

Other Tools