Skip to main content
Glama

get_file_contents

Read-only

Fetch contents of a file or directory from a GitLab project. Specify branch, tag, or commit and optionally filter results with JMESPath.

Instructions

Get contents of a file or directory from a GitLab project. Read-only; missing resources, denied access, and rate limits return errors. project_id/group_id take a numeric ID or URL-encoded path.

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

A3.9/5.0
Behavior4/5

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

Annotations already declare readOnlyHint and openWorldHint, so the safety profile is covered by structured data. The description adds genuinely useful behavior beyond that: missing resources, denied access, and rate limits surface as errors rather than partial results. It does not address return shape or large-file handling, keeping it short of a 5.

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?

Two tight sentences with the core purpose front-loaded and zero filler. Minor deduction: it references `group_id`, which does not exist in the input schema, so that clause spends words on something misleading rather than useful.

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 does some of the return-value work by disclosing error conditions. It stops short of explaining what a directory result looks like versus a file result, or whether content is truncated for large files, which an agent would benefit from knowing for a five-parameter retrieval tool.

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 coverage is 100%, so all five parameters are already documented, including the project_id ID-or-URL-encoded-path convention that the description restates. The description adds no information about ref, the path/file_path alias precedence, or the jmespath filter, so it does not exceed the schema baseline.

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?

Names a specific verb (Get), resource (contents of a file or directory), and scope (a GitLab project), which cleanly separates it from siblings like get_repository_tree, get_file_blame, or get_commit_diff. An agent can identify the right tool 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 Guidelines3/5

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

The tool's read-only nature is stated, which implies a read/retrieve use case, but there is no explicit when-to-use guidance and no named alternative (e.g., use get_repository_tree to enumerate a directory, get_file_blame for line ownership). Usage is implied rather than directed.

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