Skip to main content
Glama

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

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

Input Schema (JSON Schema)

{ "properties": { "branch": { "default": "main", "description": "Branch name (defaults to main/master)", "type": "string" }, "content": { "description": "Content to write to the file", "type": "string" }, "message": { "default": "Update file via MCP", "description": "Commit message", "type": "string" }, "path": { "description": "Path where to create/update the file", "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", "content" ], "type": "object" }

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

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