Skip to main content
Glama

Gitlab Get File

gitlab_get_file
Read-onlyIdempotent

Fetch file content from a GitLab repository by project ID and file path (e.g., "src/main.py"). Returns decoded content, file size, name, and encoding.

Example tool call

This call uses example arguments supplied in the tool’s input schema.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "_apiKey": "your-gitlab-api-key",
      "file_path": "README.md",
      "project_id": "123"
    },
    "name": "gitlab_get_file"
  }
}

Input Schema

NameRequiredDescriptionDefault
refNoBranch, tag, or commit SHA (default: default branch)
_apiKeyYesGitLab personal access token
file_pathYesPath to the file within the repository
project_idYesProject ID (numeric) or full path "namespace/project" (e.g. "gitlab-org/gitlab"), pass the plain path, do not URL-encode it.

Output Schema

NameRequiredDescriptionDefault
refYesGit ref (branch/tag/commit)
sizeYesFile size in bytes
contentYesDecoded file content
file_nameYesFile name
file_pathYesFile path in repository
last_commitYesLast commit SHA

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • changedInput schema / properties / project_id / description
      Previous value: -"Project ID (numeric) or full path \"namespace/project\" (e.g. \"gitlab-org/gitlab\") — pass the plain path, do not URL-encode it."New value: +"Project ID (numeric) or full path \"namespace/project\" (e.g. \"gitlab-org/gitlab\"), pass the plain path, do not URL-encode it."
  2. Changed1 schema field changed
    • changedInput schema / properties / project_id / description
      Previous value: -"Project ID or URL-encoded path"New value: +"Project ID (numeric) or full path \"namespace/project\" (e.g. \"gitlab-org/gitlab\") — pass the plain path, do not URL-encode it."
  3. Changed1 schema field changed
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "properties": {
      +    "content": {
      +      "description": "Decoded file content",
      +      "type": "string"
      +    },
      +    "file_name": {
      +      "description": "File name",
      +      "type": "string"
      +    },
      +    "file_path": {
      +      "description": "File path in repository",
      +      "type": "string"
      +    },
      +    "last_commit": {
      +      "description": "Last commit SHA",
      +      "type": "string"
      +    },
      +    "ref": {
      +      "description": "Git ref (branch/tag/commit)",
      +      "type": "string"
      +    },
      +    "size": {
      +      "description": "File size in bytes",
      +      "type": "number"
      +    }
      +  },
      +  "required": [
      +    "file_name",
      +    "file_path",
      +    "size",
      +    "ref",
      +    "last_commit",
      +    "content"
      +  ],
      +  "type": "object"
      +}
  4. Changed1 schema field changed
    • addedInput schema / examples
      Added value: +[
      +  {
      +    "_apiKey": "your-gitlab-api-key",
      +    "file_path": "README.md",
      +    "project_id": "123"
      +  },
      +  {
      +    "_apiKey": "your-gitlab-api-key",
      +    "file_path": "src/main.py",
      +    "project_id": "123",
      +    "ref": "develop"
      +  }
      +]
  5. First observed

TDQS

B3.2/5.0
Behavior3/5

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

Annotations already declare readOnlyHint, idempotentHint, destructiveHint=false, and openWorldHint, so the safety profile is covered. The description adds that content is returned 'decoded' with size/name/encoding, which is genuinely useful behavior beyond the annotations, but it says nothing about failure modes (missing path, binary files, size limits) or permission requirements.

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 operation front-loaded and the return shape summarized second. The inline path example is mildly redundant with the schema example but does clarify expected format without waste.

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 simple read-only fetch with full schema coverage, an output schema, and complete annotations, the description covers identity, inputs, and return content adequately. The remaining gap is operational edge cases (binary/large files, not-found errors), which are minor for this tool's complexity.

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 all four parameters including the ref default and the 'do not URL-encode' caveat are already documented in structured data. The description only restates project ID and file path, adding no new semantics such as ref behavior or path edge cases; baseline 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb ('Fetch') and resource ('file content from a GitLab repository') and names the two identifying inputs (project ID, file path) plus a concrete path example. It does not explicitly contrast with sibling tools such as gitlab_get_project, but the resource is narrow enough that confusion is unlikely.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

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

The description explains what the tool does but gives no when-to-use/when-not-to-use guidance and no alternatives (e.g., listing repository trees vs. reading a single file, or how ref selection changes the result). An agent must infer all usage conditions from the schema.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.