Bitbucket MCP (Model Context Protocol) server built with FastMCP that provides programmatic access to Bitbucket API v2.0
Project description
Bitbucket MCP Server
A Model Context Protocol (MCP) server that provides programmatic access to Bitbucket API v2.0. Built with FastMCP, this server enables LLMs and other tools to interact with Bitbucket repositories, pull requests, pipelines, and workspaces.
Features
- 11 MCP Tools: Lean surface covering pull requests, pipelines, and workspace insights
- 7 MCP Resources: Quick access to repository info, branches, members, and more
- Optimized for LLMs: Token-efficient design with structured outputs
- Flexible Configuration: Works with any Bitbucket workspace and repository via environment variables or HTTP headers
- Context-Aware Credentials: Per-request headers are cached in the FastMCP context so every tool call shares the same configuration
Installation
From PyPI
pip install bb-mcp-server
From Source
git clone https://github.com/jasonpaulso/bitbucket-openapi-generated.git
cd bitbucket-openapi-generated
pip install -e .
Configuration
-
Create a Bitbucket App Password:
- Go to https://bitbucket.org/account/settings/app-passwords/
- Create a new app password with necessary permissions
- Save the password securely
-
Supply credentials on every request via HTTP headers (see below). You can also set environment variables as server defaults for single-tenant deployments.
-
Environment variable template (optional server defaults):
BITBUCKET_USERNAME=your_username BITBUCKET_APP_PASSWORD=your_app_password BITBUCKET_WORKSPACE=your_workspace # Optional; auto-discovered when absent BITBUCKET_REPO=your_repo REQUIRE_CLIENT_CREDENTIALS=false # Set true to require HTTP headers for sensitive values
-
HTTP header equivalents (case-insensitive):
Header Purpose X-Bitbucket-UsernameBitbucket username X-Bitbucket-App-PasswordBitbucket app password X-Bitbucket-WorkspaceWorkspace slug (optional; auto-detected when only one exists) X-Bitbucket-RepoRepository slug Authorization: Bearer <token>Optional bearer token (overrides basic auth) Authorization: Basic <...>Optional pre-encoded basic credential When
REQUIRE_CLIENT_CREDENTIALS=true, the server refuses to fall back to environment variables for sensitive keys during HTTP requests.You can also suffix requests with
?repo=<workspace>/<repo>(or simply?repo=<repo>in a single-workspace account) instead of sending theX-Bitbucket-Repoheader. Add?workspace=<workspace>to override the workspace explicitly. Query parameters take precedence over headers and inferred defaults, making it easy to pin a repo/workspace for a single request.Examples:
...?repo=busie/fe-main...?repo=fe-main&workspace=busie(equivalent)
Single-workspace accounts can skip the workspace header altogether; the server will auto-discover the slug on first use.
-
Project-level configuration lives in
fastmcp.json, which you can customise and run viafastmcp run fastmcp.jsonin any environment that supports the FastMCP CLI.
Usage
Running the Server
# Using the installed package (HTTP transport only)
bb-mcp-server --host 0.0.0.0 --port 8000
# Or run directly from source
python server.py --host 0.0.0.0 --port 8000
# Via the FastMCP CLI with declarative config
fastmcp run fastmcp.json
# Skip environment bootstrapping when dependencies are preinstalled (e.g., Docker)
fastmcp run fastmcp.json --skip-env
Both bb-mcp-server and python server.py accept --host, --port, and --transport
flags (HTTP only). The fastmcp.json file in this repository mirrors those defaults so
fastmcp run starts an HTTP server without additional arguments.
Integrating with MCP Clients
Forward the headers listed in the configuration section with every request. See AGENTS.md for agent integration details and context behaviour.
Available Tools
The lean surface ships ten focused tools with summary-first payloads:
pr.list– List PRs with compact metadata.pr.overview– Return digest: meta, blockers, diffstat, recent comments.pr.review– Generate a structured review summary based on the overview.pr.comment.add– Post a PR comment (optional inline path/line).pr.tasks.sync– Create and resolve PR tasks in one call.pipe.run– Start a pipeline for the given repo/ref/spec.pipe.fail.summary– Summarise the most recent failing pipelines.workspace.list– List repos, members, or projects (summary by default).repo.get– Repo basics plus a five-item PR sample.me.whoami– Minimal identity plus accessible workspaces.
Resources
repo://{repo}/info– Repository informationpipelines://{repo}/recent– Recent pipeline runspull-requests://{repo}/open– Open pull requestsworkspace://{workspace}/members– Team members for reviewersworkspace://{workspace}/default-reviewers– Suggested reviewersrepo://{repo}/branches– Available branchesrepo://{repo}/branching-model– Branching configuration
Development
Setting up Development Environment
# Clone the repository
git clone https://github.com/jasonpaulso/bitbucket-openapi-generated.git
cd bitbucket-openapi-generated
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install in development mode
pip install -e .
pip install -r requirements.txt
Running Tests
# Install test dependencies
pip install pytest pytest-asyncio pytest-cov
# Run tests
pytest tests/
# Run with coverage
pytest tests/ --cov=. --cov-report=html
Code Quality
# Linting
ruff check .
# Formatting
black .
# Type checking
mypy server.py utils/ modules/
Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Built with FastMCP framework
- Uses Bitbucket API v2.0
- Implements Model Context Protocol (MCP) specification
Support
For issues, questions, or contributions, please visit:
- GitHub Issues: https://github.com/jasonpaulso/bitbucket-openapi-generated/issues
- Documentation: https://github.com/jasonpaulso/bitbucket-openapi-generated/wiki
Next Steps?
- Built-in Auth Providers: if you plan to expand beyond simple bearer/basic auth, FastMCP’s auth providers (see docs/fast-mcp/auth-overview.md) can replace the custom middleware with reusable token/OAuth flows and built-in metadata hints for clients.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bb_mcp_server-1.2.2.tar.gz.
File metadata
- Download URL: bb_mcp_server-1.2.2.tar.gz
- Upload date:
- Size: 33.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dcd1e028f8cba76d8a357785b2aea269033407f7bde634d268cb35c51a59dbd4
|
|
| MD5 |
0796ae657a4c8b37d33d62db5ddff442
|
|
| BLAKE2b-256 |
f67bd86ebfc8e8af9f80aa1d58582dd0674ca544e34b1c621eeae8cd00a1b38d
|
Provenance
The following attestation bundles were made for bb_mcp_server-1.2.2.tar.gz:
Publisher:
publish.yml on jasonpaulso/bitbucket-openapi-generated
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bb_mcp_server-1.2.2.tar.gz -
Subject digest:
dcd1e028f8cba76d8a357785b2aea269033407f7bde634d268cb35c51a59dbd4 - Sigstore transparency entry: 566679237
- Sigstore integration time:
-
Permalink:
jasonpaulso/bitbucket-openapi-generated@5ee3fc36eeb057ce7b42ce95ec0202a6ea2c39e4 -
Branch / Tag:
refs/tags/v1.2.2 - Owner: https://github.com/jasonpaulso
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5ee3fc36eeb057ce7b42ce95ec0202a6ea2c39e4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file bb_mcp_server-1.2.2-py3-none-any.whl.
File metadata
- Download URL: bb_mcp_server-1.2.2-py3-none-any.whl
- Upload date:
- Size: 42.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aba0c6b9ba849cb1c11440f9ad4af3d35aa27c2335bca7e7560bbc995a7297b7
|
|
| MD5 |
461a25215177397d6bc21b3901831f98
|
|
| BLAKE2b-256 |
f7f51008c9f06317a8e0abe6ea2c6a9c1fe236dc9628312583ce9e0b8f6197ff
|
Provenance
The following attestation bundles were made for bb_mcp_server-1.2.2-py3-none-any.whl:
Publisher:
publish.yml on jasonpaulso/bitbucket-openapi-generated
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bb_mcp_server-1.2.2-py3-none-any.whl -
Subject digest:
aba0c6b9ba849cb1c11440f9ad4af3d35aa27c2335bca7e7560bbc995a7297b7 - Sigstore transparency entry: 566679240
- Sigstore integration time:
-
Permalink:
jasonpaulso/bitbucket-openapi-generated@5ee3fc36eeb057ce7b42ce95ec0202a6ea2c39e4 -
Branch / Tag:
refs/tags/v1.2.2 - Owner: https://github.com/jasonpaulso
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5ee3fc36eeb057ce7b42ce95ec0202a6ea2c39e4 -
Trigger Event:
push
-
Statement type: