Skip to main content

MCP server for bitbucket python API

Project description

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:
    • Repositories: Read, Write, Admin (for delete operations)
    • Pull requests: Read, Write
    • Issues: Read, Write
    • Account: Read (for workspace operations)

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 -v

Development

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.py

License

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iflow_mcp_kallows_mcp_bitbucket-0.1.0.tar.gz (27.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file iflow_mcp_kallows_mcp_bitbucket-0.1.0.tar.gz.

File metadata

  • Download URL: iflow_mcp_kallows_mcp_bitbucket-0.1.0.tar.gz
  • Upload date:
  • Size: 27.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for iflow_mcp_kallows_mcp_bitbucket-0.1.0.tar.gz
Algorithm Hash digest
SHA256 41f378366cb3eec6df19697cd42cc54047a91dda083ee2b2bb4a9574ab45f959
MD5 a23270ce8b7a7ed8375e9233632517ed
BLAKE2b-256 155adbcc1672214cb6b17279404f4d04acfdade3fa364ede7a91d445f82ebed9

See more details on using hashes here.

File details

Details for the file iflow_mcp_kallows_mcp_bitbucket-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: iflow_mcp_kallows_mcp_bitbucket-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for iflow_mcp_kallows_mcp_bitbucket-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9c089b2de98e412f4bf3b07f8ab21bf91995076781f9bc0ab9c1cf050f665385
MD5 b4491c9b99971eb434a7153a08879527
BLAKE2b-256 9634ba2328410d58c4ac2eca6dcc586c01741e28350384f05e5d0a9e97180664

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page