Bitbucket MCP Server

Bitbucket MCP Server

Enables retrieval of pull request metadata and diffs from Bitbucket Cloud and Server/Data Center, with optional comment creation.

Category
访问服务器

README

Bitbucket MCP Server

License: MIT CI Node.js MCP

A production-focused Model Context Protocol server for retrieving pull request metadata and diffs from Bitbucket Cloud and Bitbucket Server/Data Center, with opt-in pull request comments.

Features

  • Supports Bitbucket Cloud and self-hosted Bitbucket Server/Data Center.
  • Exposes focused tools for pull request metadata, diffs, and general or inline comments.
  • Supports bearer tokens and basic authentication.
  • Returns raw diffs plus structured changed-file data when Bitbucket provides it.
  • Caps large diffs without breaking UTF-8 characters.
  • Uses stdio without writing protocol-breaking logs to stdout.
  • Keeps comment creation disabled by default and does not approve, merge, or otherwise modify pull requests.

Quick start

Requires a supported Node.js LTS release (Node.js 22 or newer).

git clone https://github.com/inceon/bitbucket-mcp.git
cd bitbucket-mcp
npm install
npm run build
cp .env.example .env

Set BITBUCKET_URL and BITBUCKET_TOKEN in your MCP client configuration, then launch the compiled server with node dist/index.js. The server intentionally does not load .env files itself; MCP clients should pass environment variables directly.

Authentication

Bearer authentication is the default and is recommended for Bitbucket Server/Data Center personal access tokens:

BITBUCKET_URL=https://bitbucket.example.com/bitbucket
BITBUCKET_TOKEN=your-personal-access-token
BITBUCKET_AUTH_TYPE=bearer

For Bitbucket Cloud API tokens or app passwords that require basic authentication:

BITBUCKET_URL=https://api.bitbucket.org
BITBUCKET_TOKEN=your-api-token-or-app-password
BITBUCKET_AUTH_TYPE=basic
BITBUCKET_USERNAME=your-bitbucket-username

Grant the credential only the permissions needed for the tools you enable. Comment creation requires permission to create pull request comments. Never commit credentials or put real tokens in issue reports.

Environment variables

Variable Required Default Description
BITBUCKET_URL Yes - Bitbucket base URL, such as https://api.bitbucket.org or https://bitbucket.example.com/bitbucket
BITBUCKET_TOKEN Yes - API token, app password, or personal access token
BITBUCKET_AUTH_TYPE No bearer bearer or basic
BITBUCKET_USERNAME For basic auth - Username paired with the token for basic auth
BITBUCKET_MAX_DIFF_BYTES No 1000000 Maximum UTF-8 byte size returned in rawDiff
BITBUCKET_ENABLE_WRITE_TOOLS No false Set to true to allow tools that modify Bitbucket, currently PR comment creation

The server writes startup errors only to stderr and redacts configured credentials from Bitbucket HTTP error snippets.

MCP configuration

Claude Desktop configuration:

{
  "mcpServers": {
    "bitbucket": {
      "command": "node",
      "args": ["/absolute/path/to/my-bitbucket-mcp/dist/index.js"],
      "env": {
        "BITBUCKET_URL": "https://api.bitbucket.org",
        "BITBUCKET_TOKEN": "your-token"
      }
    }
  }
}

Codex config.toml configuration:

[mcp_servers.bitbucket]
command = "node"
args = ["/absolute/path/to/my-bitbucket-mcp/dist/index.js"]

[mcp_servers.bitbucket.env]
BITBUCKET_URL = "https://api.bitbucket.org"
BITBUCKET_TOKEN = "your-token"

Available tools

get_pull_request

Returns pull request metadata, including its description, state, author, reviewers, branches, timestamps, and links.

{
  "name": "get_pull_request",
  "arguments": {
    "workspace": "my-workspace",
    "repository": "my-repository",
    "pull_request_id": 123
  }
}

get_pull_request_diff

