Skip to main content
Glama

gitlab_get_repository_file

Retrieve the content of a specific file from a GitLab repository. Provide the project ID, file path, and branch/tag/commit reference to access file data directly.

Instructions

Get content of a file in a repository

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYesPath of the file in the repository
project_idYesThe ID or URL-encoded path of the project
refNoThe name of branch, tag or commit

Implementation Reference

  • The main handler function for 'gitlab_get_repository_file' that fetches the content of a specific file from a GitLab repository using the GitLab API.
    export const getRepositoryFile: ToolHandler = async (params, context) => {
      const { project_id, file_path, ref } = params.arguments || {};
      if (!project_id || !file_path) {
        throw new McpError(ErrorCode.InvalidParams, 'project_id and file_path are required');
      }
      
      const response = await context.axiosInstance.get(
        `/projects/${encodeURIComponent(String(project_id))}/repository/files/${encodeURIComponent(String(file_path))}`,
        { params: { ref: ref || 'main' } }
      );
      return formatResponse(response.data);
    };
  • The input schema definition for the 'gitlab_get_repository_file' tool, specifying parameters like project_id, file_path, and optional ref.
      name: 'gitlab_get_repository_file',
      description: 'Get content of a file in a repository',
      inputSchema: {
        type: 'object',
        properties: {
          project_id: {
            type: 'string',
            description: 'The ID or URL-encoded path of the project'
          },
          file_path: {
            type: 'string',
            description: 'Path of the file in the repository'
          },
          ref: {
            type: 'string',
            description: 'The name of branch, tag or commit'
          }
        },
        required: ['project_id', 'file_path']
      }
    },
  • Registration of the 'gitlab_get_repository_file' tool mapping to the repoHandlers.getRepositoryFile handler function.
    gitlab_get_repository_file: repoHandlers.getRepositoryFile,
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the action ('Get content') but doesn't describe traits like read-only nature (implied by 'Get'), authentication requirements, rate limits, error handling, or output format. For a tool with zero annotation coverage, this is a significant gap in transparency.

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?

The description is a single, efficient sentence that directly states the tool's purpose without any wasted words. It is appropriately sized and front-loaded, making it easy to understand at a glance.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (3 parameters, no output schema, no annotations), the description is incomplete. It lacks behavioral context (e.g., safety, permissions), usage guidelines, and details on return values, which are crucial for an agent to invoke it correctly without structured support from annotations or output schema.

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 three parameters (file_path, project_id, ref) with clear descriptions. The description adds no additional meaning beyond what's in the schema, such as examples or constraints, but since the schema is comprehensive, a baseline score of 3 is appropriate.

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?

The description clearly states the verb ('Get') and resource ('content of a file in a repository'), making the purpose specific and understandable. However, it doesn't explicitly differentiate from siblings like 'gitlab_get_project' or 'gitlab_get_merge_request', which also retrieve data but for different resources, so it lacks sibling distinction.

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 provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., authentication, project access), exclusions (e.g., when to use other get tools for different resources), or contextual cues, leaving usage entirely implied from the name and schema.

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

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/rifqi96/mcp-gitlab'

If you have feedback or need assistance with the MCP directory API, please join our Discord server