bitbucket-mcp
MCP server for Bitbucket Cloud that enables listing repositories, managing pull requests, posting comments, and handling tasks via natural language.
README
bitbucket-mcp
A production-grade, open-source Model Context Protocol (MCP) server that integrates with Bitbucket Cloud. Expose your Bitbucket repositories and pull requests as MCP tools — ready to use with Claude Desktop and any other MCP-compatible client.
What is MCP?
The Model Context Protocol is an open standard that lets AI models (like Claude) communicate with external tools and data sources in a structured, secure way. An MCP server exposes tools that an AI client can call, with typed inputs and structured outputs.
What is this project?
bitbucket-mcp is an MCP server that wraps the Bitbucket Cloud REST API v2. Once connected to Claude Desktop, you can ask Claude to:
- List all repos in your workspace
- Show open (or merged/declined) pull requests
- Fetch PR details, diffs, and commit history
- Post review comments on PRs
- Manage tasks on PRs (list, create, resolve, delete)
Features
| Tool | Description |
|---|---|
list_repositories |
List all repos in a workspace (paginated) |
list_pull_requests |
List PRs with optional state filter |
get_pull_request_details |
Full PR info: reviewers, participants, merge commit |
get_pull_request_diff |
Raw unified diff (large diffs safely truncated) |
list_pull_request_commits |
All commits in a PR |
list_pull_request_comments |
List all comments on a PR (general and inline) |
create_pull_request_comment |
Post a general comment on a PR (posted as pending/draft) |
create_inline_pull_request_comment |
Post an inline review comment pinned to a file and line (posted as pending/draft) |
list_pull_request_tasks |
List all tasks on a PR |
create_pull_request_task |
Create a task on a PR (optionally attach to a comment) |
update_pull_request_task |
Update task content or mark it RESOLVED / UNRESOLVED |
delete_pull_request_task |
Delete a task from a PR |
Requirements
- Node.js 18+
- A Bitbucket Cloud account
- A Bitbucket App Password (see below)
Installation
# Clone the repository
git clone https://github.com/your-org/bitbucket-mcp.git
cd bitbucket-mcp
# Install dependencies
npm install
# Build
npm run build
Environment Setup
Copy the example env file and fill in your credentials:
cp .env.example .env
Edit .env:
BITBUCKET_USERNAME=your_bitbucket_username
BITBUCKET_APP_PASSWORD=your_app_password
LOG_LEVEL=info
How to create a Bitbucket App Password
- Log in to bitbucket.org
- Click your avatar → Personal settings
- Go to App passwords → Create app password
- Give it a label (e.g.
mcp-server) - Select the following permissions:
- Repositories:
Read - Pull requests:
Read,Write(Write needed for posting comments)
- Repositories:
- Click Create and copy the generated password into
.env
Security: App passwords are scoped and can be revoked at any time. Never use your actual Bitbucket password.
Running Locally
# Development mode (with hot reload)
npm run dev
# Production
npm run build
npm start
The server communicates over stdio — it has no HTTP port. It is designed to be launched by an MCP client such as Claude Desktop.
Connecting to Claude Desktop
Add the following to your Claude Desktop config file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"bitbucket": {
"command": "node",
"args": ["/absolute/path/to/bitbucket-mcp/dist/server.js"],
"env": {
"BITBUCKET_USERNAME": "your_bitbucket_username",
"BITBUCKET_APP_PASSWORD": "your_app_password",
"LOG_LEVEL": "info"
}
}
}
}
Replace
/absolute/path/to/bitbucket-mcpwith the actual path where you cloned the repo.
After saving, restart Claude Desktop. You should see the Bitbucket tools available in Claude's tool list.
Example prompts
"List all repositories in my workspace 'acme-corp'"
"Show me the open pull requests in repo 'backend-api'"
"Fetch the diff for PR #42 in workspace 'acme-corp', repo 'backend-api'"
"List all comments on PR #42 in 'backend-api'"
"Post a comment on PR #42: 'LGTM! Great work on the refactor.'"
"List all tasks on PR #42 in 'backend-api'"
"Create a task on PR #42: 'Add unit tests for the new endpoint'"
"Mark task 7 on PR #42 as resolved"
"Delete task 7 from PR #42"
Development
# Lint
npm run lint
# Format
npm run format
# Watch mode
npm run dev
Troubleshooting
Server fails to start with "Missing required environment variable"
→ Make sure .env exists and both BITBUCKET_USERNAME and BITBUCKET_APP_PASSWORD are set.
401 Unauthorized errors → Verify your App Password is correct and has the required permissions (Repositories: Read, Pull requests: Read/Write).
403 Forbidden errors → Your account may not have access to the workspace or repository you're querying.
Tools not appearing in Claude Desktop
→ Check that the path in claude_desktop_config.json is correct and the build has run (npm run build). Restart Claude Desktop after config changes.
Large diffs are truncated → By design. Diffs over 500,000 characters are truncated with a notice appended. This prevents overwhelming the LLM context window.
Security Considerations
- Credentials are never logged. The Axios interceptors strip auth headers from all log output.
- No hardcoded secrets. All credentials are loaded exclusively from environment variables.
- All tool inputs are validated with Zod before any API call is made.
- Comment length is capped at 10,000 characters to prevent abuse.
- Use App Passwords (not your account password); they can be individually revoked.
- Run the server with the minimum required App Password permissions.
Project Structure
bitbucket-mcp/
├── src/
│ ├── server.ts # MCP server entry point
│ ├── config/
│ │ └── index.ts # Env var loading & validation
│ ├── services/
│ │ ├── bitbucket.client.ts # Axios client with auth & interceptors
│ │ └── bitbucket.service.ts # Bitbucket API methods
│ ├── tools/
│ │ ├── list-repositories.ts
│ │ ├── list-pull-requests.ts
│ │ ├── get-pull-request-details.ts
│ │ ├── get-pull-request-diff.ts
│ │ ├── list-pr-commits.ts
│ │ ├── list-pr-comments.ts
│ │ ├── create-pr-comment.ts
│ │ ├── create-inline-pr-comment.ts
│ │ ├── list-pr-tasks.ts
│ │ ├── create-pr-task.ts
│ │ ├── update-pr-task.ts
│ │ └── delete-pr-task.ts
│ └── utils/
│ ├── logger.ts # Pino logger (stderr only)
│ ├── errors.ts # Error normalization
│ └── pagination.ts # Auto-pagination utility
├── tests/
├── .env.example
├── .gitignore
├── .eslintrc.json
├── .prettierrc
├── LICENSE
├── package.json
├── tsconfig.json
└── README.md
Contributing
See CONTRIBUTING.md.
License
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。