Skip to main content
Glama
Kallows

MCP Bitbucket Python

by Kallows

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

TableJSON Schema
NameRequiredDescriptionDefault
branchNoBranch name (defaults to main/master)main
pathYesPath to the file in the repository
repo_slugYesRepository slug/name
workspaceNoRepository workspace (defaults to kallows)kallows

Implementation Reference

  • 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
            )]
  • 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"]
        }
    ),
Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Kallows/mcp-bitbucket'

If you have feedback or need assistance with the MCP directory API, please join our Discord server