Returns the raw diff and structured changed files when available.

{
  "name": "get_pull_request_diff",
  "arguments": {
    "workspace": "PROJECT_KEY",
    "repository": "my-repository",
    "pull_request_id": 123
  }
}

Diff output includes provider, pull_request_id, rawDiff, optional files, and truncated. Truncation respects UTF-8 character boundaries.

add_pull_request_comment

Creates a general, file-level, or inline line comment on a pull request. This write operation is available only when BITBUCKET_ENABLE_WRITE_TOOLS=true is set in the MCP server environment.

General comment:

{
  "name": "add_pull_request_comment",
  "arguments": {
    "workspace": "my-workspace",
    "repository": "my-repository",
    "pull_request_id": 123,
    "comment": "The implementation looks good. Please add a regression test for the empty input case."
  }
}

Inline comment on an added line:

{
  "name": "add_pull_request_comment",
  "arguments": {
    "workspace": "my-workspace",
    "repository": "my-repository",
    "pull_request_id": 123,
    "comment": "Please handle an empty value here.",
    "file_path": "src/service.ts",
    "line": 42,
    "line_type": "added"
  }
}

Use line_type values added, removed, or context. Added lines default to the new side, removed lines default to the old side, and context lines default to new; set line_side explicitly to place a context comment on old. Provide file_path without line fields for a file-level comment. For renamed files on Server/Data Center, source_file_path can identify the previous path.

The authenticated Bitbucket user becomes the comment author. Review the target workspace, repository, pull request ID, and comment text before approving the tool call in your MCP client.

Provider behavior

The URL host determines the provider. bitbucket.org and api.bitbucket.org use Bitbucket Cloud; all other hosts use Server/Data Center.

Cloud URLs are normalized to one /2.0 API prefix and use:

  • /repositories/{workspace}/{repository}/pullrequests/{id}
  • /repositories/{workspace}/{repository}/pullrequests/{id}/diff
  • /repositories/{workspace}/{repository}/pullrequests/{id}/diffstat
  • /repositories/{workspace}/{repository}/pullrequests/{id}/comments (POST, when enabled)

Server/Data Center URLs preserve a context path such as /bitbucket, normalize to one /rest/api/1.0 prefix, and use:

  • /projects/{project}/repos/{repository}/pull-requests/{id}
  • /projects/{project}/repos/{repository}/pull-requests/{id}/diff
  • /projects/{project}/repos/{repository}/pull-requests/{id}/changes
  • /projects/{project}/repos/{repository}/pull-requests/{id}/comments (POST, when enabled)

The optional diffstat or changes request is omitted from the result when the Bitbucket instance does not provide it.

Roadmap

Planned areas for future releases include:

  • [ ] Follow pagination for complete Cloud diffstat and Server/Data Center changes results.
  • [ ] Add request timeouts, retry handling, and clearer rate-limit diagnostics.
  • [ ] Provide normalized pull request output while retaining access to provider-specific fields.
  • [ ] Add read-only tools for listing pull requests and retrieving commits, comments, and build status.
  • [ ] Offer an optional Streamable HTTP transport while keeping stdio as the default.
  • [ ] Publish versioned releases with simpler installation and upgrade paths.

Write operations will remain disabled by default. Approving, merging, and other high-impact Bitbucket operations are not planned. Ideas and implementation proposals are welcome through GitHub issues.

Development

npm run dev        # Run directly from TypeScript
npm run build      # Compile to dist/
npm test           # Run the test suite once
npm run test:watch # Run tests in watch mode
npm run check      # Build and test, matching CI

The command registry keeps each MCP tool isolated under src/tools. See CONTRIBUTING.md before opening a pull request.

Security

This server handles credentials in memory and sends them only to the configured BITBUCKET_URL. Review that URL carefully before starting the server. Enabling write tools allows connected MCP clients to publish PR comments as the authenticated Bitbucket user. To report a vulnerability privately, follow SECURITY.md.

License

Released under the MIT License.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选