Skip to main content
Glama
Kallows

MCP Bitbucket Python

by Kallows

bb_write_file

Write or update files in a Bitbucket repository, specifying workspace, repo slug, path, content, commit message, and branch. Streamline file management within Bitbucket repositories.

Instructions

Write/update a file in a Bitbucket repository

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
branchNoBranch name (defaults to main/master)main
contentYesContent to write to the file
messageNoCommit messageUpdate file via MCP
pathYesPath where to create/update the file
repo_slugYesRepository slug/name
workspaceNoRepository workspace (defaults to kallows)kallows

Implementation Reference

  • Handler implementation for the 'bb_write_file' tool. Extracts arguments, constructs Bitbucket API URL, posts file content using multipart form data, and returns success or error message.
    elif name == "bb_write_file":
        workspace = arguments.get("workspace", "kallows")
        repo_slug = arguments.get("repo_slug")
        file_path = arguments.get("path")
        content = arguments.get("content")
        message = arguments.get("message", "Update file via MCP")
        branch = arguments.get("branch", "main")
    
        url = f"https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/src"
        
        # Prepare form data for file upload
        files = {
            file_path: (None, content)
        }
        data = {
            'message': message,
            'branch': branch
        }
    
        response = requests.post(url, auth=auth, files=files, data=data)
    
        if response.status_code in (200, 201):
            return [types.TextContent(
                type="text",
                text=f"File {file_path} updated successfully"
            )]
        else:
            return [types.TextContent(
                type="text",
                text=f"Failed to write file: {response.status_code}\n{format_permission_error(response.text)}",
                isError=True
            )]
  • Registration of the 'bb_write_file' tool with MCP server, including description and detailed input schema defining parameters and requirements.
    types.Tool(
        name="bb_write_file",
        description="Write/update a file in 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 where to create/update the file"
                },
                "content": {
                    "type": "string",
                    "description": "Content to write to the file"
                },
                "message": {
                    "type": "string",
                    "description": "Commit message",
                    "default": "Update file via MCP"
                },
                "branch": {
                    "type": "string",
                    "description": "Branch name (defaults to main/master)",
                    "default": "main"
                }
            },
            "required": ["repo_slug", "path", "content"]
        }
    ),
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'write/update' which implies mutation, but fails to describe critical behaviors like authentication requirements, error handling (e.g., if the file doesn't exist), commit creation, or potential side effects. This leaves significant gaps for a tool that modifies repository content.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's function without any fluff. It's front-loaded with the core action and resource, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with no annotations and no output schema, the description is incomplete. It doesn't cover behavioral aspects like what happens on success/failure, commit implications, or how it interacts with version control. Given the complexity of file operations in a repository, more context is needed for safe and effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds no additional meaning about parameters beyond what's in the schema (e.g., it doesn't explain parameter interactions or provide examples). This meets the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('write/update') and resource ('a file in a Bitbucket repository'), making the purpose unambiguous. However, it doesn't explicitly differentiate from sibling tools like bb_delete_file or bb_read_file, which would require mentioning creation vs. deletion vs. reading operations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. For example, it doesn't clarify if this should be used for new files versus updates, or how it relates to bb_delete_file or bb_read_file. The description only states what it does, not when to choose it.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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