Bitbucket MCP Server
Bitbucket MCP 서버
Bitbucket API와 상호작용하기 위한 도구를 제공하는 MCP(Model Context Protocol) 서버로, Bitbucket Cloud와 Bitbucket Server를 모두 지원합니다.
기능
사용 가능한 도구 (총 29개)
PR 핵심 (pr_core)
get_pull_request- 댓글, 파일 변경 사항, 병합 정보를 포함한 전체 PR 세부 정보list_pull_requests- 필터(상태, 작성자, 페이지네이션)를 사용하여 PR 목록 조회create_pull_request- 새 풀 리퀘스트 생성update_pull_request- PR 세부 정보 업데이트(제목, 설명, 리뷰어, 대상 브랜치)merge_pull_request- 다양한 전략으로 풀 리퀘스트 병합decline_pull_request- 풀 리퀘스트 거절/반려
PR 댓글 (pr_comments)
add_comment- PR에 일반, 인라인, 스레드 또는 제안 댓글 추가delete_comment- 풀 리퀘스트에서 댓글 삭제
코드 리뷰 (pr_review)
get_pull_request_diff- ADDED/REMOVED/CONTEXT 유형을 포함한 구조화된 줄 단위 diffset_pr_approval- PR 승인(approved: true) 또는 승인 취소(approved: false)set_review_status- 변경 요청(request_changes: true) 또는 요청 제거(false)
PR 작업 — Bitbucket Server 전용 (pr_tasks)
list_pr_tasks- 풀 리퀘스트의 모든 작업 목록 조회create_pr_task- 풀 리퀘스트에 새 작업 생성update_pr_task- 기존 작업의 텍스트 업데이트set_pr_task_status- 작업을 완료(done: true)로 표시하거나 다시 열기(done: false)delete_pr_task- 풀 리퀘스트에서 작업 삭제convert_pr_item- 댓글을 작업으로 변환(direction: "to_task")하거나 다시 댓글로 변환("to_comment")
커밋 (commits)
list_pr_commits- 풀 리퀘스트의 모든 커밋 목록 조회list_branch_commits- 날짜/작성자/메시지 필터를 사용하여 브랜치의 커밋 목록 조회get_commit_detail- SHA를 통해 특정 커밋의 구조화된 diff 가져오기
브랜치 (branches)
list_branches- 필터링 및 페이지네이션을 사용하여 브랜치 목록 조회get_branch- 관련 PR 및 통계를 포함한 상세 브랜치 정보delete_branch- 브랜치 삭제
파일 (files)
list_directory_content- 저장소 경로의 파일 및 디렉토리 목록 조회get_file_content- 대용량 파일에 대한 스마트 잘림 기능을 포함하여 파일 내용 가져오기search_files- glob 패턴으로 파일 검색 (대소문자 구분 안 함, VS Code Ctrl+P와 유사)
검색 — Bitbucket Server 전용 (search)
search_code- 저장소 전체에서 코드 검색search_repositories- 이름 또는 설명으로 저장소 검색
탐색 (discovery)
list_projects- 액세스 가능한 모든 Bitbucket 프로젝트/워크스페이스 목록 조회list_repositories- 프로젝트 내 또는 액세스 가능한 모든 프로젝트의 저장소 목록 조회
토큰 최적화
v2.0.0에서는 모든 LLM 요청에 대해 상당한 토큰 절감 효과를 제공합니다:
구성 | 노출된 도구 | 예상 토큰 |
Bitbucket Server (모든 그룹) | 29 | ~5,100 |
Bitbucket Cloud (자동 필터링) | 21 | ~3,900 |
사용자 지정 그룹 프리셋 (예: | 12 | ~2,100 |
Bitbucket Cloud는 구성 없이도 10개의 서버 전용 도구를 자동으로 숨깁니다.
**BITBUCKET_TOOL_GROUPS**를 사용하면 워크플로우와 관련된 그룹만 노출할 수 있습니다. 아래의 도구 그룹 필터링을 참조하세요.
Related MCP server: MCP Server
설치
npx 사용 (권장)
이 MCP 서버를 사용하는 가장 쉬운 방법은 npx를 직접 사용하는 것입니다:
{
"mcpServers": {
"bitbucket": {
"command": "npx",
"args": [
"-y",
"@nexus2520/bitbucket-mcp-server"
],
"env": {
"BITBUCKET_USERNAME": "your-username",
"BITBUCKET_APP_PASSWORD": "your-app-password"
}
}
}
}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"
}
}
}
}소스에서 설치
이 저장소를 복제하거나 다운로드합니다.
종속성을 설치합니다:
npm installTypeScript 코드를 빌드합니다:
npm run build
인증 설정
이 서버는 인증을 위해 Bitbucket 앱 비밀번호를 사용합니다.
앱 비밀번호 생성
Bitbucket 계정에 로그인합니다.
다음으로 이동합니다: https://bitbucket.org/account/settings/app-passwords/
"앱 비밀번호 생성"을 클릭합니다.
설명 레이블을 지정합니다 (예: "MCP Server").
다음 권한을 선택합니다:
계정: 읽기
저장소: 읽기, 쓰기
풀 리퀘스트: 읽기, 쓰기
"생성"을 클릭합니다.
중요: 생성된 비밀번호를 즉시 복사하세요 (다시 볼 수 없습니다!)
설정 스크립트 실행
node scripts/setup-auth.js이 스크립트가 인증 설정 과정을 안내합니다.
구성
MCP 설정 파일(일반적으로 ~/.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"
}
}
}
}다음 내용을 교체하세요:
/absolute/path/to/bitbucket-mcp-server를 이 디렉토리의 실제 경로로your-username을 Bitbucket 사용자 이름(이메일 아님)으로your-app-password를 생성한 앱 비밀번호로
Bitbucket Server의 경우 다음을 사용하세요:
{
"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"
}
}
}
}Bitbucket Server 사용자를 위한 중요 사항:
사용자 이름으로 전체 이메일 주소를 사용하세요 (예: "john.doe@company.com")
승인/리뷰 작업이 올바르게 작동하려면 이 설정이 필요합니다.
도구 그룹 필터링
BITBUCKET_TOOL_GROUPS를 그룹 이름의 쉼표로 구분된 목록으로 설정하여 모든 요청 시 LLM으로 전송되는 도구 수를 줄이세요. 나열된 그룹의 도구만 노출됩니다.
사용 가능한 그룹
그룹 | 도구 | 플랫폼 |
|
| 둘 다 |
|
| 둘 다 |
|
| 둘 다 |
|
| 서버 전용 |
|
| 둘 다 |
|
| 둘 다 |
|
| 둘 다 |
|
| 서버 전용 |
|
| 둘 다 |
예시 프리셋
PR 리뷰 워크플로우 (~2,100 토큰):
"env": {
"BITBUCKET_TOOL_GROUPS": "pr_core,pr_review,files"
}전체 PR 관리 (~3,500 토큰):
"env": {
"BITBUCKET_TOOL_GROUPS": "pr_core,pr_comments,pr_review,pr_tasks"
}코드 탐색 전용 (~1,400 토큰):
"env": {
"BITBUCKET_TOOL_GROUPS": "files,search,discovery"
}BITBUCKET_TOOL_GROUPS가 설정되지 않으면 적용 가능한 모든 도구가 노출됩니다(기본 동작). Bitbucket Cloud 사용자는 이 설정과 관계없이 서버 전용 도구가 자동으로 숨겨집니다.
사용법
구성 후에는 사용 가능한 도구를 사용할 수 있습니다:
풀 리퀘스트 가져오기
{
"tool": "get_pull_request",
"arguments": {
"workspace": "PROJ", // Required - your project key
"repository": "my-repo",
"pull_request_id": 123
}
}다음 내용을 포함한 풀 리퀘스트에 대한 상세 정보를 반환합니다:
제목 및 설명
작성자 및 리뷰어
소스 및 대상 브랜치
승인 상태
웹 UI 및 diff 링크
병합 커밋 세부 정보 (PR이 병합된 경우):
merge_commit_hash: 병합 커밋의 해시merged_by: 병합을 수행한 사람merged_at: 병합이 발생한 시간merge_commit_message: 병합 커밋 메시지
중첩된 답글이 있는 활성 댓글 (주의가 필요한 해결되지 않은 댓글):
active_comments: 활성 댓글 배열 (최근 상위 댓글 최대 20개)댓글 텍스트 및 작성자
생성 날짜
인라인 댓글 여부 (파일 경로 및 줄 번호 포함)
중첩된 답글 (Bitbucket Server의 경우):
replies: 동일한 구조의 답글 댓글 배열답글은 여러 단계로 중첩될 수 있음
상위 참조 (Bitbucket Cloud의 경우):
parent_id: 답글의 상위 댓글 ID
active_comment_count: 해결되지 않은 댓글의 총 개수 (중첩된 답글 포함)total_comment_count: 모든 댓글의 총 개수 (해결된 댓글 및 답글 포함)
파일 변경 사항:
file_changes: PR에서 수정된 모든 파일의 배열파일 경로
상태 (추가됨, 수정됨, 삭제됨 또는 이름 변경됨)
이전 경로 (이름이 변경된 파일의 경우)
file_changes_summary: 요약 통계변경된 총 파일 수
기타 등등...
코드 검색
Bitbucket 저장소 전체에서 코드를 검색합니다 (현재 Bitbucket Server에서만 지원):
// Search in a specific repository
{
"tool": "search_code",
"arguments": {
"workspace": "PROJ",
"repository": "my-repo",
"search_query": "TODO",
"limit": 50
}
}
// Search across all repositories in a workspace
{
"tool": "search_code",
"arguments": {
"workspace": "PROJ",
"search_query": "deprecated",
"file_pattern": "*.java", // Optional: filter by file pattern
"limit": 100
}
}
// Search with file pattern filtering
{
"tool": "search_code",
"arguments": {
"workspace": "PROJ",
"repository": "frontend-app",
"search_query": "useState",
"file_pattern": "*.tsx", // Only search in .tsx files
"start": 0,
"limit": 25
}
}다음 내용을 포함한 검색 결과를 반환합니다:
파일 경로 및 이름
저장소 및 프로젝트 정보
일치하는 줄:
줄 번호
전체 줄 내용
정확히 일치하는 부분을 강조 표시한 세그먼트
페이지네이션 정보
응답 예시:
{
"message": "Code search completed successfully",
"workspace": "PROJ",
"repository": "my-repo",
"search_query": "TODO",
"results": [
{
"file_path": "src/utils/helper.js",
"file_name": "helper.js",
"repository": "my-repo",
"project": "PROJ",
"matches": [
{
"line_number": 42,
"line_content": " // TODO: Implement error handling",
"highlighted_segments": [
{ "text": " // ", "is_match": false },
{ "text": "TODO", "is_match": true },
{ "text": ": Implement error handling", "is_match": false }
]
}
]
}
],
"total_count": 15,
"start": 0,
"limit": 50,
"has_more": false
}참고: 이 도구는 현재 Bitbucket Server에서만 작동합니다. Bitbucket Cloud 지원은 향후 릴리스에서 계획되어 있습니다.
풀 리퀘스트 목록 조회
{
"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)
}
}다음 내용을 포함한 페이지네이션된 풀 리퀘스트 목록을 반환합니다:
get_pull_request와 동일한 세부 정보를 가진 풀 리퀘스트 배열
일치하는 PR의 총 개수
페이지네이션 정보 (has_more, next_start)
작성자 필터 참고:
Bitbucket Cloud의 경우: 사용자 이름 사용 (예: "johndoe")
Bitbucket Server의 경우: 전체 이메일 주소 사용 (예: "john.doe@company.com")
풀 리퀘스트 생성
{
"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 - see note below
}
}리뷰어에 대한 중요 참고 사항:
reviewers매개변수를 지정하지 않고 PR을 업데이트하면 기존 리뷰어와 해당 승인 상태가 유지됩니다.reviewers매개변수를 제공하는 경우:리뷰어 목록이 새 목록으로 교체됩니다.
PR에 이미 존재하는 리뷰어의 경우 승인 상태가 유지됩니다.
새로운 리뷰어는 승인 상태 없이 추가됩니다.
이는 PR 설명이나 제목만 업데이트하려 할 때 실수로 리뷰어를 제거하는 것을 방지합니다.
댓글 추가
풀 리퀘스트에 일반 댓글 또는 특정 코드에 대한 인라인 댓글을 추가합니다:
// 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}"
}
}제안 기능은 Bitbucket이 렌더링할 수 있는 GitHub 스타일의 마크다운 제안 블록을 사용하여 댓글을 형식화합니다. 제안을 추가할 때:
suggestion은 필수이며 대체 코드를 포함합니다.제안을 사용할 때는
file_path와line_number가 필수입니다.suggestion_end_line은 선택 사항이며 여러 줄 제안에 사용됩니다 (기본값은line_number).댓글은 Bitbucket UI에서 적용 가능한
```suggestion마크다운 블록으로 형식화됩니다.
줄 번호 대신 코드 스니펫 사용
add_comment 도구는 이제 코드 스니펫을 사용하여 줄 번호를 자동으로 찾는 기능을 지원합니다. 이는 AI 도구가 diff를 분석할 때 정확한 줄 번호를 찾기 어려울 수 있는 경우 특히 유용합니다:
// 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: 찾을 정확한 코드 줄 (line_number의 대안)search_context: 여러 일치 항목을 구분하기 위한 선택적 컨텍스트before: 대상 앞에 나타나야 하는 줄 배열after: 대상 뒤에 나타나야 하는 줄 배열
match_strategy: 여러 일치 항목을 처리하는 방법"strict"(기본값): 모든 일치 항목을 보여주며 오류와 함께 실패"best": 가장 높은 신뢰도의 일치 항목을 자동 선택
여러 일치 항목에 대한 오류 응답 (strict 모드):
{
"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"
}
}이 기능은 특히 다음 경우에 유용합니다:
diff를 분석하는 AI 기반 코드 리뷰 도구
코드 패턴을 기반으로 자동으로 댓글을 추가하는 스크립트
대규모 diff에서 줄 번호 혼동 방지
댓글 답글 참고:
parent_comment_id를 사용하여 모든 댓글(일반 또는 인라인)에 답글을 달 수 있습니다.get_pull_request응답에서:Bitbucket Server는 답글을
replies배열에 중첩하여 보여줍니다.Bitbucket Cloud는 답글 댓글에
parent_id필드를 보여줍니다.
답글에 답글을 달아 중첩된 대화를 만들 수 있습니다.
인라인 댓글 참고:
file_path: diff에 표시된 파일 경로line_number: diff에 표시된 줄 번호line_type:ADDED- 새로 추가된 줄 (diff에서 녹색)`REMO
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/pdogra1299/bitbucket-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server