
Bitbucket
STDIOBitbucket API交互工具,支持云端和服务器版本
Bitbucket API交互工具,支持云端和服务器版本
An MCP (Model Context Protocol) server that provides tools for interacting with the Bitbucket API, supporting both Bitbucket Cloud and Bitbucket Server.
get_pull_request
- Retrieve detailed information about a pull requestlist_pull_requests
- List pull requests with filters (state, author, pagination)create_pull_request
- Create new pull requestsupdate_pull_request
- Update PR details (title, description, reviewers, destination branch)add_comment
- Add comments to pull requests (supports replies)merge_pull_request
- Merge pull requests with various strategiesdelete_branch
- Delete branches after mergeget_pull_request_diff
- Get the diff/changes for a pull requestapprove_pull_request
- Approve a pull requestunapprove_pull_request
- Remove approval from a pull requestrequest_changes
- Request changes on a pull requestremove_requested_changes
- Remove change request from a pull requestThe easiest way to use this MCP server is directly with npx:
{ "mcpServers": { "bitbucket": { "command": "npx", "args": [ "-y", "@nexus2520/bitbucket-mcp-server" ], "env": { "BITBUCKET_USERNAME": "your-username", "BITBUCKET_APP_PASSWORD": "your-app-password" } } } }
For Bitbucket Server:
{ "mcpServers": { "bitbucket": { "command": "npx", "args": [ "-y", "@nexus2520/bitbucket-mcp-server" ], "env": { "BITBUCKET_USERNAME": "[email protected]", "BITBUCKET_TOKEN": "your-http-access-token", "BITBUCKET_BASE_URL": "https://bitbucket.yourcompany.com" } } } }
npm install
npm run build
This server uses Bitbucket App Passwords for authentication.
node scripts/setup-auth.js
This will guide you through the authentication setup process.
Add the server to your MCP settings file (usually located at ~/.vscode-server/data/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
):
{ "mcpServers": { "bitbucket": { "command": "node", "args": ["/absolute/path/to/bitbucket-mcp-server/build/index.js"], "env": { "BITBUCKET_USERNAME": "your-username", "BITBUCKET_APP_PASSWORD": "your-app-password" } } } }
Replace:
/absolute/path/to/bitbucket-mcp-server
with the actual path to this directoryyour-username
with your Bitbucket username (not email)your-app-password
with the app password you createdFor Bitbucket Server, use:
{ "mcpServers": { "bitbucket": { "command": "node", "args": ["/absolute/path/to/bitbucket-mcp-server/build/index.js"], "env": { "BITBUCKET_USERNAME": "[email protected]", "BITBUCKET_TOKEN": "your-http-access-token", "BITBUCKET_BASE_URL": "https://bitbucket.yourcompany.com" } } } }
Important for Bitbucket Server users:
Once configured, you can use the available tools:
{ "tool": "get_pull_request", "arguments": { "workspace": "PROJ", // Required - your project key "repository": "my-repo", "pull_request_id": 123 } }
Returns detailed information about the pull request including:
merge_commit_hash
: The hash of the merge commitmerged_by
: Who performed the mergemerged_at
: When the merge occurredmerge_commit_message
: The merge commit message{ "tool": "list_pull_requests", "arguments": { "workspace": "PROJ", // Required - your project key "repository": "my-repo", "state": "OPEN", // Optional: OPEN, MERGED, DECLINED, ALL (default: OPEN) "author": "username", // Optional: filter by author (see note below) "limit": 25, // Optional: max results per page (default: 25) "start": 0 // Optional: pagination start index (default: 0) } }
Returns a paginated list of pull requests with:
Note on Author Filter:
{ "tool": "create_pull_request", "arguments": { "workspace": "PROJ", "repository": "my-repo", "title": "Add new feature", "source_branch": "feature/new-feature", "destination_branch": "main", "description": "This PR adds a new feature...", // Optional "reviewers": ["john.doe", "jane.smith"], // Optional "close_source_branch": true // Optional (default: false) } }
{ "tool": "update_pull_request", "arguments": { "workspace": "PROJ", "repository": "my-repo", "pull_request_id": 123, "title": "Updated title", // Optional "description": "Updated description", // Optional "destination_branch": "develop", // Optional "reviewers": ["new.reviewer"] // Optional - replaces existing reviewers } }
Add general comments or inline comments on specific lines of code:
// General comment { "tool": "add_comment", "arguments": { "workspace": "PROJ", "repository": "my-repo", "pull_request_id": 123, "comment_text": "Great work! Just one small suggestion...", "parent_comment_id": 456 // Optional - for replies } } // Inline comment on specific code { "tool": "add_comment", "arguments": { "workspace": "PROJ", "repository": "my-repo", "pull_request_id": 123, "comment_text": "This variable should be renamed for clarity", "file_path": "src/main.js", "line_number": 42, "line_type": "ADDED" // ADDED, REMOVED, or CONTEXT } }
Note on inline comments:
file_path
: The path to the file as shown in the diffline_number
: The line number as shown in the diffline_type
:
ADDED
- For newly added lines (green in diff)REMOVED
- For deleted lines (red in diff)CONTEXT
- For unchanged context lines{ "tool": "merge_pull_request", "arguments": { "workspace": "PROJ", "repository": "my-repo", "pull_request_id": 123, "merge_strategy": "squash", // Optional: merge-commit, squash, fast-forward "close_source_branch": true, // Optional "commit_message": "Custom merge message" // Optional } }
{ "tool": "list_branches", "arguments": { "workspace": "PROJ", "repository": "my-repo", "filter": "feature", // Optional: filter by name pattern "limit": 25, // Optional (default: 25) "start": 0 // Optional: for pagination (default: 0) } }
Returns a paginated list of branches with:
{ "tool": "delete_branch", "arguments": { "workspace": "PROJ", "repository": "my-repo", "branch_name": "feature/old-feature", "force": false // Optional (default: false) } }
Note: Branch deletion requires appropriate permissions. The branch will be permanently deleted.
{ "tool": "get_pull_request_diff", "arguments": { "workspace": "PROJ", "repository": "my-repo", "pull_request_id": 123, "context_lines": 5 // Optional (default: 3) } }
{ "tool": "approve_pull_request", "arguments": { "workspace": "PROJ", "repository": "my-repo", "pull_request_id": 123 } }
{ "tool": "request_changes", "arguments": { "workspace": "PROJ", "repository": "my-repo", "pull_request_id": 123, "comment": "Please address the following issues..." // Optional } }
npm run dev
- Watch mode for developmentnpm run build
- Build the TypeScript codenpm start
- Run the built serverMIT