Atlassian Bitbucket MCP Server

by aashari
Verified

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Integrations

  • Provides authentication and integration with Atlassian services, specifically focused on Bitbucket functionality using Atlassian API tokens.

  • Allows AI assistants to interact with Bitbucket repositories, including listing repositories, accessing pull requests, viewing commit information, and exploring workspaces.

Atlassian Bitbucket MCP 服务器

该项目提供了一个模型上下文协议 (MCP) 服务器,它充当 AI 助手(例如 Anthropic 的 Claude、Cursor AI 或其他兼容 MCP 的客户端)与您的 Atlassian Bitbucket 实例之间的桥梁。它允许 AI 实时安全地访问您的代码库、拉取请求和工作区并与之交互。


概述

什么是 MCP?

模型上下文协议 (MCP) 是一种开放标准,允许 AI 系统安全且上下文地与外部工具和数据源连接。

该服务器专门为 Bitbucket Cloud 实现 MCP,将您的 Bitbucket 数据与 AI 助手连接起来。

为什么要使用此服务器?

  • 最小输入,最大输出理念:您只需要像workspaceSlugrepoSlug这样的简单标识符。每个工具都会返回全面的详细信息,无需额外的参数。
  • 丰富的代码可视化:通过文件统计、差异视图和围绕代码修改的智能上下文,深入了解存储库和代码更改。
  • 安全的本地身份验证:凭证永远不会存储在服务器中。服务器在本地运行,因此您的令牌永远不会离开您的计算机,并且您可以只请求所需的权限。
  • 直观的 Markdown 回复:所有回复均使用结构良好的 Markdown,具有一致的格式和导航链接,以提高可读性。
  • 完整的 Bitbucket 集成:通过统一的界面访问工作区、存储库、拉取请求、评论、代码搜索等。

入门

先决条件

  • Node.js (>=18.x):下载
  • Bitbucket 云帐户

步骤 1:验证

选择以下身份验证方法之一:

选项 A:Bitbucket 应用程序密码(推荐)

Bitbucket App Passwords生成一个。最低权限:

  • 工作区:阅读
  • 存储库:阅读
  • 拉取请求:阅读

选项 B:Atlassian API 令牌

Atlassian API Tokens生成一个。


第 2 步:配置凭证

方法A:MCP配置文件(推荐)

创建或编辑~/.mcp/configs.json

使用 Bitbucket 应用程序密码:

{ "@aashari/mcp-server-atlassian-bitbucket": { "environments": { "ATLASSIAN_BITBUCKET_USERNAME": "<your_username>", "ATLASSIAN_BITBUCKET_APP_PASSWORD": "<your_app_password>" } } }

使用 Atlassian API 令牌:

{ "@aashari/mcp-server-atlassian-bitbucket": { "environments": { "ATLASSIAN_SITE_NAME": "bitbucket", "ATLASSIAN_USER_EMAIL": "<your_email>", "ATLASSIAN_API_TOKEN": "<your_api_token>" } } }

方法B:环境变量

运行服务器时直接传递凭据:

ATLASSIAN_BITBUCKET_USERNAME="<your_username>" \ ATLASSIAN_BITBUCKET_APP_PASSWORD="<your_app_password>" \ npx -y @aashari/mcp-server-atlassian-bitbucket

步骤3:连接你的AI助手

配置与 MCP 兼容的客户端以启动此服务器。

克劳德/光标配置:

{ "mcpServers": { "aashari/mcp-server-atlassian-bitbucket": { "command": "npx", "args": ["-y", "@aashari/mcp-server-atlassian-bitbucket"] } } }

此配置在运行时自动启动服务器。


工具

本节介绍将此服务器与 AI 助手配合使用时可用的 MCP 工具。请注意,MCP 工具使用snake_case -case) 来命名工具名称,使用camelCase来命名参数。

list_workspaces

列出可用的 Bitbucket 工作区。

{}

或者:

{ "query": "devteam" }

“显示我所有的 Bitbucket 工作区。”


get_workspace

获取特定工作区的完整详细信息。

{ "workspaceSlug": "acme-corp" }

“告诉我有关‘acme-corp’工作区的更多信息。”


list_repositories

列出工作区中的存储库。

{ "workspaceSlug": "acme-corp" }

或者:

{ "workspaceSlug": "acme-corp", "query": "api" }

“列出‘acme-corp’中的存储库。”


get_repository

获取特定存储库的详细信息。

{ "workspaceSlug": "acme-corp", "repoSlug": "backend-api" }

“向我显示‘acme-corp’中的‘backend-api’存储库。”


搜索 Bitbucket 内容。

存储库:

{ "workspaceSlug": "acme-corp", "query": "api", "scope": "repositories" }

拉取请求:

{ "workspaceSlug": "acme-corp", "repoSlug": "backend-api", "query": "fix", "scope": "pullrequests" }

提交:

{ "workspaceSlug": "acme-corp", "repoSlug": "backend-api", "query": "update", "scope": "commits" }

代码:

{ "workspaceSlug": "acme-corp", "query": "function getUser", "scope": "code" }

“在‘acme-corp’工作区中搜索‘function getUser’。”


list_pull_requests

列出存储库中的拉取请求。

{ "workspaceSlug": "acme-corp", "repoSlug": "frontend-app", "state": "OPEN" }

“在‘frontend-app’中显示打开的 PR。”


get_pull_request

获取拉取请求的完整详细信息,包括代码差异和文件更改。

{ "workspaceSlug": "acme-corp", "repoSlug": "frontend-app", "prId": "42" }

“从‘frontend-app’获取 PR #42 以及所有代码更改。”


list_pr_comments

列出对特定拉取请求的评论。

{ "workspaceSlug": "acme-corp", "repoSlug": "frontend-app", "prId": "42" }

“显示 PR #42 上的所有评论。”


add_pr_comment

向拉取请求添加评论。

一般的:

{ "workspaceSlug": "acme-corp", "repoSlug": "frontend-app", "prId": "42", "content": "Looks good." }

排队:

{ "workspaceSlug": "acme-corp", "repoSlug": "frontend-app", "prId": "42", "content": "Consider refactoring.", "inline": { "path": "src/utils.js", "line": 42 } }

“在第 42 行向 PR #42 添加一条评论。”


pull_requests_create

创建一个新的拉取请求。

{ "workspaceSlug": "acme-corp", "repoSlug": "frontend-app", "title": "Add login screen", "sourceBranch": "feature/login" }

“创建从‘feature/login’到‘main’的 PR。”


命令行界面 (CLI)

CLI 使用 kebab-case 来表示命令(例如, list-workspaces )和选项(例如, --workspace-slug )。

使用npx快速使用

npx -y @aashari/mcp-server-atlassian-bitbucket list-workspaces npx -y @aashari/mcp-server-atlassian-bitbucket get-repository \ --workspace-slug acme-corp \ --repo-slug backend-api

全局安装

npm install -g @aashari/mcp-server-atlassian-bitbucket

然后直接运行:

mcp-atlassian-bitbucket list-workspaces

发现更多 CLI 选项

使用--help查看所有可用命令的标志和用法:

mcp-atlassian-bitbucket --help

或者获取特定命令的详细帮助:

mcp-atlassian-bitbucket get-repository --help mcp-atlassian-bitbucket list-pull-requests --help mcp-atlassian-bitbucket search --help

执照

ISC 许可证

ID: d3mfwp6ce5