mcp-bitbucket
Bitbucket MCP Server Implementation in Python
Documentation
MCP Bitbucket Python ๐ฆ
A Python implementation of an MCP server for Bitbucket integration. MCP (Model Context Protocol) enables secure, local tool access for AI applications. The server runs locally on the same machine as your AI application.
Installation
# Install the server locally
git clone https://github.com/kallows/mcp-bitbucket.git
cd mcp-bitbucket
# Install dependencies using uv (recommended) or pip
uv install
# or
pip install -e .Tools Available
This MCP server provides the following Bitbucket integration tools:
- `bb_create_repository`: Create a new Bitbucket repository
- Required: name (repository name)
- Optional: description, workspace (defaults to kallows), project_key, is_private (default: true), has_issues (default: true)
- `bb_create_branch`: Create a new branch in a repository
- Required: repo_slug, branch (name for the new branch)
- Optional: workspace (defaults to kallows), start_point (defaults to main)
- `bb_delete_repository`: Delete a Bitbucket repository
- Required: repo_slug
- Optional: workspace (defaults to kallows)
- `bb_read_file`: Read a file from a repository
- Required: repo_slug, path (file path in repository)
- Optional: workspace (defaults to kallows), branch (defaults to main/master)
- `bb_write_file`: Create or update a file in a repository
- Required: repo_slug, path, content
- Optional: workspace (defaults to kallows), branch (defaults to main), message (commit message)
- `bb_create_issue`: Create an issue in a repository
- Required: repo_slug, title, content
- Optional: workspace (defaults to kallows), kind (bug/enhancement/proposal/task), priority (trivial/minor/major/critical/blocker)
- `bb_delete_issue`: Delete an issue from a repository
- Required: repo_slug, issue_id
- Optional: workspace (defaults to kallows)
- `bb_search_repositories`: Search Bitbucket repositories using query syntax
- Required: query (e.g., 'name ~ "test"' or 'project.key = "PROJ"')
- Optional: workspace (defaults to kallows), page (default: 1), pagelen (default: 10, max: 100)
- `bb_delete_file`: Delete a file from a repository
- Required: repo_slug, path
- Optional: workspace (defaults to kallows), branch (defaults to main), message (commit message)
- `bb_create_pull_request`: Create a pull request
- Required: repo_slug, title, source_branch
- Optional: workspace (defaults to kallows), destination_branch (defaults to main), description, close_source_branch (default: true)
Environment Setup
The server requires Bitbucket credentials to be set up as environment variables:
export BITBUCKET_USERNAME="your-username"
export BITBUCKET_APP_PASSWORD="your-app-password"Creating Bitbucket App Password
1. Go to Bitbucket Settings โ App passwords
2. Create a new app password with these permissions:
Claude Desktop Configuration
Add this configuration to your `claude_desktop_config.json`:
Windows
{
"mcpServers": {
"bitbucket-api": {
"command": "C:\\\\Users\\\\YOURUSERNAME\\\\.local\\\\bin\\\\uv.exe",
"args": [
"--directory",
"D:\\\\mcp\\\\mcp-bitbucket",
"run",
"-m",
"mcp_bitbucket.server"
],
"env": {
"BITBUCKET_USERNAME": "your-username",
"BITBUCKET_APP_PASSWORD": "your-app-password"
}
}
}
}Mac and Linux
{
"mcpServers": {
"bitbucket-api": {
"command": "uv",
"args": [
"run",
"--directory", "/path/to/mcp-bitbucket",
"-m", "mcp_bitbucket.server"
],
"env": {
"BITBUCKET_USERNAME": "your-username",
"BITBUCKET_APP_PASSWORD": "your-app-password"
}
}
}
}โ ๏ธ Important: You must restart Claude Desktop after modifying the configuration file.
Usage
Once configured, the Bitbucket tools will be available in Claude Desktop. You can:
- Ask Claude to create repositories and branches
- Read and write files in your repositories
- Create and manage issues
- Search for repositories
- Create pull requests
- Manage repository files
Example queries:
- "Create a new repository called 'my-project' in my personal workspace"
- "Create a new branch called 'feature-xyz' in the my-project repository"
- "Create a README.md file in my-project with some basic content"
- "Search for repositories that contain 'python' in the name"
Workspace Configuration
The tools default to the "kallows" workspace, but you can:
- Specify a different workspace using the `workspace` parameter
- Use `workspace='~'` to work with your personal workspace
- Create repositories in team workspaces if you have permissions
Running Tests
The project includes unit and integration tests:
# Run all tests
python -m unittest discover tests
# Run specific test files
python -m unittest tests.test_bb_api
python -m unittest tests.test_bb_integration
# Run with verbose output
python -m unittest discover tests -vDevelopment
Adding New Tools
1. Add the tool definition to `handle_list_tools()` in `server.py`
2. Add the implementation to `handle_call_tool()` in `server.py`
3. Add corresponding tests
4. Update this README
Error Handling
The server includes comprehensive error handling:
- Permission errors with helpful guidance
- Network connectivity issues
- Invalid parameters and validation
- Bitbucket API rate limiting
Project Structure
mcp-bitbucket/
โโโ README.md
โโโ pyproject.toml
โโโ uv.lock
โโโ .gitignore
โโโ .python-version
โโโ src/
โ โโโ mcp_bitbucket/
โ โโโ __init__.py
โ โโโ server.py
โโโ tests/
โโโ README.md
โโโ test_bb_api.py
โโโ test_bb_integration.pyLicense
This project is licensed under the MIT License.
Contributing
1. Fork the repository
2. Create a feature branch
3. Add tests for your changes
4. Ensure all tests pass
5. Submit a pull request
Support
For issues and questions:
- Check the Bitbucket API documentation
- Verify your app password permissions
- Review the test files for usage examples
- Create an issue in this repository
Frequently asked questions
What is mcp-bitbucket?
mcp-bitbucket is Bitbucket MCP Server Implementation in Python
How do I install mcp-bitbucket?
Open the GitHub repository and follow its README. Most MCP servers are added to your client's MCP config, then called by your agent.
Is mcp-bitbucket open source?
Yes โ it is hosted on GitHub at https://github.com/kallows/mcp-bitbucket and has 5 stars.
Related MCP tools
AWS MCP Servers โ helping you get the most out of AWS, wherever you use MCP. Python-based implementation. Trusted by 6900+ developers.
A simple, secure MCP-to-OpenAPI proxy server Python-based implementation. Trusted by 3500+ developers. Trusted by 3500+ developers.
MCP server that interacts with Obsidian via the Obsidian rest API community plugin Python-based implementation. Trusted by 2300+ developers.
Default Configuration: MCP CLI defaults to using Ollama with the gpt-oss reasoning model for local, privacy-focused operation without requiring API keys.
Official MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
MCP server for long term agent memory with Mem0. Also useful as a template to get you started building your own MCP server with Python!
Run your own MCP server? See who uses it and what to fix.
Measure it with TrackMCP