bb_delete_file
Remove files from a Bitbucket repository using a commit, specifying workspace, repo slug, file path, and branch. Streamline file deletion with automated commit messages.
Instructions
Delete a file from a Bitbucket repository
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| branch | No | Branch name (defaults to main/master) | main |
| message | No | Commit message for the deletion | Delete file via MCP |
| path | Yes | Path to the file to delete | |
| 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"
},
"message": {
"default": "Delete file via MCP",
"description": "Commit message for the deletion",
"type": "string"
},
"path": {
"description": "Path to the file to delete",
"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:756-786 (handler)Handler logic for bb_delete_file tool: deletes file by posting empty content to Bitbucket src endpoint.elif name == "bb_delete_file": workspace = arguments.get("workspace", "kallows") repo_slug = arguments.get("repo_slug") file_path = arguments.get("path") message = arguments.get("message", "Delete file via MCP") branch = arguments.get("branch", "main") url = f"https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/src" # In Bitbucket, file deletion is done by posting an empty file files = { file_path: (None, "") } 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} deleted successfully" )] else: return [types.TextContent( type="text", text=f"Failed to delete file: {response.status_code}\n{format_permission_error(response.text)}", isError=True )]
- src/mcp_bitbucket/server.py:323-355 (registration)Registration of bb_delete_file tool in list_tools(), including input schema.types.Tool( name="bb_delete_file", description="Delete 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 to delete" }, "message": { "type": "string", "description": "Commit message for the deletion", "default": "Delete file via MCP" }, "branch": { "type": "string", "description": "Branch name (defaults to main/master)", "default": "main" } }, "required": ["repo_slug", "path"] } ),