Bitbucket MCP Server
About
Manage Bitbucket repositories, pull requests, and pipelines via the Bitbucket API for both Cloud and Server.
Details
- Author
- pdogra1299
- GitHub stars
- 24
- Downloads
- 454
- Categories
- Developer Tools, Other, Infrastructure, API
Jump to
- 29 tools covering PRs, comments, attachments, reviews, tasks, commits, branches, files, search, and discovery.
- Supports both Bitbucket Cloud and Bitbucket Server.
- Tool group filtering reduces token usage by exposing only needed tools.
- Bitbucket Cloud automatically hides server-only tools.
- Structured diffs, inline comments, nested replies, and merge commit details.
- Code search with index-backed search, file content search with regex, and repository search.
Setting up with Highlight
This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:
- Download and install Highlight from highlightai.com/download
- Navigate to the plugins tab and select "Add Custom Plugin"
-
Configure the plugin with the settings below
Plugin Name
Bitbucket MCP ServerCommand (node, npx, python, etc.)Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.
- Enable "Start Automatically" if you want the plugin to start when Highlight launches
From the repository
Install via npx -y @nexus2520/bitbucket-mcp-server or from source. Configure the server in your MCP settings file with environment variables (BITBUCKET_USERNAME, BITBUCKET_APP_PASSWORD for Cloud; for Server additionally BITBUCKET_TOKEN and BITBUCKET_BASE_URL). Optionally set BITBUCKET_TOOL_GROUPS to expose only desired tool groups. Then invoke any of the 29 tools (e.g., get_pull_request, search_code).
Claude Desktop / Cursor
Paste into your MCP client config file to install this server.
{
"mcpServers": {
"bitbucket mcp server": {
"bitbucket-mcp-server": {
"command": "node",
"args": [
"scripts/setup-auth.js"
]
}
}
}
}
McpServers
{
"bitbucket-mcp-server": {
"command": "node",
"args": [
"scripts/setup-auth.js"
]
}
}
Bitbucket MCP Server
An MCP (Model Context Protocol) server that provides tools for interacting with the Bitbucket API, supporting both Bitbucket Cloud and Bitbucket Server.
Features
Available Tools (29 total)
PR Core (pr_core)
- get_pull_request - Full PR details including comments, file changes, and merge info
- list_pull_requests - List PRs with filters (state, author, pagination)
- create_pull_request - Create new pull requests
- update_pull_request - Update PR details (title, description, reviewers, destination branch)
- merge_pull_request - Merge pull requests with various strategies
- decline_pull_request - Decline/reject a pull request
PR Comments (pr_comments)
- add_comment - Add general, inline, threaded, or suggestion comments to a PR (supports attachments, Server only)
- delete_comment - Delete a comment from a pull request
Attachments — Bitbucket Server only (attachments)
- manage_attachments - Download (action: "download") or delete (action: "delete") an existing repository attachment by numeric id
- To upload a file, pass the attachments parameter to add_comment, create_pull_request, or update_pull_request (see Attachments). There is no list operation — Bitbucket exposes no attachment-listing API.
Code Review (pr_review)
- get_pull_request_diff - Structured line-by-line diff with ADDED/REMOVED/CONTEXT types
- set_pr_approval - Approve (approved: true) or unapprove (approved: false) a PR
- set_review_status - Request changes (request_changes: true) or remove the request (false)
PR Tasks — Bitbucket Server only (pr_tasks)
- list_pr_tasks - List all tasks on a pull request
- create_pr_task - Create a new task on a pull request
- update_pr_task - Update the text of an existing task
- set_pr_task_status - Mark a task done (done: true) or reopen it (done: false)
- delete_pr_task - Delete a task from a pull request
- convert_pr_item - Convert a comment to a task (direction: "to_task") or back ("to_comment")
Commits (commits)
- list_pr_commits - List all commits in a pull request
- list_branch_commits - List commits in a branch with date/author/message filters
- get_commit_detail - Get the structured diff for a specific commit by SHA
Branches (branches)
- list_branches - List branches with filtering and pagination
- get_branch - Detailed branch info including associated PRs and stats
- delete_branch - Delete a branch
Files (files)
- list_directory_content - List files and directories in a repository path
- get_file_content - Get file content with smart truncation for large files
- search_files - Search for files by glob pattern (case-insensitive, like VS Code Ctrl+P)
- get_file_blame - Per-line blame: who last modified each line, commit hash, and author timestamp (Bitbucket Server only)
Search — Bitbucket Server only (search)
- search_code - Index-backed code search with Bitbucket modifiers (lang:, ext:, path:, archived:, fork:, -term), client-side regex_filter post-filter, snake_case ↔ camelCase fanout, and an index-reach probe that surfaces INDEX_GAP_LIKELY when the index returns nothing despite matching files existing
- find_in_files - Content search via file listing + raw-content fan-out. Full PCRE regex; works on languages or branches Bitbucket's index does not cover; with rate-limit detection and honest scan diagnostics
- search_repositories - Search for repositories by name, slug, or description
Discovery (discovery)
- list_projects - List all accessible Bitbucket projects/workspaces
- list_repositories - List repositories in a project or across all accessible projects
Token Optimization
v2.0.0 introduces significant token savings on every LLM request:
| Configuration | Tools exposed | Est. tokens |
|---|---|---|
| Bitbucket Server (all groups) | 29 | ~5,100 |
| Bitbucket Cloud (auto-filtered) | 21 | ~3,900 |
| Custom group preset (e.g. pr_core,pr_review,files) | 12 | ~2,100 |
Bitbucket Cloud automatically hides the 10 server-only tools with no configuration needed.
BITBUCKET_TOOL_GROUPS lets you expose only the groups relevant to your workflow — see Tool Group Filtering below.
Installation
Using npx (Recommended)
The 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": "your.email@company.com",
"BITBUCKET_TOKEN": "your-http-access-token",
"BITBUCKET_BASE_URL": "https://bitbucket.yourcompany.com"
}
}
}
}
From Source
1. Clone or download this repository
2. Install dependencies:
npm install
3. Build the TypeScript code:
npm run build
Authentication Setup
This server uses Bitbucket App Passwords for authentication.
Creating an App Password
1. Log in to your Bitbucket account
2. Navigate to: https://bitbucket.org/account/settings/app-passwords/
3. Click "Create app password"
4. Give it a descriptive label (e.g., "MCP Server")
5. Select the following permissions:
- Account: Read
- Repositories: Read, Write
- Pull requests: Read, Write
6. Click "Create"
7. Important: Copy the generated password immediately (you won't be able to see it again!)
Running the Setup Script
node scripts/setup-auth.js
This will guide you through the authentication setup process.
Configuration
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 directory
- your-username with your Bitbucket username (not email)
- your-app-password with the app password you created
For Bitbucket Server, use:
{
"mcpServers": {
"bitbucket": {
"command": "node",
"args": ["/absolute/path/to/bitbucket-mcp-server/build/index.js"],
"env": {
"BITBUCKET_USERNAME": "your.email@company.com",
"BITBUCKET_TOKEN": "your-http-access-token",
"BITBUCKET_BASE_URL": "https://bitbucket.yourcompany.com"
}
}
}
}
Important for Bitbucket Server users:
- Use your full email address as the username (e.g., "john.doe@company.com")
- This is required for approval/review actions to work correctly
Tool Group Filtering
Reduce the number of tools sent to the LLM on every request by setting BITBUCKET_TOOL_GROUPS to a comma-separated list of group names. Only tools in the listed groups will be exposed.
Available groups
| Group | Tools | Platform |
|---|---|---|
| pr_core | get_pull_request, list_pull_requests, create_pull_request, update_pull_request, merge_pull_request, decline_pull_request | Both |
| pr_comments | add_comment, delete_comment | Both |
| attachments | manage_attachments | Server only |
| pr_review | get_pull_request_diff, set_pr_approval, set_review_status | Both |
| pr_tasks | list_pr_tasks, create_pr_task, update_pr_task, set_pr_task_status, delete_pr_task, convert_pr_item | Server only |
| commits | list_pr_commits, list_branch_commits, get_commit_detail | Both |
| branches | list_branches, get_branch, delete_branch | Both |
| files | list_directory_content, get_file_content, search_files, get_file_blame (Server only) | Both |
| search | search_code, find_in_files, search_repositories | Server only |
| discovery | list_projects, list_repositories | Both |
Example presets
PR review workflow (~2,100 tokens):
"env": {
"BITBUCKET_TOOL_GROUPS": "pr_core,pr_review,files"
}
Full PR management (~3,500 tokens):
"env": {
"BITBUCKET_TOOL_GROUPS": "pr_core,pr_comments,pr_review,pr_tasks"
}
Code exploration only (~1,400 tokens):
"env": {
"BITBUCKET_TOOL_GROUPS": "files,search,discovery"
}
When BITBUCKET_TOOL_GROUPS is not set, all applicable tools are exposed (default behaviour). Bitbucket Cloud users always have server-only tools automatically hidden regardless of this setting.
Usage
Once configured, you can use the available tools:
Get Pull Request
{
"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:
- Title and description
- Author and reviewers
- Source and destination branches
- Approval status
- Links to web UI and diff
- Merge commit details (when PR is merged):
- merge_commit_hash: The hash of the merge commit
- merged_by: Who performed the merge
- merged_at: When the merge occurred
- merge_commit_message: The merge commit message
- Active comments with nested replies (unresolved comments that need attention):
- active_comments: Array of active comments (up to 20 most recent top-level comments)
- Comment text and author
- Creation date
- Whether it's an inline comment (with file path and line number)
- Nested replies (for Bitbucket Server):
- replies: Array of reply comments with same structure
- Replies can be nested multiple levels deep
- Parent reference (for Bitbucket Cloud):
- parent_id: ID of the parent comment for replies
- active_comment_count: Total count of unresolved comments (including nested replies)
- total_comment_count: Total count of all comments (including resolved and replies)
- File changes:
- file_changes: Array of all files modified in the PR
- File path
- Status (added, modified, removed, or renamed)
- Old path (for renamed files)
- file_changes_summary: Summary statistics
- Total files changed
- And more...
Search Code
Index-backed exact-term search via Bitbucket Server's search index (Bitbucket Server only). Fast — one API call.
// Search in a specific repository
{
"tool": "search_code",
"arguments": {
"workspace": "PROJ",
"repository": "my-repo",
"query": "TODO",
"limit": 50
}
}
// Filter by language and exclude noise
{
"tool": "search_code",
"arguments": {
"workspace": "PROJ",
"repository": "my-repo",
"query": "deprecated",
"lang": "java",
"exclude_terms": ["test", "spec"]
}
}
// Filter by extension and post-filter the result lines with a client-side regex
{
"tool": "search_code",
"arguments": {
"workspace": "PROJ",
"repository": "frontend-app",
"query": "useState",
"ext": "tsx",
"regex_filter": "^\\sconst\\s+\\[",
"case_variants": true
}
}
Inputs
- workspace (required) — project key (e.g. PROJ).
- query (required) — exact term or phrase. No regex / wildcards / fuzzy match at this layer (the Bitbucket index does not support them).
- repository — repo slug. Omit to search all repos in the project.
- lang — Bitbucket lang: modifier (e.g. python, java). One expression covers all extensions for the language.
- ext — extension without dot (e.g. tsx). Use when lang is too broad.
- path — subpath scope (Bitbucket path: modifier).
- exclude_terms — array of terms to exclude (each becomes -term).
- archived — true / false / (default: active only).
- fork — true / false.
- regex_filter — client-side regex applied to returned hit lines as a post-filter; lets you narrow results without spending Bitbucket query budget.
- case_variants — if true, also runs the query with snake_case ↔ camelCase converted and merges results (one extra API call).
- limit (default 25) and start for pagination.
Bitbucket index limits to know about
- Punctuation other than . and _ is stripped at index time. Including =, (, : in your query does not narrow it.
- Case-insensitive. Single-character terms ignored.
- Implicit AND between terms; OR / NOT / parentheses supported (operators ALL CAPS).
- Hard caps: 250 characters total query, max 9 expressions, only files <512 KiB are indexed, only the default branch is indexed.
When constructed clauses exceed the cap, optional clauses are dropped one-at-a-time in priority order (exclude_terms → archived → fork → ext → lang → path → repo) and a QUERY_TRUNCATED warning is emitted.
Output (dense JSON)
{
"query": "doSomething",
"filters": { "project": "PROJ", "repo": "my-repo" },
"engine": "bitbucket_index",
"total_files": 2,
"total_matches": 3,
"files": [
{
"path": "src/lib/handler.ts",
"matches": [
{ "line": 17, "text": " const result = await doSomething(payload);" },
{ "line": 42, "text": "export function doSomething(input: Input) {" }
]
},
{
"path": "tests/handler.test.ts",
"matches": [
{ "line": 9, "text": " expect(doSomething(sample)).toEqual(expected);" }
]
}
],
"warnings": [],
"next_start": null,
"diagnostics": {
"default_branch_only": true,
"expression_count": 3,
"query_length": 42,
"dropped_clauses": []
}
}
Only lines that actually match are returned (no surrounding context unless explicitly requested by regex_filter). total_files and total_matches are distinct. engine is bitbucket_index for search_code.
Warnings to act on
- INDEX_GAP_LIKELY — Bitbucket returned zero hits but matching files exist. Switch to find_in_files. If a lang: filter was set, the warning calls it out specifically — Bitbucket may not recognize that language name.
- REGEX_FILTER_REJECTED_ALL — Bitbucket returned hits but your regex_filter killed them all. Adjust or drop it.
- PROBE_UNAVAILABLE — index returned zero AND the file-list probe could not run. Cannot tell whether the term is missing or the index has a gap.
- QUERY_TRUNCATED — soft-degrade dropped optional clauses to fit Bitbucket caps; the dropped clauses are listed in diagnostics.dropped_clauses.
- DEPRECATED_PARAM — old parameter names (search_query, search_context, include_patterns, file_pattern) still work but should be migrated.
Find in Files
Content search by listing files and reading them through Bitbucket's raw endpoint. Slower than search_code (1 + N API calls), but supports full regex and works where the index has gaps (Haskell, feature branches, files Bitbucket's index missed). Bitbucket Server only.
// Recover a function in files the index does not cover (e.g. an unindexed language)
{
"tool": "find_in_files",
"arguments": {
"workspace": "PROJ",
"repository": "my-repo",
"filename_pattern": "src//.hs",
"content_query": "doSomething"
}
}
// Search a feature branch
{
"tool": "find_in_files",
"arguments": {
"workspace": "PROJ",
"repository": "my-repo",
"branch": "feat/new-thing",
"filename_pattern": "src/
/.py",
"content_query": "^class\\s+Order"
}
}
Inputs
- workspace, repository, content_query (required). content_query is a JS regex (PCRE-style) applied line-by-line to file contents.
- filename_pattern — glob to scope the file set. Strongly recommended. Without it, the tool fans out across the whole repo and is likely to truncate or trip rate limits.
- branch — defaults to the default branch.
- regex_filter — optional second regex applied as a post-filter on each candidate hit line.
- max_files — hard cap on files fetched (default 3000). If exceeded, response includes truncated: true and (on zero matches) a POSSIBLE_FALSE_NEGATIVE warning.
- parallelism — concurrent file fetches (default 4). Higher values risk rate-limiting; on RATE_LIMITED warning, lower this and narrow filename_pattern.
- limit — max total hit lines (default 25).
Rate-limit awareness
find_in_files watches HTTP status codes during fan-out:
- A single 429 aborts the scan immediately.
- Three or more consecutive 403s also abort (likely rate-limited rather than per-file permission).
- A successful read between failures resets the counter.
When aborted early, the response includes a RATE_LIMITED warning with aborted_after / total counts in diagnostics.
Output
Same dense JSON shape as search_code, with engine: "find_in_files" and diagnostics fields specific to fan-out:
"diagnostics": {
"files_scanned": 16,
"files_attempted": 16,
"files_failed": 0,
"files_truncated": false,
"default_branch_only": false
}
Note: Both search_code and find_in_files work only with Bitbucket Server. Bitbucket Cloud support is not planned.
List Pull Requests
{
"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:
- Array of pull requests with same details as get_pull_request
- Total count of matching PRs
- Pagination info (has_more, next_start)
Note on Author Filter:
- For Bitbucket Cloud: Use the username (e.g., "johndoe")
- For Bitbucket Server: Use the full email address (e.g., "john.doe@company.com")
Create Pull Request
{
"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)
}
}
Update Pull Request
{
"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 - see note below
}
}
Important Note on Reviewers:
- When updating a PR without specifying the reviewers parameter, existing reviewers and their approval status are preserved
- When providing the reviewers parameter:
- The reviewer list is replaced with the new list
- For reviewers that already exist on the PR, their approval status is preserved
- New reviewers are added without approval status
- This prevents accidentally removing reviewers when you only want to update the PR description or title
Add Comment
Add a comment to a pull request, either as a general comment or inline on specific code:
// General comment
{
"tool": "add_comment",
"arguments": {
"workspace": "PROJ",
"repository": "my-repo",
"pull_request_id": 123,
"comment_text": "Great work on this PR!"
}
}
// Inline comment on specific line
{
"tool": "add_comment",
"arguments": {
"workspace": "PROJ",
"repository": "my-repo",
"pull_request_id": 123,
"comment_text": "Consider extracting this into a separate function",
"file_path": "src/utils/helpers.js",
"line_number": 42,
"line_type": "CONTEXT" // ADDED, REMOVED, or CONTEXT
}
}
// Reply to existing comment
{
"tool": "add_comment",
"arguments": {
"workspace": "PROJ",
"repository": "my-repo",
"pull_request_id": 123,
"comment_text": "I agree with this suggestion",
"parent_comment_id": 456
}
}
// Add comment with code suggestion (single line)
{
"tool": "add_comment",
"arguments": {
"workspace": "PROJ",
"repository": "my-repo",
"pull_request_id": 123,
"comment_text": "This variable name could be more descriptive.",
"file_path": "src/utils/helpers.js",
"line_number": 42,
"line_type": "CONTEXT",
"suggestion": "const userAuthenticationToken = token;"
}
}
// Add comment with multi-line code suggestion
{
"tool": "add_comment",
"arguments": {
"workspace": "PROJ",
"repository": "my-repo",
"pull_request_id": 123,
"comment_text": "This function could be simplified using array methods.",
"file_path": "src/utils/calculations.js",
"line_number": 50,
"suggestion_end_line": 55,
"line_type": "CONTEXT",
"suggestion": "function calculateTotal(items) {\n return items.reduce((sum, item) => sum + item.price, 0);\n}"
}
}
The suggestion feature formats comments using GitHub-style markdown suggestion blocks that Bitbucket can render. When adding a suggestion:
- suggestion is required and contains the replacement code
- file_path and line_number are required when using suggestions
- suggestion_end_line is optional and used for multi-line suggestions (defaults to line_number)
- The comment will be formatted with a ```suggestion markdown block that may be applicable in the Bitbucket UI
Using Code Snippets Instead of Line Numbers
The add_comment tool now supports finding line numbers automatically using code snippets. This is especially useful when AI tools analyze diffs and may struggle with exact line numbers:
// Add comment using code snippet
{
"tool": "add_comment",
"arguments": {
"workspace": "PROJ",
"repository": "my-repo",
"pull_request_id": 123,
"comment_text": "This variable name could be more descriptive",
"file_path": "src/components/Button.res",
"code_snippet": "let isDisabled = false",
"search_context": {
"before": ["let onClick = () => {"],
"after": ["setLoading(true)"]
}
}
}
// Handle multiple matches with strategy
{
"tool": "add_comment",
"arguments": {
"workspace": "PROJ",
"repository": "my-repo",
"pull_request_id": 123,
"comment_text": "Consider extracting this",
"file_path": "src/utils/helpers.js",
"code_snippet": "return result;",
"search_context": {
"before": ["const result = calculate();"],
"after": ["}"]
},
"match_strategy": "best" // Auto-select highest confidence match
}
}
Code Snippet Parameters:
- code_snippet: The exact code line to find (alternative to line_number)
- search_context: Optional context to disambiguate multiple matches
- before: Array of lines that should appear before the target
- after: Array of lines that should appear after the target
- match_strategy: How to handle multiple matches
- "strict" (default): Fail with error showing all matches
- "best": Auto-select the highest confidence match
Error Response for Multiple Matches (strict mode):
{
"error": {
"code": "MULTIPLE_MATCHES_FOUND",
"message": "Code snippet 'return result;' found in 3 locations",
"occurrences": [
{
"line_number": 42,
"file_path": "src/utils/helpers.js",
"preview": " const result = calculate();\n> return result;\n}",
"confidence": 0.9,
"line_type": "ADDED"
},
// ... more matches
],
"suggestion": "To resolve, either:\n1. Add more context...\n2. Use match_strategy: 'best'...\n3. Use line_number directly"
}
}
This feature is particularly useful for:
- AI-powered code review tools that analyze diffs
- Scripts that automatically add comments based on code patterns
- Avoiding line number confusion in large diffs
Note on comment replies:
- Use parent_comment_id to reply to any comment (general or inline)
- In get_pull_request responses:
- Bitbucket Server shows replies nested in a replies array
- Bitbucket Cloud shows a parent_id field for reply comments
- You can reply to replies, creating nested conversations
Note on inline comments:
- file_path: The path to the file as shown in the diff
- line_number: The line number as shown in the diff
- line_type:
- ADDED - For newly added lines (green in diff)
- REMOVED - For deleted lines (red in diff)
- CONTEXT - For unchanged context lines
Add Comment - Complete Usage Guide
The add_comment tool supports multiple scenarios. Here's when and how to use each approach:
1. General PR Comments (No file/line)
- Use when: Making overall feedback about the PR
- Required params: comment_text only
- Example: "LGTM!", "Please update the documentation"
2. Reply to Existing Comments
- Use when: Continuing a conversation thread
- Required params: comment_text, parent_comment_id
- Works for both general and inline comment replies
3. Inline Comments with Line Number
- Use when: You know the exact line number from the diff
- Required params: comment_text, file_path, line_number
- Optional: line_type (defaults to CONTEXT)
4. Inline Comments with Code Snippet
- Use when: You have the code but not the line number (common for AI tools)
- Required params: comment_text, file_path, code_snippet
- The tool will automatically find the line number
- Add search_context if the code appears multiple times
- Use match_strategy: "best" to auto-select when multiple matches exist
5. Code Suggestions
- Use when: Proposing specific code changes
- Required params: comment_text, file_path, line_number, suggestion
- For multi-line: also add suggestion_end_line
- Creates applicable suggestion blocks in Bitbucket UI
Decision Flow for AI/Automated Tools:
1. Do you want to suggest code changes?
→ Use suggestion with line_number
2. Do you have the exact line number?
→ Use line_number directly
3. Do you have the code snippet but not line number?
→ Use code_snippet (add search_context if needed)
4. Is it a general comment about the PR?
→ Use comment_text only
5. Are you replying to another comment?
→ Add parent_comment_id
Common Pitfalls to Avoid:
- Don't use both line_number and code_snippet - pick one
- Suggestions always need file_path and line_number
- Code snippets must match exactly (including whitespace)
- REMOVED lines reference the source file, ADDED/CONTEXT reference the destination
Merge Pull Request
{
"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
}
}
List Branches
{
"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:
- Branch name and ID
- Latest commit hash
- Default branch indicator
- Pagination info
Delete Branch
{
"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.
Get Branch
{
"tool": "get_branch",
"arguments": {
"workspace": "PROJ",
"repository": "my-repo",
"branch_name": "feature/new-feature",
"include_merged_prs": false // Optional (default: false)
}
}
Returns comprehensive branch information including:
- Branch details:
- Name and ID
- Latest commit (hash, message, author, date)
- Default branch indicator
- Open pull requests from this branch:
- PR title and ID
- Destination branch
- Author and reviewers
- Approval status (approved by, changes requested by, pending)
- PR URL
- Merged pull requests (if include_merged_prs is true):
- PR title and ID
- Merge date and who merged it
- Statistics:
- Total open PRs count
- Total merged PRs count
- Days since last commit
This tool is particularly useful for:
- Checking if a branch has open PRs before deletion
- Getting an overview of branch activity
- Understanding PR review status
- Identifying stale branches
List Branch Commits
Get all commits in a specific branch with advanced filtering options:
```typescript
// Basic usage - get recent commits
{
"tool": "list_branch_commits",
"arguments": {
"workspace": "PROJ",
"repository": "my-repo",
"branch_name": "feature/new-feature",
"limit": 50 // Optional (default: 25)
}
}
// Filter by date range
{
"tool": "list_branch_commits",
"arguments": {
"workspace": "PROJ",
"repository": "my-repo",
"branch_name": "main",
"since": "2025-01-01T00:00:00Z", // ISO date string
"until": "2025-01-15T23:59:59Z" // ISO date string
}
}
// Filter by author
{
"tool": "list_branch_commits",
"arguments": {
"workspace": "PROJ",
"repository": "my-repo",
"branch_name": "develop",
"author": "john.doe@company.com", // Email or username
"limit": 100
}
}
// Exclude merge commits
{
"tool": "list_branch_commits",
"arguments": {
"workspace": "PROJ",
"repository": "my-repo",
"branch_name": "release/v2.0",
"include_merge_commits": false
}
}
// Search in commit messages
{
"tool": "list_branch_commits",
"arguments": {
"workspace": "PROJ",
"reposito
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.





