Skip to main content
Glama

get_file_contents

Retrieve file or directory contents from GitLab projects by specifying project ID, file path, and branch reference to access repository files through API calls.

Instructions

Get the contents of a file or directory from a GitLab project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYesProject ID or complete URL-encoded path to project
file_pathYesPath to the file or directory
refNoBranch/tag/commit to get contents from

Implementation Reference

  • Input schema (GetFileContentsSchema) for the 'get_file_contents' MCP tool, which takes project_id (inherited), file_path, and optional ref.
    export const GetFileContentsSchema = ProjectParamsSchema.extend({ file_path: z.string().describe("Path to the file or directory"), ref: z.string().optional().describe("Branch/tag/commit to get contents from"), });
  • Output schema (GitLabContentSchema) for get_file_contents tool, union of single file content or array of directory contents.
    export const GitLabContentSchema = z.union([ GitLabFileContentSchema, z.array(GitLabDirectoryContentSchema), ]);
  • Detailed schema for file content response in get_file_contents tool.
    export const GitLabFileContentSchema = z.object({ file_name: z.string(), // Changed from name to match GitLab API file_path: z.string(), // Changed from path to match GitLab API size: z.number(), encoding: z.string(), content: z.string(), content_sha256: z.string(), // Changed from sha to match GitLab API ref: z.string(), // Added as GitLab requires branch reference blob_id: z.string(), // Added to match GitLab API commit_id: z.string(), // ID of the current file version last_commit_id: z.string(), // Added to match GitLab API execute_filemode: z.boolean().optional(), // Added to match GitLab API });

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/harshmaur/gitlab-mcp'

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