get_file_content
Retrieve file contents from Bitbucket repositories to access code, documentation, or configuration files for review, analysis, or integration purposes.
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 | The file path | |
| ref | No | The reference (branch, tag, or commit hash) - defaults to HEAD |
Implementation Reference
- src/BitbucketClient.ts:193-197 (handler)The implementation of the getFileContent method in the BitbucketClient class, which makes the API call to Bitbucket to retrieve file content.
async getFileContent(workspace: string, repoSlug: string, path: string, ref?: string): Promise<string> { const params = ref ? { ref } : {}; const response = await this.api.get(`/repositories/${workspace}/${repoSlug}/src/${ref || 'HEAD'}/${path}`, { params }); return response.data; } - src/index.ts:615-631 (handler)The MCP tool request handler case for get_file_content, which extracts arguments from the request and calls the BitbucketClient's getFileContent method.
case 'get_file_content': { const { workspace, repo_slug, path, ref } = args as { workspace: string; repo_slug: string; path: string; ref?: string; }; const content = await client.getFileContent(workspace, repo_slug, path, ref); return { content: [ { type: 'text', text: content, }, ], }; } - src/index.ts:318-342 (schema)The tool definition/schema for get_file_content, describing its inputs and purpose.
name: 'get_file_content', description: 'Get the content of a file from a repository', inputSchema: { type: 'object', properties: { workspace: { type: 'string', description: 'The workspace slug', }, repo_slug: { type: 'string', description: 'The repository slug', }, path: { type: 'string', description: 'The file path', }, ref: { type: 'string', description: 'The reference (branch, tag, or commit hash) - defaults to HEAD', }, }, required: ['workspace', 'repo_slug', 'path'], }, },