bb_read_file
Retrieve and access files directly from a Bitbucket repository using workspace, repo slug, path, and branch inputs. Simplifies file operations for repository management tasks.
Instructions
Read a file from a Bitbucket repository
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| branch | No | Branch name (defaults to main/master) | main |
| path | Yes | Path to the file in the repository | |
| repo_slug | Yes | Repository slug/name | |
| workspace | No | Repository workspace (defaults to kallows) | kallows |
Input Schema (JSON Schema)
{
"properties": {
"branch": {
"default": "main",
"description": "Branch name (defaults to main/master)",
"type": "string"
},
"path": {
"description": "Path to the file in the repository",
"type": "string"
},
"repo_slug": {
"description": "Repository slug/name",
"type": "string"
},
"workspace": {
"default": "kallows",
"description": "Repository workspace (defaults to kallows)",
"type": "string"
}
},
"required": [
"repo_slug",
"path"
],
"type": "object"
}
Implementation Reference
- src/mcp_bitbucket/server.py:649-668 (handler)Handler implementation for the 'bb_read_file' tool. Fetches file content from Bitbucket repository using API GET request to /src/{branch}/{path} endpoint and returns the raw text content or error message.elif name == "bb_read_file": workspace = arguments.get("workspace", "kallows") repo_slug = arguments.get("repo_slug") file_path = arguments.get("path") branch = arguments.get("branch", "main") url = f"https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/src/{branch}/{file_path}" response = requests.get(url, auth=auth) if response.status_code == 200: return [types.TextContent( type="text", text=response.text )] else: return [types.TextContent( type="text", text=f"Failed to read file: {response.status_code}\n{format_permission_error(response.text)}", isError=True )]
- src/mcp_bitbucket/server.py:169-196 (registration)Tool registration in list_tools() handler, defining the name, description, and input schema for 'bb_read_file'.types.Tool( name="bb_read_file", description="Read a file from a Bitbucket repository", inputSchema={ "type": "object", "properties": { "workspace": { "type": "string", "description": "Repository workspace (defaults to kallows)", "default": "kallows" }, "repo_slug": { "type": "string", "description": "Repository slug/name" }, "path": { "type": "string", "description": "Path to the file in the repository" }, "branch": { "type": "string", "description": "Branch name (defaults to main/master)", "default": "main" } }, "required": ["repo_slug", "path"] } ),