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
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes | Project ID or complete URL-encoded path to project | |
| file_path | Yes | Path to the file or directory | |
| ref | No | Branch/tag/commit to get contents from |
Implementation Reference
- schemas.ts:813-816 (schema)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"), });
- schemas.ts:362-365 (schema)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), ]);
- schemas.ts:339-351 (schema)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 });