bitbucket-python-mcp
Allows AI agents to manage Bitbucket Cloud repositories, branches, pull requests, search code, and store/retrieve workspace memories through the Bitbucket API.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@bitbucket-python-mcp list my open pull requests"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
BitBucket MCP Server
A Model Context Protocol (MCP) server for BitBucket Cloud operations. This server enables AI coding agents like Claude Code CLI and Codex CLI to interact with BitBucket repositories, branches, and pull requests.
Features
Repository Management: Create, delete, update, and list repositories
Branch Management: Create, delete, and list branches
Pull Request Operations: Create, review, approve, comment on pull requests
Code Search: Search repositories and browse file contents
Memory System: Store and retrieve workspace standards and learnings from PR reviews
Auto-detection: Automatically detects current BitBucket repository from git remote
Related MCP server: Bitbucket MCP Server
Installation
Using uvx (Recommended)
uvx bitbucket-python-mcpUsing pip
pip install bitbucket-python-mcpFrom Source
git clone https://github.com/yourusername/bitbucket-python-mcp.git
cd bitbucket-python-mcp
uv syncConfiguration
The server requires the following environment variables:
Variable | Required | Description |
| Yes | Your BitBucket username (not email) |
| Yes | App password/API token from BitBucket settings |
| Yes | Default workspace slug |
| No | Enable debug logging (1/true/yes) |
Creating an App Password
Go to BitBucket App Passwords
Click "Create app password"
Give it a descriptive name (e.g., "MCP Server")
Select the required permissions:
Repositories: Read, Write, Admin (for create/delete)
Pull requests: Read, Write
Click "Create" and copy the generated password
Usage with AI Agents
Claude Code CLI
Add to your ~/.claude/claude_desktop_config.json:
{
"mcpServers": {
"bitbucket": {
"command": "uvx",
"args": ["bitbucket-python-mcp"],
"env": {
"BITBUCKET_USERNAME": "your-username",
"BITBUCKET_API_TOKEN": "your-api-token",
"BITBUCKET_WORKSPACE": "your-workspace"
}
}
}
}OpenAI Codex CLI
Add to your ~/.codex/config.toml:
[mcp_servers.bitbucket]
command = "uvx"
args = ["bitbucket-python-mcp"]
[mcp_servers.bitbucket.env]
BITBUCKET_USERNAME = "your-username"
BITBUCKET_API_TOKEN = "your-api-token"
BITBUCKET_WORKSPACE = "your-workspace"Alternatively, use the Codex CLI to add the server:
codex mcp add bitbucket \
--env BITBUCKET_USERNAME=your-username \
--env BITBUCKET_API_TOKEN=your-api-token \
--env BITBUCKET_WORKSPACE=your-workspace \
-- uvx bitbucket-python-mcpVerify the server is configured:
codex mcp listRunning Locally
# Set environment variables
export BITBUCKET_USERNAME="your-username"
export BITBUCKET_API_TOKEN="your-api-token"
export BITBUCKET_WORKSPACE="your-workspace"
# Run the server
uvx bitbucket-python-mcp
# or
uv run bitbucket-python-mcpAvailable Tools
Repository Tools
Tool | Description |
| List all repositories in a workspace |
| Get detailed repository information |
| Create a new repository |
| Delete a repository (requires confirmation) |
| Update repository settings |
Branch Tools
Tool | Description |
| List all branches in a repository |
| Get branch details |
| Create a new branch |
| Delete a branch (requires confirmation) |
Pull Request Tools
Tool | Description |
| List pull requests (open/merged/declined) |
| Get PR details (defaults to newest) |
| Get the diff for a PR |
| Get all comments on a PR |
| Add a comment (general or inline) |
| Approve a PR |
| Request changes on a PR |
| Create a new PR |
Search Tools
Tool | Description |
| Search for repositories by name |
| Browse repository files/directories |
| Search for code patterns |
| Get raw file content |
Memory Tools
Tool | Description |
| Store a new learning/standard for future reference |
| List stored memories filtered by workspace/category |
| Search memories by keyword |
| Get memories relevant to current context |
| Delete a stored memory |
| Extract and store learning from a PR comment |
Memories are stored in ~/.bitbucket-python-mcp/memory/ and persist across sessions.
Examples
Create a Repository
User: Create a new private repository named "my-new-project" with description "My awesome project"Create a Branch
User: Create a new branch named "feature-login" from developmentReview a Pull Request
User: Show me the details of the newest pull request
User: What are the comments on PR #42?
User: Approve PR #42Search Code
User: Search for "authentication" in the project-api repository
User: Show me the contents of src/main.pyStore and Retrieve Memories
User: Remember that we should use shared-pipeline for SonarQube scans
User: What standards should I follow for this workspace?
User: Search memories for "pipeline"Development
Setup
# Clone the repository
git clone https://github.com/yourusername/bitbucket-python-mcp.git
cd bitbucket-python-mcp
# Install dependencies
uv sync --all-extras
# or using just
just install-devRunning Tests
uv run pytest
# or using just
just testLinting
uv run ruff check src tests
uv run ruff format src tests
# or using just
just fmt
just lintBuilding
uv build
# or using just
just buildContributing
Contributions are welcome! Please feel free to submit a Pull Request.
Fork the repository
Create your feature branch (
git checkout -b feature/amazing-feature)Commit your changes (
git commit -m 'Add some amazing feature')Push to the branch (
git push origin feature/amazing-feature)Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
Model Context Protocol - The protocol specification
atlassian-python-api - BitBucket API client
Available Tools
32 toolsadd_memoryA
Store a new memory/learning for future reference.
Use this tool to remember important standards, patterns, or learnings discovered from PR comments, code reviews, or user instructions. These memories will be available when reviewing other PRs or repositories.
Common use cases:
Workspace coding standards (e.g., "use uv for package management")
Pipeline requirements (e.g., "use shared-pipeline for SonarQube scans")
Testing standards (e.g., "mock all external API calls in tests")
Code style preferences (e.g., "use type hints for all function parameters")
Args: content: The learning/standard to remember (be specific and actionable) category: Category - one of: pipeline, testing, coding_style, tools, workflow, general tags: Comma-separated tags for easier searching (e.g., "sonarqube,pipeline,ci") workspace: Workspace this applies to (omit for global/all workspaces) repository: Repository this applies to (omit for all repos in workspace) source_type: Source of this memory - user, pr_comment, or api_response pr_id: If from a PR comment, the PR ID
Returns: Confirmation with the created memory details
Inputs: content (required), tags, pr_id, category, +3 more. Returns: result
add_pull_request_commentA
Add a comment to a pull request.
Use this tool to add feedback or discussion to a pull request. Can add general comments or inline comments on specific lines of code.
Args: pr_id: Pull request ID. comment: The comment text to add. repository: Repository slug. If not provided, uses current repository context. workspace: Workspace slug. If not provided, uses the default workspace. file_path: Path to file for inline comment (optional). line_number: Line number for inline comment (optional, requires file_path).
Returns: JSON object confirming the comment was added.
Inputs: pr_id (required), comment (required), file_path, workspace, +2 more. Returns: result
approve_pull_requestB
Approve a pull request.
Use this tool to approve a pull request, indicating the changes are acceptable and ready to merge.
Args: pr_id: Pull request ID to approve. repository: Repository slug. If not provided, uses current repository context. workspace: Workspace slug. If not provided, uses the default workspace.
Returns: JSON object confirming the approval.
Inputs: pr_id (required), workspace, repository. Returns: result
create_branchA
Create a new branch in a BitBucket repository.
Use this tool when the user wants to create a new branch. By default, branches are created from the 'development' branch.
Args: branch_name: Name for the new branch. source_branch: Source branch to create from (default: 'development'). repository: Repository slug. If not provided, uses current repository context. workspace: Workspace slug. If not provided, uses the default workspace.
Returns: JSON object with the created branch details.
Inputs: branch_name (required), workspace, repository, source_branch. Returns: result
create_pull_requestA
Create a new pull request.
Use this tool to create a pull request for merging changes from one branch to another. Supports auto-detection of source branch and smart destination selection.
Workflow for adding reviewers:
First use search_workspace_users to find users by name
Pass the account_id(s) from the search results to reviewer_account_ids
Default reviewers are automatically included unless disabled
Args: title: Title of the pull request. source_branch: Branch containing the changes. If not provided, uses the current git branch. Cannot be main/master/development. destination_branch: Branch to merge into. If not provided, defaults to 'development' for feature/bugfix branches. description: Optional description of the changes. repository: Repository slug. If not provided, uses current repository context. workspace: Workspace slug. If not provided, uses the default workspace. reviewer_account_ids: Comma-separated list of reviewer account_ids to add as additional reviewers (use search_workspace_users to find these). include_default_reviewers: If True (default), includes repository's default reviewers in addition to any specified reviewers. close_source_branch: Whether to close the source branch after merge.
Returns: JSON object with the created pull request details.
Inputs: title (required), workspace, repository, description, +5 more. Returns: result
create_repositoryA
Create a new repository in BitBucket.
Use this tool when the user wants to create a new repository. The repository will be created in the specified workspace with the given settings.
Args: name: Name of the new repository. Will also be used as the slug. description: Optional description of the repository. is_private: Whether the repository should be private (default: True). project_key: Optional project key to associate the repository with a project. workspace: Workspace slug. If not provided, uses the default workspace.
Returns: JSON object with the created repository details.
Inputs: name (required), workspace, is_private, description, +1 more. Returns: result
delete_branchA
Delete a branch from a BitBucket repository.
WARNING: This is a destructive operation. The confirm parameter MUST be set to true to proceed with deletion.
Use this tool only when the user explicitly requests to delete a branch and has confirmed the deletion.
Args: branch_name: Name of the branch to delete. confirm: Must be True to proceed with deletion. This is a safety measure. repository: Repository slug. If not provided, uses current repository context. workspace: Workspace slug. If not provided, uses the default workspace.
Returns: Confirmation message or error if confirm is not True.
Inputs: confirm (required), branch_name (required), workspace, repository. Returns: result
delete_memoryB
Delete a stored memory by ID.
Args: memory_id: The ID of the memory to delete
Returns: Confirmation of deletion
Inputs: memory_id (required). Returns: result
delete_repositoryA
Delete a repository from BitBucket.
WARNING: This is a destructive operation that cannot be undone. The confirm parameter MUST be set to true to proceed with deletion.
Use this tool only when the user explicitly requests to delete a repository and has confirmed the deletion.
Args: repository: Repository slug to delete. confirm: Must be True to proceed with deletion. This is a safety measure. workspace: Workspace slug. If not provided, uses the default workspace.
Returns: Confirmation message or error if confirm is not True.
Inputs: confirm (required), repository (required), workspace. Returns: result
get_branchA
Get detailed information about a specific branch.
Use this tool when you need complete details about a branch, including its latest commit information.
Args: branch_name: Name of the branch to get details for. repository: Repository slug. If not provided, uses current repository context. workspace: Workspace slug. If not provided, uses the default workspace.
Returns: JSON object with branch details including commit information.
Inputs: branch_name (required), workspace, repository. Returns: result
get_current_git_branchA
Get the current git branch name.
Use this tool to detect what branch you're currently on before creating a pull request. This is useful for auto-detecting the source branch.
Returns: JSON object with the current branch name, or error if not in a git repository.
Inputs: no named parameters. Returns: result
get_current_userA
Get the authenticated user's account information including email addresses.
Use this tool to get information about the currently authenticated BitBucket user, including their email addresses. This is useful for:
Verifying which account is being used
Getting the user's email addresses
Getting the user's account_id for self-assignment
Returns: JSON object with the authenticated user's details and email addresses.
Inputs: no named parameters. Returns: result
get_default_reviewersA
Get default reviewers configured for a repository.
Use this tool to see which users are automatically added as reviewers when creating pull requests. These reviewers will be included unless explicitly excluded.
Args: repository: Repository slug. If not provided, uses current repository context. workspace: Workspace slug. If not provided, uses the default workspace.
Returns: JSON list of default reviewers with their details.
Inputs: workspace, repository. Returns: result
get_file_contentA
Get the raw content of a specific file from a BitBucket repository.
Use this tool when you need to read the full content of a specific file. This is useful for reviewing code, configuration files, or documentation.
Args: file_path: Path to the file in the repository. repository: Repository slug. If not provided, uses current repository context. workspace: Workspace slug. If not provided, uses the default workspace. ref: Branch, tag, or commit hash (default: HEAD).
Returns: The raw file content as a string.
Inputs: file_path (required), ref, workspace, repository. Returns: result
get_pull_requestA
Get detailed information about a specific pull request.
Use this tool to get complete details about a pull request, including its description, reviewers, and approval status.
Args: pr_id: Pull request ID. If not provided, returns the newest open PR. repository: Repository slug. If not provided, uses current repository context. workspace: Workspace slug. If not provided, uses the default workspace.
Returns: JSON object with complete pull request details.
Inputs: pr_id, workspace, repository. Returns: result
get_pull_request_commentsA
Get all comments on a pull request.
Use this tool to review comments, feedback, and discussions on a pull request. Includes both general comments and inline code review comments.
Args: pr_id: Pull request ID. repository: Repository slug. If not provided, uses current repository context. workspace: Workspace slug. If not provided, uses the default workspace.
Returns: JSON list of comments with their content, authors, and locations.
Inputs: pr_id (required), workspace, repository. Returns: result
get_pull_request_diffA
Get the diff/changes for a pull request.
Use this tool to see what code changes are included in a pull request. Returns the raw diff output.
Args: pr_id: Pull request ID. repository: Repository slug. If not provided, uses current repository context. workspace: Workspace slug. If not provided, uses the default workspace.
Returns: The diff text showing all changes in the pull request.
Inputs: pr_id (required), workspace, repository. Returns: result
get_relevant_memoriesA
Get all memories relevant to the current context.
Call this tool at the start of a PR review or when working with a repository to retrieve all applicable standards and learnings.
Args: workspace: Current workspace (uses default if not specified) repository: Current repository categories: Comma-separated categories to filter (e.g., "pipeline,testing")
Returns: JSON list of relevant memories for the context
Inputs: workspace, categories, repository. Returns: result
get_repositoryA
Get detailed information about a specific BitBucket repository.
Use this tool when you need full details about a repository, including its settings, clone URLs, and metadata.
Args: repository: Repository slug (the URL-friendly name of the repository). workspace: Workspace slug. If not provided, uses the default workspace.
Returns: JSON object with complete repository details.
Inputs: repository (required), workspace. Returns: result
get_repository_contentsA
Get file or directory contents from a BitBucket repository.
Use this tool to browse repository contents, view file structure, or read file contents. Can navigate to specific paths and refs (branches/tags).
Args: path: Path to file or directory (empty string for root). repository: Repository slug. If not provided, uses current repository context. workspace: Workspace slug. If not provided, uses the default workspace. ref: Branch, tag, or commit hash (default: HEAD).
Returns: JSON object with directory listing or file contents.
Inputs: ref, path, workspace, repository. Returns: result
list_branchesA
List branches in a BitBucket repository.
Use this tool to see available branches in a repository, including their names and latest commit information.
Args: repository: Repository slug. If not provided and working in a git repo with a BitBucket remote, will use the current repository. workspace: Workspace slug. If not provided, uses the default workspace. limit: Maximum number of branches to return. Default 50.
Returns: JSON list of branches with their names and target commit info.
Inputs: limit, workspace, repository. Returns: result
list_memoriesA
List stored memories/learnings.
Retrieves all stored memories, optionally filtered by scope or category. Global memories (workspace=None) are always included when filtering by workspace.
Args: workspace: Filter by workspace (includes global memories too) repository: Filter by repository category: Filter by category (pipeline, testing, coding_style, tools, workflow, general)
Returns: JSON list of memories matching the filters
Inputs: category, workspace, repository. Returns: result
list_pull_requestsA
List pull requests in a BitBucket repository.
Use this tool to see pull requests in a repository. By default, shows only open pull requests.
Args: repository: Repository slug. If not provided, uses current repository context. workspace: Workspace slug. If not provided, uses the default workspace. state: Filter by state - 'OPEN', 'MERGED', 'DECLINED', or 'SUPERSEDED'. Default is 'OPEN'. limit: Maximum number of pull requests to return. Default 10.
Returns: JSON list of pull requests with their titles, authors, and status.
Inputs: limit, state, workspace, repository. Returns: result
list_repositoriesA
List repositories in a BitBucket workspace.
This is the primary tool for discovering repositories. Use this when the user wants to see what repositories are available or when searching for a specific repository by browsing.
Args: workspace: Workspace slug. If not provided, uses the default workspace from BITBUCKET_WORKSPACE environment variable. limit: Maximum number of repositories to return. Default 50.
Returns: JSON list of repositories with their names, descriptions, and URLs.
Inputs: limit, workspace. Returns: result
list_workspace_membersA
List all members in a BitBucket workspace.
Use this tool to see all users who have access to a workspace. Useful for finding reviewers or understanding team membership.
Args: workspace: Workspace slug. If not provided, uses the default workspace.
Returns: JSON list of all workspace members with their details.
Inputs: workspace. Returns: result
remember_from_pr_commentA
Extract and store a learning from a PR comment.
Use this when you identify a standard or pattern in a PR comment that should be remembered for future reference.
Args: repository: Repository where the PR comment was found pr_id: PR ID where the comment was found comment_content: The original comment content (for reference) learning: The extracted learning/standard to remember category: Category - pipeline, testing, coding_style, tools, workflow, general tags: Comma-separated tags workspace: Workspace (uses default if not specified) apply_to_all_repos: If True, applies to all repos in workspace; if False, only this repo
Returns: Confirmation with the created memory
Inputs: pr_id (required), learning (required), repository (required), comment_content (required), +4 more. Returns: result
request_changesA
Request changes on a pull request.
Use this tool to indicate that changes are needed before the pull request can be approved. Always include a comment explaining what needs to change.
Args: pr_id: Pull request ID. comment: Explanation of what changes are needed. repository: Repository slug. If not provided, uses current repository context. workspace: Workspace slug. If not provided, uses the default workspace.
Returns: JSON object confirming the change request.
Inputs: pr_id (required), comment (required), workspace, repository. Returns: result
search_codeA
Search for code patterns in a BitBucket repository.
Use this tool to find specific code patterns, function names, or text within a repository's codebase.
Args: query: Search query for code content. repository: Repository slug. If not provided, uses current repository context. workspace: Workspace slug. If not provided, uses the default workspace. limit: Maximum number of results to return. Default 20.
Returns: JSON list of matching code locations with snippets.
Inputs: query (required), limit, workspace, repository. Returns: result
search_memoriesA
Search memories by keyword.
Searches memory content and tags for the given query. Use this before reviewing PRs or making suggestions to check for existing standards or learnings.
Args: query: Search keyword (searches content and tags) workspace: Filter by workspace repository: Filter by repository
Returns: JSON list of matching memories
Inputs: query (required), workspace, repository. Returns: result
search_repositoriesA
Search for repositories in a BitBucket workspace.
Use this tool to find repositories by name or other criteria. Searches within the specified workspace and returns matching repositories.
Args: query: Search query to filter repositories by name. If not provided, lists all repositories. workspace: Workspace slug. If not provided, uses the default workspace.
Returns: JSON list of matching repositories.
Inputs: query, workspace. Returns: result
search_workspace_usersA
Search for users in a BitBucket workspace by name.
Use this tool to find users by their name or nickname. It first checks the memory cache for previously found users, then searches BitBucket if needed. Found users are automatically cached for future lookups.
This is useful when:
Adding reviewers to a pull request
Mentioning users in comments (@username)
Finding user account IDs for API operations
Args: query: User name or nickname to search for (partial match supported). workspace: Workspace slug. If not provided, uses the default workspace. check_memory_first: If True, checks memory cache before searching BitBucket.
Returns: JSON object with matching users. If multiple matches found, returns all so the caller can ask the user to choose.
Inputs: query (required), workspace, check_memory_first. Returns: result
update_repositoryA
Update repository settings in BitBucket.
Use this tool to modify repository metadata such as description or visibility. Only provide the parameters you want to change.
Args: repository: Repository slug to update. description: New description for the repository. is_private: Whether the repository should be private. workspace: Workspace slug. If not provided, uses the default workspace.
Returns: JSON object with the updated repository details.
Inputs: repository (required), workspace, is_private, description. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 32 tools
Most tools have clearly distinct purposes, with memory and PR operations well-separated. However, get_file_content and get_repository_contents both retrieve file content, which could cause confusion despite different functionality.
The majority follow a consistent verb_noun pattern (e.g., create_branch, list_pull_requests). Only remember_from_pr_comment deviates, being a verb_phrase rather than simple verb_noun.
With 32 tools, the server is on the heavier side but still within a reasonable range for a comprehensive Bitbucket integration. The count is justified by the inclusion of memory management features.
Core Bitbucket operations are well-covered (repos, branches, PRs, comments, search), but notable gaps exist: there's no tool to merge a pull request, update PR details, or manage commits. The memory subsystem is a nice addition but not part of the core domain.
Maintenance
Related MCP Connectors
MCP server for AI agents to plan, verify, and deploy Cloudflare-native apps.
A MCP server built for developers enabling Git based project management with project and personal…
MCP server for building and testing AI agents with multi-model experimentation and insights.
MCP server connecting AI agents to 100+ apps (Gmail, Slack, Notion, GitHub) via one-click OAuth.
Related MCP Servers
- AlicenseBqualityDmaintenanceAn MCP server that provides tools for interacting with the Bitbucket API, supporting both Bitbucket Cloud and Bitbucket Server, enabling pull request, branch, file, code review, and search operations.19MIT
- AlicenseCqualityCmaintenanceMCP server for integrating with Bitbucket Cloud and Server APIs, enabling AI assistants to interact with repositories, pull requests, pipelines, and more.5933 npm3MIT
- FlicenseBqualityDmaintenanceMCP server for Bitbucket Cloud that enables AI agents to manage repositories, branches, pull requests, and deployments via typed tools.17-
- AlicenseBqualityDmaintenanceAn MCP server for Bitbucket Cloud that enables managing pull requests, branches, and repositories in natural language from any MCP-capable client.23544 npm4MIT