mcp server atlassian bitbucket
An integration tool that enables AI assistants like Claude to directly access and interact with Bitbucket repositories, pull requests, and code without requiring copy/paste operations.
An integration tool that enables AI assistants like Claude to directly access and interact with Bitbucket repositories, pull requests, and code without requiring copy/paste operations.
This project provides a Model Context Protocol (MCP) server that acts as a bridge between AI assistants (like Anthropic's Claude, Cursor AI, or other MCP-compatible clients) and your Atlassian Bitbucket instance. It allows AI to securely access and interact with your repositories, pull requests, and workspaces in real-time.
Model Context Protocol (MCP) is an open standard enabling AI models to connect securely to external tools and data sources. This server implements MCP specifically for Bitbucket Cloud.
Benefits:
This MCP server provides the following tools for your AI assistant:
List Workspaces (list-workspaces
)
{}
(no parameters needed for basic list) or { query: "devteam" }
(to filter).Get Workspace (get-workspace
)
{ workspaceSlug: "acme-corp" }
List Repositories (list-repositories
)
{ workspaceSlug: "acme-corp" }
or { workspaceSlug: "acme-corp", query: "backend" }
(to filter).Get Repository (get-repository
)
{ workspaceSlug: "acme-corp", repoSlug: "backend-api" }
List Pull Requests (list-pull-requests
)
{ workspaceSlug: "acme-corp", repoSlug: "frontend-app", state: "OPEN" }
Get Pull Request (get-pull-request
)
{ workspaceSlug: "acme-corp", repoSlug: "frontend-app", prId: "42" }
Add Pull Request Comment (add-pr-comment
)
{ workspaceSlug: "acme-corp", repoSlug: "frontend-app", prId: "42", content: "This looks good to merge" }
or with inline comment: { workspaceSlug: "acme-corp", repoSlug: "frontend-app", prId: "42", content: "Consider a constant here", inline: { path: "src/utils.js", line: 42 } }
Create Pull Request (create-pull-request
)
{ workspaceSlug: "acme-corp", repoSlug: "frontend-app", title: "Add new login screen", sourceBranch: "feature/new-login" }
or with more options: { workspaceSlug: "acme-corp", repoSlug: "frontend-app", title: "Fix login bug", sourceBranch: "bugfix/login", description: "This fixes issue #123", destinationBranch: "develop", closeSourceBranch: true }
This server follows a "Minimal Interface, Maximal Detail" approach:
workspaceSlug
, repoSlug
, prId
).get-repository
), the server provides all relevant information by default (description, owner, links, etc.) without needing extra flags.Follow these steps to connect your AI assistant to Bitbucket:
You have two options for authenticating with Bitbucket:
Important: Treat your App Password like a password. Do not share it or commit it to version control.
mcp-bitbucket-access
).Workspaces
: Read
Repositories
: Read
Pull requests
: Read
Important: Treat your API token like a password.
mcp-bitbucket-access
).Choose one of the following methods:
This keeps credentials separate and organized.
~/.mcp/
~/.mcp/configs.json
Add the configuration: Paste one of the following JSON structures, corresponding to your chosen authentication method, replacing the placeholders:
Using Bitbucket App Password:
{
"@aashari/mcp-server-atlassian-bitbucket": {
"environments": {
"ATLASSIAN_BITBUCKET_USERNAME": "<YOUR_BITBUCKET_USERNAME>",
"ATLASSIAN_BITBUCKET_APP_PASSWORD": "<YOUR_COPIED_APP_PASSWORD>"
}
}
// Add other servers here if needed
}
<YOUR_BITBUCKET_USERNAME>
: Your Bitbucket username.<YOUR_COPIED_APP_PASSWORD>
: The App Password from Step 1B.Using Atlassian API Token:
{
"@aashari/mcp-server-atlassian-bitbucket": {
"environments": {
"ATLASSIAN_SITE_NAME": "<YOUR_ATLASSIAN_SITE_NAME_UNUSED_BUT_NEEDED>",
"ATLASSIAN_USER_EMAIL": "<YOUR_ATLASSIAN_EMAIL>",
"ATLASSIAN_API_TOKEN": "<YOUR_COPIED_API_TOKEN>"
}
}
// Add other servers here if needed
}
<YOUR_ATLASSIAN_SITE_NAME_UNUSED_BUT_NEEDED>
: Enter any value (like bitbucket
). This field is required by the underlying transport but not used for Bitbucket API auth when using an API token.<YOUR_ATLASSIAN_EMAIL>
: Your Atlassian account email.<YOUR_COPIED_API_TOKEN>
: The API token from Step 1B.Set environment variables when running the server. Choose the set matching your authentication:
Using Bitbucket App Password:
ATLASSIAN_BITBUCKET_USERNAME="<YOUR_USERNAME>" nATLASSIAN_BITBUCKET_APP_PASSWORD="<YOUR_APP_PASSWORD>" nnpx -y @aashari/mcp-server-atlassian-bitbucket
Using Atlassian API Token:
ATLASSIAN_SITE_NAME="bitbucket" nATLASSIAN_USER_EMAIL="<YOUR_EMAIL>" nATLASSIAN_API_TOKEN="<YOUR_API_TOKEN>" nnpx -y @aashari/mcp-server-atlassian-bitbucket
Configure your MCP client (Claude Desktop, Cursor, etc.) to run this server.
Add or merge into mcpServers
:
{
"mcpServers": {
"aashari/mcp-server-atlassian-bitbucket": {
"command": "npx",
"args": ["-y", "@aashari/mcp-server-atlassian-bitbucket"]
}
// ... other servers
}
}
Save and Restart Claude Desktop.
Cmd+Shift+P
/ Ctrl+Shift+P
) > Cursor Settings > MCP.aashari/mcp-server-atlassian-bitbucket
command
npx -y @aashari/mcp-server-atlassian-bitbucket
You can now ask your AI assistant questions related to your Bitbucket instance:
You can also use this package directly from your terminal. Ensure credentials are set first (Method A or B above).
npx
npx -y @aashari/mcp-server-atlassian-bitbucket list-workspaces
npx -y @aashari/mcp-server-atlassian-bitbucket get-repository --workspace my-team --repository my-api
npx -y @aashari/mcp-server-atlassian-bitbucket list-pull-requests --workspace my-team --repository my-api --state OPEN
npx -y @aashari/mcp-server-atlassian-bitbucket create-pull-request --workspace my-team --repository my-api --title "New feature" --source-branch feature/new-login
npm install -g @aashari/mcp-server-atlassian-bitbucket
mcp-atlassian-bitbucket
command:mcp-atlassian-bitbucket list-workspaces --limit 5
mcp-atlassian-bitbucket get-pull-request --workspace my-team --repository my-api --pull-request 42
mcp-atlassian-bitbucket --help # See all commands
~/.mcp/configs.json
or environment variables. Ensure you used the correct set (App Password OR API Token).npx ...
) is correct in your client's config.npx
command directly in your terminal to see errors.DEBUG
environment variable to true
(e.g., add "DEBUG": "true"
in configs.json
or run DEBUG=true npx ...
).Contributions are welcome! If you'd like to contribute, please consider the following:
.cursorrules
file or code comments for more details.npm install
. Use npm run dev:server
to run with hot-reloading or npm run dev:cli -- <command>
to test CLI commands.npm run lint
and npm run format
.npm test
).This project (@aashari/mcp-server-atlassian-bitbucket
) follows Semantic Versioning and is versioned independently from other @aashari/mcp-server-*
packages.
[
{
"description": "List Bitbucket workspaces available to your account.nnPURPOSE: Discovers workspaces you have access to with their slugs, names, and permission levels to help navigate Bitbucket's organization structure.nnWHEN TO USE:n- When you need to discover what workspaces exist in your Bitbucket accountn- When you want to find the slugs needed for other Bitbucket operationsn- When you need to check what workspaces you have access to and their permission levelsn- Before accessing repositories or pull requests that require workspace informationn- When you're unfamiliar with the workspace organization structurennWHEN NOT TO USE:n- When you already know the workspace slug (use get-workspace or list-repositories instead)n- When you need detailed workspace information (use get-workspace instead)n- When you need to find specific repositories (use list-repositories after identifying the workspace)nnRETURNS: Formatted list of workspaces with slugs, names, and permission information, plus pagination details if available.nnEXAMPLES:n- List all workspaces: {}n- With sorting: {sort: "name"}n- With pagination: {limit: 10, cursor: "next-page-token"}nnERRORS:n- Authentication failures: Check your Bitbucket credentialsn- No workspaces found: You might not have access to any workspacesn- Rate limiting: Use pagination and reduce query frequency",
"inputSchema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"cursor": {
"description": "Pagination cursor for retrieving the next set of results. Obtain this value from the previous response when more results are available.",
"type": "string"
},
"limit": {
"description": "Maximum number of workspaces to return (1-100). Use this to control the response size. If omitted, defaults to 25.",
"exclusiveMinimum": 0,
"maximum": 100,
"type": "integer"
},
"q": {
"description": "Query string to filter workspaces by name. Performs a partial text match on workspace names. Example: "team" would match "my-team" and "team-project". If omitted, returns all accessible workspaces.",
"type": "string"
},
"sort": {
"description": "Field to sort results by. Common values: "name", "created_on", "updated_on". Prefix with "-" for descending order. Example: "-name" for reverse alphabetical order. If omitted, defaults to server-defined ordering.",
"type": "string"
}
},
"type": "object"
},
"name": "list-workspaces"
},
{
"description": "Get detailed information about a specific Bitbucket workspace by slug.nnPURPOSE: Retrieves comprehensive workspace metadata including projects, permissions, and configuration.nnWHEN TO USE:n- When you need detailed information about a specific workspacen- When you need to check workspace permissions or membershipn- When you need to verify workspace settings or configurationn- After using list-workspaces to identify the relevant workspacen- Before performing operations that require detailed workspace contextnnWHEN NOT TO USE:n- When you don't know which workspace to look for (use list-workspaces first)n- When you just need basic workspace information (slug, name)n- When you're only interested in repositories (use list-repositories directly)nnRETURNS: Detailed workspace information including slug, name, type, description, projects, and permission levels.nnEXAMPLES:n- Get workspace: {workspace: "myteam"}nnERRORS:n- Workspace not found: Verify the workspace slug is correctn- Permission errors: Ensure you have access to the requested workspacen- Rate limiting: Cache workspace information when possible",
"inputSchema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"workspace": {
"description": "Workspace slug to retrieve detailed information for. Must be a valid workspace slug from your Bitbucket account. Example: "myteam"",
"minLength": 1,
"type": "string"
}
},
"required": [
"workspace"
],
"type": "object"
},
"name": "get-workspace"
},
{
"description": "List Bitbucket repositories within a specific workspace.nnPURPOSE: Discovers repositories in a workspace with their slugs, names, and URLs to help navigate code resources.nnWHEN TO USE:n- When you need to find repositories within a specific workspacen- When you need repository slugs for other Bitbucket operationsn- When you want to explore available repositories before accessing specific contentn- When you need to check repository visibility and access levelsn- When looking for repositories with specific characteristics (language, size, etc.)nnWHEN NOT TO USE:n- When you don't know which workspace to look for repos in (use list-workspaces first)n- When you already know the repository slug (use get-repository instead)n- When you need detailed repository information (use get-repository instead)n- When you need to access pull requests or branches (use dedicated tools after identifying the repo)nnRETURNS: Formatted list of repositories with slugs, names, descriptions, URLs, and metadata, plus pagination info.nnEXAMPLES:n- List all repos in workspace: {workspace: "myteam"}n- With sorting: {workspace: "myteam", sort: "name"}n- With filtering: {workspace: "myteam", query: "api"}n- With pagination: {workspace: "myteam", limit: 10, cursor: "next-page-token"}nnERRORS:n- Workspace not found: Verify the workspace slug is correctn- Authentication failures: Check your Bitbucket credentialsn- Permission errors: Ensure you have access to the requested workspacen- Rate limiting: Use pagination and reduce query frequency",
"inputSchema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"cursor": {
"description": "Pagination cursor for retrieving the next set of results. Obtain this value from the previous response when more results are available.",
"type": "string"
},
"limit": {
"description": "Maximum number of repositories to return (1-100). Use this to control the response size. If omitted, defaults to 25.",
"exclusiveMinimum": 0,
"maximum": 100,
"type": "integer"
},
"q": {
"description": "Query string to filter repositories using Bitbucket query syntax. Example: "name ~ \"api\"" for repositories with "api" in the name. If omitted, returns all repositories.",
"type": "string"
},
"role": {
"description": "Filter repositories by the authenticated user's role. Common values: "owner", "admin", "contributor", "member". If omitted, returns repositories of all roles.",
"type": "string"
},
"sort": {
"description": "Field to sort results by. Common values: "name", "created_on", "updated_on". Prefix with "-" for descending order. Example: "-updated_on" for most recently updated first.",
"type": "string"
},
"workspace": {
"description": "Workspace slug containing the repositories. Must be a valid workspace slug from your Bitbucket account. Example: "myteam"",
"minLength": 1,
"type": "string"
}
},
"required": [
"workspace"
],
"type": "object"
},
"name": "list-repositories"
},
{
"description": "Get detailed information about a specific Bitbucket repository.nnPURPOSE: Retrieves comprehensive repository metadata including branches, settings, permissions, and more.nnWHEN TO USE:n- When you need detailed information about a specific repositoryn- When you need repository URLs, clone links, or other reference informationn- When you need to check repository settings or permissionsn- After using list-repositories to identify the relevant repositoryn- Before performing operations that require repository context (PRs, branches)nnWHEN NOT TO USE:n- When you don't know which repository to look for (use list-repositories first)n- When you just need basic repository informationn- When you're looking for pull request details (use list-pullrequests instead)n- When you need content from multiple repositories (use list-repositories instead)nnRETURNS: Detailed repository information including slug, name, description, URLs, branch information, and settings.nnEXAMPLES:n- Get repository: {workspace: "myteam", repoSlug: "project-api"}nnERRORS:n- Repository not found: Verify workspace and repository slugsn- Permission errors: Ensure you have access to the requested repositoryn- Rate limiting: Cache repository information when possible",
"inputSchema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"includeBranches": {
"description": "When true, includes information about repository branches in the response. If omitted, defaults to false.",
"type": "boolean"
},
"includeCommits": {
"description": "When true, includes recent commits information in the response. If omitted, defaults to false.",
"type": "boolean"
},
"includePullRequests": {
"description": "When true, includes open pull requests information in the response. If omitted, defaults to false.",
"type": "boolean"
},
"repoSlug": {
"description": "Repository slug to retrieve. This must be a valid repository in the specified workspace. Example: "project-api"",
"minLength": 1,
"type": "string"
},
"workspace": {
"description": "Workspace slug containing the repository. Must be a valid workspace slug from your Bitbucket account. Example: "myteam"",
"minLength": 1,
"type": "string"
}
},
"required": [
"workspace",
"repoSlug"
],
"type": "object"
},
"name": "get-repository"
},
{
"description": "List Bitbucket pull requests with optional filtering capabilities.nnPURPOSE: Allows you to find and browse pull requests across repositories with filtering options.nnWHEN TO USE:n- When you need to find pull requests within a specific repositoryn- When you want to check PR status (open, merged, declined, etc.)n- When you need to track code review activity and progressn- When you need PR IDs for other Bitbucket operationsn- When monitoring contributions from specific authorsnnWHEN NOT TO USE:n- When you don't know which repository to look in (use list-repositories first)n- When you already know the PR ID (use get-pull-request instead)n- When you need detailed PR content or comments (use get-pull-request instead)n- When you need to browse repositories rather than PRs (use list-repositories)nnRETURNS: Formatted list of pull requests with IDs, titles, states, authors, branch information, and URLs, plus pagination info.nnEXAMPLES:n- List all PRs in a repo: {workspace: "myteam", repoSlug: "project-api"}n- Filter by state: {workspace: "myteam", repoSlug: "project-api", state: "OPEN"}n- With pagination: {workspace: "myteam", repoSlug: "project-api", limit: 10, cursor: "next-page-token"}nnERRORS:n- Repository not found: Verify workspace and repository slugsn- Authentication failures: Check your Bitbucket credentialsn- Permission errors: Ensure you have access to the requested repositoryn- Rate limiting: Use pagination and reduce query frequency",
"inputSchema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"cursor": {
"description": "Pagination cursor for retrieving the next set of results. Obtain this value from the previous response when more results are available.",
"type": "string"
},
"limit": {
"description": "Maximum number of pull requests to return (1-100). Use this to control the response size. If omitted, defaults to 25.",
"exclusiveMinimum": 0,
"maximum": 100,
"type": "integer"
},
"repoSlug": {
"description": "Repository slug containing the pull requests. This must be a valid repository in the specified workspace. Example: "project-api"",
"minLength": 1,
"type": "string"
},
"state": {
"description": "Filter pull requests by state. Options: "OPEN" (active PRs), "MERGED" (completed PRs), "DECLINED" (rejected PRs), or "SUPERSEDED" (replaced PRs). If omitted, defaults to showing all states.",
"enum": [
"OPEN",
"MERGED",
"DECLINED",
"SUPERSEDED"
],
"type": "string"
},
"workspace": {
"description": "Workspace slug containing the repository. Must be a valid workspace slug from your Bitbucket account. Example: "myteam"",
"minLength": 1,
"type": "string"
}
},
"required": [
"workspace",
"repoSlug"
],
"type": "object"
},
"name": "list-pull-requests"
},
{
"description": "Get detailed information about a specific Bitbucket pull request.nnPURPOSE: Retrieves comprehensive PR data including description, comments, diff stats, reviewers, and branch information.nnWHEN TO USE:n- When you need the full description and context of a specific PRn- When you need to see comments, reviews, or approvalsn- When you need details about the source and destination branchesn- When you need diff statistics or changed files informationn- After using list-pull-requests to identify the relevant PR IDnnWHEN NOT TO USE:n- When you don't know which PR to look for (use list-pull-requests first)n- When you need to browse multiple PRs (use list-pull-requests instead)n- When you only need basic PR information without comments or detailsn- When you need repository information rather than PR details (use get-repository)nnRETURNS: Detailed PR information including title, description, status, author, reviewers, branches, comments, and related timestamps.nnEXAMPLES:n- Get PR details: {workspace: "myteam", repoSlug: "project-api", id: 42}nnERRORS:n- PR not found: Verify workspace, repository slugs, and PR IDn- Permission errors: Ensure you have access to the requested PRn- Rate limiting: Cache PR information when possible for frequently referenced PRs",
"inputSchema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"includeComments": {
"description": "Whether to include comments in the response. When true, includes all comments on the pull request. If omitted, defaults to false.",
"type": "boolean"
},
"pullRequestId": {
"description": "Numeric ID of the pull request to retrieve. Must be a valid pull request ID in the specified repository. Example: 42",
"exclusiveMinimum": 0,
"type": "integer"
},
"repoSlug": {
"description": "Repository slug containing the pull request. This must be a valid repository in the specified workspace. Example: "project-api"",
"minLength": 1,
"type": "string"
},
"workspace": {
"description": "Workspace slug containing the repository. Must be a valid workspace slug from your Bitbucket account. Example: "myteam"",
"minLength": 1,
"type": "string"
}
},
"required": [
"workspace",
"repoSlug",
"pullRequestId"
],
"type": "object"
},
"name": "get-pull-request"
}
]