get_file_content
Retrieve file content from Bitbucket Cloud repositories to access code, documentation, or configuration files for review or processing.
Instructions
Get the content of a file from a repository.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| workspace | Yes | The workspace slug | |
| repo_slug | Yes | The repository slug | |
| path | Yes | File path | |
| ref | No | Git ref (branch, tag, or commit) |
Implementation Reference
- src/tools/index.ts:1082-1091 (handler)Handler case in ToolHandler.handleTool that parses arguments and delegates to RepositoriesAPI.getFileContentcase 'get_file_content': { const params = toolSchemas.get_file_content.parse(args); const content = await this.repos.getFileContent( params.workspace, params.repo_slug, params.path, params.ref ); return { content }; }
- src/tools/index.ts:297-302 (schema)Zod schema for input validation used in the handlerget_file_content: z.object({ workspace: z.string().describe('The workspace slug'), repo_slug: z.string().describe('The repository slug'), path: z.string().describe('File path'), ref: z.string().optional().describe('Git ref (branch, tag, or commit)'), }),
- src/tools/index.ts:863-876 (registration)Tool registration in toolDefinitions array with MCP inputSchema{ name: 'get_file_content', description: 'Get the content of a file from a repository.', inputSchema: { type: 'object' as const, properties: { workspace: { type: 'string', description: 'The workspace slug' }, repo_slug: { type: 'string', description: 'The repository slug' }, path: { type: 'string', description: 'File path' }, ref: { type: 'string', description: 'Git ref (branch, tag, or commit)' }, }, required: ['workspace', 'repo_slug', 'path'], }, },
- src/api/repositories.ts:64-74 (helper)Core implementation in RepositoriesAPI that fetches file content from Bitbucket APIasync getFileContent( workspace: string, repo_slug: string, path: string, ref?: string ): Promise<string> { const endpoint = ref ? `/repositories/${workspace}/${repo_slug}/src/${ref}/${path}` : `/repositories/${workspace}/${repo_slug}/src/HEAD/${path}`; return this.client.getRaw(endpoint); }