get_file_content
Retrieve file content from Bitbucket Cloud repositories to access code, documentation, or configuration files directly through the MCP server.
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:1084-1093 (handler)MCP tool handler for 'get_file_content' that validates input with Zod schema, delegates to RepositoriesAPI.getFileContent, and returns the file content.case '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 input schema definition for the 'get_file_content' tool.get_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, including name, description, and JSON schema for MCP.{ 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 constructs Bitbucket API endpoint and fetches raw file content using the client.async 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); }