mcp-bitbucket-server 1.7.1 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +148 -207
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/services/bitbucket.d.ts +3 -3
- package/dist/services/bitbucket.d.ts.map +1 -1
- package/dist/services/bitbucket.js +3 -3
- package/dist/services/bitbucket.js.map +1 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +2 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/projects/list_projects.js +1 -1
- package/dist/tools/projects/list_projects.js.map +1 -1
- package/dist/tools/pull-requests/add_pr_comment.js +2 -2
- package/dist/tools/pull-requests/add_pr_comment.js.map +1 -1
- package/dist/tools/pull-requests/add_pr_comment_reaction.js +1 -1
- package/dist/tools/pull-requests/add_pr_comment_reaction.js.map +1 -1
- package/dist/tools/pull-requests/add_pr_file_comment.js +2 -2
- package/dist/tools/pull-requests/add_pr_file_comment.js.map +1 -1
- package/dist/tools/pull-requests/add_pr_line_comment.js +2 -2
- package/dist/tools/pull-requests/add_pr_line_comment.js.map +1 -1
- package/dist/tools/pull-requests/create_pull_request.d.ts +3 -0
- package/dist/tools/pull-requests/create_pull_request.d.ts.map +1 -0
- package/dist/tools/pull-requests/create_pull_request.js +37 -0
- package/dist/tools/pull-requests/create_pull_request.js.map +1 -0
- package/dist/tools/pull-requests/delete_pr_comment.js +1 -1
- package/dist/tools/pull-requests/delete_pr_comment.js.map +1 -1
- package/dist/tools/pull-requests/get_inbox_pull_requests.js +1 -1
- package/dist/tools/pull-requests/get_inbox_pull_requests.js.map +1 -1
- package/dist/tools/pull-requests/get_pr_activities.js +1 -1
- package/dist/tools/pull-requests/get_pr_activities.js.map +1 -1
- package/dist/tools/pull-requests/get_pr_changes.js +2 -2
- package/dist/tools/pull-requests/get_pr_changes.js.map +1 -1
- package/dist/tools/pull-requests/get_pr_details.js +1 -1
- package/dist/tools/pull-requests/get_pr_details.js.map +1 -1
- package/dist/tools/pull-requests/get_pr_diff.js +1 -1
- package/dist/tools/pull-requests/get_pr_diff.js.map +1 -1
- package/dist/tools/pull-requests/get_pr_file_diff.js +1 -1
- package/dist/tools/pull-requests/get_pr_file_diff.js.map +1 -1
- package/dist/tools/pull-requests/index.d.ts +1 -0
- package/dist/tools/pull-requests/index.d.ts.map +1 -1
- package/dist/tools/pull-requests/index.js +1 -0
- package/dist/tools/pull-requests/index.js.map +1 -1
- package/dist/tools/pull-requests/remove_pr_comment_reaction.js +1 -1
- package/dist/tools/pull-requests/remove_pr_comment_reaction.js.map +1 -1
- package/dist/tools/pull-requests/update_review_status.js +1 -1
- package/dist/tools/pull-requests/update_review_status.js.map +1 -1
- package/dist/tools/repositories/list_repositories.js +1 -1
- package/dist/tools/repositories/list_repositories.js.map +1 -1
- package/dist/tools/tools.types.d.ts +1 -1
- package/dist/tools/users/get_all_users.js +1 -1
- package/dist/tools/users/get_all_users.js.map +1 -1
- package/dist/tools/users/get_user_profile.js +1 -1
- package/dist/tools/users/get_user_profile.js.map +1 -1
- package/package.json +2 -1
- package/dist/client/bitbucket.client.d.ts +0 -79
- package/dist/client/bitbucket.client.d.ts.map +0 -1
- package/dist/client/bitbucket.client.js +0 -176
- package/dist/client/bitbucket.client.js.map +0 -1
- package/dist/client/bitbucket.types.d.ts +0 -823
- package/dist/client/bitbucket.types.d.ts.map +0 -1
- package/dist/client/bitbucket.types.js +0 -5
- package/dist/client/bitbucket.types.js.map +0 -1
- package/dist/client/index.d.ts +0 -3
- package/dist/client/index.d.ts.map +0 -1
- package/dist/client/index.js +0 -4
- package/dist/client/index.js.map +0 -1
package/CLAUDE.md
CHANGED
|
@@ -8,21 +8,22 @@ This is an MCP (Model Context Protocol) server for Bitbucket Server/Data Center
|
|
|
8
8
|
- **User management**: Get user profile, list all users
|
|
9
9
|
- **Project operations**: List projects with filtering
|
|
10
10
|
- **Repository operations**: List repositories in a project
|
|
11
|
-
- **Pull request operations**:
|
|
11
|
+
- **Pull request operations**: Create PR, get PR details, get inbox PRs, get changed files, get full/file diffs (text and structured), add comments (three separate tools: general, file-level, and line-level), delete comments, add/remove emoticon reactions, get activities, update review status (approve/request changes)
|
|
12
12
|
|
|
13
13
|
## Architecture
|
|
14
14
|
|
|
15
|
-
This is a **simple, straightforward implementation**
|
|
15
|
+
This is a **simple, straightforward implementation** using the `bitbucket-data-center-client` library:
|
|
16
16
|
|
|
17
17
|
```
|
|
18
|
-
Tool →
|
|
18
|
+
Tool → bitbucketService (BitbucketClient) → Bitbucket Server REST API
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
**Key principles:**
|
|
22
|
-
-
|
|
22
|
+
- Use the `bitbucket-data-center-client` library for all API calls
|
|
23
|
+
- Type-safe client methods (no manual endpoint construction)
|
|
23
24
|
- Minimal error handling (let errors bubble up)
|
|
24
25
|
- Simple, readable code
|
|
25
|
-
- Verify
|
|
26
|
+
- Verify endpoint capabilities against Swagger documentation when needed
|
|
26
27
|
|
|
27
28
|
## Bitbucket Server API Documentation
|
|
28
29
|
|
|
@@ -40,23 +41,15 @@ grep -n '"/api/latest/users"' BitbucketServerSwagger.json
|
|
|
40
41
|
# Use the line number from grep, then read ~80 lines
|
|
41
42
|
```
|
|
42
43
|
|
|
43
|
-
### API Base URL
|
|
44
|
-
|
|
45
|
-
All endpoints use: `${BITBUCKET_URL}/rest/api/latest`
|
|
46
|
-
|
|
47
|
-
Example: `https://your-bitbucket-server.com/rest/api/latest/users`
|
|
48
|
-
|
|
49
44
|
### Authentication
|
|
50
45
|
|
|
51
|
-
|
|
46
|
+
The `bitbucket-data-center-client` library handles authentication automatically using Bearer tokens.
|
|
52
47
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
```
|
|
48
|
+
Configuration is done via environment variables in `.env`:
|
|
49
|
+
- `BITBUCKET_URL`: Your Bitbucket Server base URL
|
|
50
|
+
- `BITBUCKET_TOKEN`: Personal Access Token from Bitbucket Server
|
|
58
51
|
|
|
59
|
-
The
|
|
52
|
+
The library automatically adds the `Authorization: Bearer ${token}` header to all requests.
|
|
60
53
|
|
|
61
54
|
## Project Structure
|
|
62
55
|
|
|
@@ -65,157 +58,94 @@ src/
|
|
|
65
58
|
├── config.ts # Environment validation (BITBUCKET_URL, BITBUCKET_TOKEN)
|
|
66
59
|
├── index.ts # Main entry point, MCP server setup
|
|
67
60
|
├── services/
|
|
68
|
-
│ └── bitbucket.ts #
|
|
69
|
-
├── types/
|
|
70
|
-
│ ├── index.ts # Barrel export for all types
|
|
71
|
-
│ ├── common.ts # Shared types (PaginatedResponse)
|
|
72
|
-
│ ├── pull-request.ts # Pull request types (RestComment, RestPullRequest, etc.)
|
|
73
|
-
│ └── repository.ts # Repository-specific types
|
|
61
|
+
│ └── bitbucket.ts # BitbucketClient singleton (export const bitbucketService)
|
|
74
62
|
└── tools/
|
|
75
63
|
├── index.ts # Tool registration
|
|
76
64
|
├── users/
|
|
77
65
|
│ ├── index.ts # Barrel export
|
|
78
|
-
│ ├── get_user_profile.ts #
|
|
79
|
-
│ └── get_all_users.ts #
|
|
66
|
+
│ ├── get_user_profile.ts # User profile operations
|
|
67
|
+
│ └── get_all_users.ts # List all users
|
|
80
68
|
├── projects/
|
|
81
69
|
│ ├── index.ts # Barrel export
|
|
82
|
-
│ └── list_projects.ts #
|
|
70
|
+
│ └── list_projects.ts # List projects with filtering
|
|
83
71
|
├── repositories/
|
|
84
72
|
│ ├── index.ts # Barrel export
|
|
85
|
-
│ └── list_repositories.ts #
|
|
73
|
+
│ └── list_repositories.ts # List repositories in a project
|
|
86
74
|
└── pull-requests/
|
|
87
|
-
├── index.ts
|
|
88
|
-
├── get_inbox_pull_requests.ts
|
|
89
|
-
├──
|
|
90
|
-
├──
|
|
91
|
-
├──
|
|
92
|
-
├──
|
|
93
|
-
|
|
75
|
+
├── index.ts # Barrel export
|
|
76
|
+
├── get_inbox_pull_requests.ts # Get PRs in reviewer's inbox
|
|
77
|
+
├── get_pr_details.ts # Get full PR details
|
|
78
|
+
├── get_pr_diff.ts # Get PR diff (text or JSON)
|
|
79
|
+
├── add_pr_comment.ts # Add general/reply comment
|
|
80
|
+
├── add_pr_file_comment.ts # Add file-level comment
|
|
81
|
+
├── add_pr_line_comment.ts # Add line-specific comment
|
|
82
|
+
├── delete_pr_comment.ts # Delete comment
|
|
83
|
+
├── add_pr_comment_reaction.ts # Add emoticon reaction
|
|
84
|
+
├── remove_pr_comment_reaction.ts # Remove emoticon reaction
|
|
85
|
+
├── get_pr_changes.ts # Get changed files list
|
|
86
|
+
├── get_pr_file_diff.ts # Get structured file diff
|
|
87
|
+
├── get_pr_activities.ts # Get PR activities/comments
|
|
88
|
+
└── update_review_status.ts # Approve/request changes
|
|
94
89
|
```
|
|
95
90
|
|
|
96
91
|
## TypeScript Types
|
|
97
92
|
|
|
98
|
-
TypeScript
|
|
99
|
-
|
|
100
|
-
```
|
|
101
|
-
src/types/
|
|
102
|
-
├── index.ts # Barrel export (import from here)
|
|
103
|
-
├── common.ts # Shared types (PaginatedResponse)
|
|
104
|
-
├── pull-request.ts # Pull request types (RestComment, RestPullRequest, RestPullRequestParticipant, etc.)
|
|
105
|
-
└── repository.ts # Repository-specific types
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
### Type Naming Conventions
|
|
109
|
-
|
|
110
|
-
- **Match Swagger schema names exactly**: `RestRepository`, `RestProject`, `RestPullRequest`
|
|
111
|
-
- **Use interfaces for objects**: `interface RestRepository { ... }`
|
|
112
|
-
- **Use union types for enums**: `type RepositoryState = "AVAILABLE" | "OFFLINE"`
|
|
113
|
-
- **Generic wrapper types**: `PaginatedResponse<T>` for paginated endpoints
|
|
114
|
-
- **Response type aliases**: `RepositoriesResponse = PaginatedResponse<RestRepository>`
|
|
115
|
-
|
|
116
|
-
### Adding New Types
|
|
117
|
-
|
|
118
|
-
1. **Find the schema in Swagger**:
|
|
119
|
-
```bash
|
|
120
|
-
grep -n '"RestTypeName"' BitbucketServerSwagger.json
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
2. **Create/update type file** (e.g., `src/types/domain.ts`):
|
|
124
|
-
```typescript
|
|
125
|
-
// Focus on readonly properties (what API returns)
|
|
126
|
-
export interface RestTypeName {
|
|
127
|
-
id: number;
|
|
128
|
-
name: string;
|
|
129
|
-
// ... other fields
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export type DomainResponse = PaginatedResponse<RestTypeName>;
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
3. **Export from barrel file** (`src/types/index.ts`):
|
|
136
|
-
```typescript
|
|
137
|
-
export type { RestTypeName, DomainResponse } from "./domain.js";
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
4. **Use in tool**:
|
|
141
|
-
```typescript
|
|
142
|
-
import type { DomainResponse } from "../../types/index.js";
|
|
143
|
-
|
|
144
|
-
const response = await bitbucketClient.get<DomainResponse>("/endpoint");
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
### Type Design Principles
|
|
148
|
-
|
|
149
|
-
Following the project's simplicity philosophy:
|
|
150
|
-
|
|
151
|
-
**✅ DO:**
|
|
152
|
-
- Map types directly from Swagger schemas
|
|
153
|
-
- Focus on readonly properties (API responses)
|
|
154
|
-
- Keep types simple and minimal
|
|
155
|
-
- Use generic `PaginatedResponse<T>` for all paginated endpoints
|
|
156
|
-
|
|
157
|
-
**❌ DON'T:**
|
|
158
|
-
- Over-engineer with complex utility types
|
|
159
|
-
- Include writeOnly properties (used for requests)
|
|
160
|
-
- Add properties that aren't useful
|
|
161
|
-
- Create unnecessary type abstractions
|
|
162
|
-
|
|
163
|
-
## Tool Development Workflow
|
|
93
|
+
All TypeScript types are provided by the `bitbucket-data-center-client` library. You don't need to define or maintain types manually.
|
|
164
94
|
|
|
165
|
-
|
|
95
|
+
The library exports comprehensive types for:
|
|
96
|
+
- Users, projects, repositories
|
|
97
|
+
- Pull requests, comments, activities
|
|
98
|
+
- Diffs, changes, and review statuses
|
|
99
|
+
- Paginated responses
|
|
166
100
|
|
|
167
|
-
|
|
168
|
-
# Search for the endpoint
|
|
169
|
-
grep -n '"/api/latest/your-endpoint"' BitbucketServerSwagger.json
|
|
101
|
+
Simply import types from the library when needed:
|
|
170
102
|
|
|
171
|
-
|
|
172
|
-
|
|
103
|
+
```typescript
|
|
104
|
+
import type { RestPullRequest, RestComment } from 'bitbucket-data-center-client';
|
|
173
105
|
```
|
|
174
106
|
|
|
175
|
-
|
|
107
|
+
## Tool Development Workflow
|
|
176
108
|
|
|
177
|
-
|
|
178
|
-
- Path parameters (required in the URL)
|
|
179
|
-
- Query parameters (optional filters, pagination)
|
|
180
|
-
- Request body (for POST/PUT)
|
|
109
|
+
### 1. Check the Library Documentation
|
|
181
110
|
|
|
182
|
-
|
|
111
|
+
The `bitbucket-data-center-client` library provides all necessary methods. Check:
|
|
112
|
+
- Library README: https://github.com/evrimalacan/bitbucket-data-center-client
|
|
113
|
+
- Existing tools in `src/tools/` for examples
|
|
183
114
|
|
|
184
|
-
###
|
|
115
|
+
### 2. Implement the Tool
|
|
185
116
|
|
|
186
|
-
Follow this simple pattern:
|
|
117
|
+
Follow this simple pattern using the client library:
|
|
187
118
|
|
|
188
119
|
```typescript
|
|
189
120
|
import { z } from "zod";
|
|
190
121
|
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
191
|
-
import {
|
|
192
|
-
import type { YourResponseType } from "../../types/index.js";
|
|
122
|
+
import { bitbucketService } from "../../services/bitbucket.js";
|
|
193
123
|
|
|
194
124
|
const schema = z.object({
|
|
195
|
-
requiredParam: z.string().describe("Description
|
|
125
|
+
requiredParam: z.string().describe("Description of parameter"),
|
|
196
126
|
optionalParam: z.string().optional().describe("Optional parameter"),
|
|
197
127
|
});
|
|
198
128
|
|
|
199
129
|
export const toolNameTool = (server: McpServer) => {
|
|
200
130
|
server.registerTool(
|
|
201
|
-
"
|
|
131
|
+
"tool_name",
|
|
202
132
|
{
|
|
203
133
|
title: "Human Readable Title",
|
|
204
|
-
description: "
|
|
134
|
+
description: "Clear description of what this tool does",
|
|
205
135
|
inputSchema: schema.shape,
|
|
206
136
|
},
|
|
207
|
-
async (
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
137
|
+
async ({ requiredParam, optionalParam }) => {
|
|
138
|
+
// Call the appropriate library method
|
|
139
|
+
const result = await bitbucketService.someMethod({
|
|
140
|
+
requiredParam,
|
|
141
|
+
optionalParam,
|
|
212
142
|
});
|
|
213
143
|
|
|
214
144
|
return {
|
|
215
145
|
content: [
|
|
216
146
|
{
|
|
217
147
|
type: "text",
|
|
218
|
-
text: JSON.stringify(
|
|
148
|
+
text: JSON.stringify(result, null, 2),
|
|
219
149
|
},
|
|
220
150
|
],
|
|
221
151
|
};
|
|
@@ -224,7 +154,7 @@ export const toolNameTool = (server: McpServer) => {
|
|
|
224
154
|
};
|
|
225
155
|
```
|
|
226
156
|
|
|
227
|
-
###
|
|
157
|
+
### 3. Register the Tool
|
|
228
158
|
|
|
229
159
|
```typescript
|
|
230
160
|
// 1. Export from domain barrel file (e.g., src/tools/users/index.ts)
|
|
@@ -239,7 +169,7 @@ export function registerTools(server: McpServer) {
|
|
|
239
169
|
}
|
|
240
170
|
```
|
|
241
171
|
|
|
242
|
-
###
|
|
172
|
+
### 4. Run the Linter
|
|
243
173
|
|
|
244
174
|
Always run the linter after implementing a new tool:
|
|
245
175
|
|
|
@@ -254,48 +184,51 @@ The linter will auto-fix formatting, catch unused variables, and ensure code qua
|
|
|
254
184
|
### Keep It Simple
|
|
255
185
|
|
|
256
186
|
**✅ DO:**
|
|
257
|
-
- Use
|
|
258
|
-
- Minimal error handling (
|
|
187
|
+
- Use `bitbucketService` client methods: `bitbucketService.getUserProfile(...)`
|
|
188
|
+
- Minimal error handling (let errors bubble up)
|
|
259
189
|
- Short, focused functions
|
|
260
190
|
- Clear parameter names
|
|
191
|
+
- Destructure parameters directly in async handler
|
|
261
192
|
|
|
262
193
|
**❌ DON'T:**
|
|
263
|
-
- Add wrapper
|
|
194
|
+
- Add wrapper functions around the library
|
|
264
195
|
- Over-engineer error handling
|
|
265
196
|
- Add unnecessary abstractions
|
|
266
|
-
- Use try-catch unless required
|
|
197
|
+
- Use try-catch unless absolutely required
|
|
267
198
|
|
|
268
199
|
### Example: Simple Tool
|
|
269
200
|
|
|
270
201
|
```typescript
|
|
271
|
-
// ✅ Good - simple and direct
|
|
272
|
-
export const
|
|
273
|
-
server.registerTool(
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
202
|
+
// ✅ Good - simple and direct using the library
|
|
203
|
+
export const getUserProfileTool = (server: McpServer) => {
|
|
204
|
+
server.registerTool(
|
|
205
|
+
"get_user_profile",
|
|
206
|
+
{
|
|
207
|
+
title: "Get Bitbucket User Profile",
|
|
208
|
+
description: "Gets Bitbucket Server user profile details by username",
|
|
209
|
+
inputSchema: schema.shape,
|
|
210
|
+
},
|
|
211
|
+
async ({ username }) => {
|
|
212
|
+
const user = await bitbucketService.getUserProfile({ username });
|
|
213
|
+
|
|
214
|
+
return {
|
|
215
|
+
content: [{ type: "text", text: JSON.stringify(user, null, 2) }],
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
);
|
|
284
219
|
};
|
|
285
220
|
```
|
|
286
221
|
|
|
287
222
|
```typescript
|
|
288
223
|
// ❌ Bad - over-engineered
|
|
289
|
-
export const
|
|
290
|
-
server.registerTool("
|
|
224
|
+
export const getUserProfileTool = (server: McpServer) => {
|
|
225
|
+
server.registerTool("bitbucket_get_user_profile", { ... }, async (params) => {
|
|
291
226
|
try {
|
|
292
|
-
const
|
|
293
|
-
|
|
294
|
-
const
|
|
295
|
-
const client = getClient(); // Unnecessary wrapper
|
|
296
|
-
const response = await client.get("/users", queryParams);
|
|
227
|
+
const validated = validateParams(params); // Unnecessary - zod handles this
|
|
228
|
+
const client = getClient(); // Unnecessary - use bitbucketService directly
|
|
229
|
+
const response = await client.getUser(validated.username);
|
|
297
230
|
|
|
298
|
-
return
|
|
231
|
+
return formatResponse(response); // Over-abstracted
|
|
299
232
|
} catch (error) {
|
|
300
233
|
return handleError(error); // Let errors bubble
|
|
301
234
|
}
|
|
@@ -305,19 +238,19 @@ export const getAllUsersTool = (server: McpServer) => {
|
|
|
305
238
|
|
|
306
239
|
## Current Tools
|
|
307
240
|
|
|
308
|
-
###
|
|
241
|
+
### get_user_profile
|
|
309
242
|
**File**: `src/tools/users/get_user_profile.ts`
|
|
310
243
|
**Endpoint**: `GET /users/{username}`
|
|
311
244
|
**Parameters**:
|
|
312
245
|
- `username` (required): The username/slug of the Bitbucket Server user
|
|
313
246
|
|
|
314
|
-
###
|
|
247
|
+
### get_all_users
|
|
315
248
|
**File**: `src/tools/users/get_all_users.ts`
|
|
316
249
|
**Endpoint**: `GET /users`
|
|
317
250
|
**Parameters**:
|
|
318
251
|
- `filter` (optional): Filter users by username, name or email (partial match)
|
|
319
252
|
|
|
320
|
-
###
|
|
253
|
+
### list_projects
|
|
321
254
|
**File**: `src/tools/projects/list_projects.ts`
|
|
322
255
|
**Endpoint**: `GET /projects`
|
|
323
256
|
**Parameters**:
|
|
@@ -330,7 +263,7 @@ export const getAllUsersTool = (server: McpServer) => {
|
|
|
330
263
|
|
|
331
264
|
**Purpose**: Discover available projects that the authenticated user has access to. Use the project key from this response to list repositories in specific projects.
|
|
332
265
|
|
|
333
|
-
###
|
|
266
|
+
### list_repositories
|
|
334
267
|
**File**: `src/tools/repositories/list_repositories.ts`
|
|
335
268
|
**Endpoint**: `GET /projects/{projectKey}/repos`
|
|
336
269
|
**Parameters**:
|
|
@@ -338,7 +271,7 @@ export const getAllUsersTool = (server: McpServer) => {
|
|
|
338
271
|
|
|
339
272
|
**Note**: According to Swagger, this endpoint does NOT support `name` or `permission` query parameters. Only pagination (`start`, `limit`) is supported.
|
|
340
273
|
|
|
341
|
-
###
|
|
274
|
+
### get_inbox_pull_requests
|
|
342
275
|
**File**: `src/tools/pull-requests/get_inbox_pull_requests.ts`
|
|
343
276
|
**Endpoint**: `GET /inbox/pull-requests`
|
|
344
277
|
**Parameters**:
|
|
@@ -364,7 +297,29 @@ export const getAllUsersTool = (server: McpServer) => {
|
|
|
364
297
|
|
|
365
298
|
**Purpose**: Discover all PRs across all projects and repositories that need your review in one call. Much more efficient than querying project by project. Use the `id`, `projectKey`, and `repositorySlug` from the response to review specific PRs with other tools.
|
|
366
299
|
|
|
367
|
-
###
|
|
300
|
+
### create_pull_request
|
|
301
|
+
**File**: `src/tools/pull-requests/create_pull_request.ts`
|
|
302
|
+
**Endpoint**: `POST /projects/{projectKey}/repos/{repositorySlug}/pull-requests`
|
|
303
|
+
**Parameters**:
|
|
304
|
+
- `projectKey` (required): The Bitbucket Server project key
|
|
305
|
+
- `repositorySlug` (required): The repository slug
|
|
306
|
+
- `fromBranch` (required): Source branch name (e.g., "feature-x")
|
|
307
|
+
- `toBranch` (required): Target branch name (e.g., "main")
|
|
308
|
+
- `title` (required): PR title
|
|
309
|
+
- `description` (optional): PR description in markdown format
|
|
310
|
+
- `reviewers` (optional): Array of reviewer usernames to add
|
|
311
|
+
|
|
312
|
+
**Returns**: Created pull request object including `id`, `title`, `state`, `fromRef`, `toRef`, `author`, and web URL.
|
|
313
|
+
|
|
314
|
+
**Purpose**: Create a new pull request from a source branch to a target branch. Accepts simple branch names - they are automatically converted to full refs (e.g., "main" → "refs/heads/main").
|
|
315
|
+
|
|
316
|
+
**Error Cases**:
|
|
317
|
+
- 400: Malformed request
|
|
318
|
+
- 401: Insufficient permissions
|
|
319
|
+
- 404: Repository or branches don't exist
|
|
320
|
+
- 409: Branches are the same, PR already exists, or target repo is archived
|
|
321
|
+
|
|
322
|
+
### get_pull_request
|
|
368
323
|
**File**: `src/tools/pull-requests/get_pr_details.ts`
|
|
369
324
|
**Endpoint**: `GET /projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}`
|
|
370
325
|
**Parameters**:
|
|
@@ -384,7 +339,7 @@ export const getAllUsersTool = (server: McpServer) => {
|
|
|
384
339
|
|
|
385
340
|
**Purpose**: Get comprehensive metadata for a pull request. Use this when you need full PR details including source/destination branches, author information, and reviewers. Essential for tools that need to understand PR context before performing operations.
|
|
386
341
|
|
|
387
|
-
###
|
|
342
|
+
### get_pull_request_diff
|
|
388
343
|
**File**: `src/tools/pull-requests/get_pr_diff.ts`
|
|
389
344
|
**Endpoint**: `GET /projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/diff/{path}`
|
|
390
345
|
**Parameters**:
|
|
@@ -404,7 +359,7 @@ export const getAllUsersTool = (server: McpServer) => {
|
|
|
404
359
|
|
|
405
360
|
**Purpose**: Get the complete diff for a PR in one call (when `path` is omitted) or for a specific file. The format parameter controls the response type based on the Accept header. Use `format='text'` (default) for raw text suitable for parsing or display - the background-greg service uses this for generating PR review contexts. Use `format='json'` when you need structured data with exact line numbers and segments.
|
|
406
361
|
|
|
407
|
-
###
|
|
362
|
+
### add_pr_comment
|
|
408
363
|
**File**: `src/tools/pull-requests/add_pr_comment.ts`
|
|
409
364
|
**Endpoint**: `POST /projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/comments`
|
|
410
365
|
**Parameters**:
|
|
@@ -418,7 +373,7 @@ export const getAllUsersTool = (server: McpServer) => {
|
|
|
418
373
|
|
|
419
374
|
**Returns**: Simple success message with comment ID.
|
|
420
375
|
|
|
421
|
-
###
|
|
376
|
+
### add_pr_file_comment
|
|
422
377
|
**File**: `src/tools/pull-requests/add_pr_file_comment.ts`
|
|
423
378
|
**Endpoint**: `POST /projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/comments`
|
|
424
379
|
**Parameters**:
|
|
@@ -428,11 +383,11 @@ export const getAllUsersTool = (server: McpServer) => {
|
|
|
428
383
|
- `text` (required): The comment text
|
|
429
384
|
- `path` (required): File path to attach the comment to (e.g., "src/main.ts")
|
|
430
385
|
|
|
431
|
-
**Purpose**: Add a comment attached to a specific file in the PR (file-level comment, not line-specific). The comment will appear at the file level in the PR diff view. For replies to existing comments, use
|
|
386
|
+
**Purpose**: Add a comment attached to a specific file in the PR (file-level comment, not line-specific). The comment will appear at the file level in the PR diff view. For replies to existing comments, use add_pr_comment with parentId.
|
|
432
387
|
|
|
433
388
|
**Returns**: Simple success message with comment ID.
|
|
434
389
|
|
|
435
|
-
###
|
|
390
|
+
### add_pr_line_comment
|
|
436
391
|
**File**: `src/tools/pull-requests/add_pr_line_comment.ts`
|
|
437
392
|
**Endpoint**: `POST /projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/comments`
|
|
438
393
|
**Parameters**:
|
|
@@ -445,11 +400,11 @@ export const getAllUsersTool = (server: McpServer) => {
|
|
|
445
400
|
- `lineType` (required): Type of line - "ADDED" (green +), "REMOVED" (red -), or "CONTEXT" (unchanged)
|
|
446
401
|
- `fileType` (required): Side of diff - "FROM" (source/old) or "TO" (destination/new)
|
|
447
402
|
|
|
448
|
-
**Purpose**: Add an inline comment to a specific line in the PR diff. Use line numbers from `
|
|
403
|
+
**Purpose**: Add an inline comment to a specific line in the PR diff. Use line numbers from `get_pull_request_file_diff` (destination line for TO side, source line for FROM side). Match the `lineType` to the segment type from the diff. For replies to existing comments, use add_pr_comment with parentId.
|
|
449
404
|
|
|
450
405
|
**Returns**: Simple success message with comment ID.
|
|
451
406
|
|
|
452
|
-
###
|
|
407
|
+
### get_pull_request_changes
|
|
453
408
|
**File**: `src/tools/pull-requests/get_pr_changes.ts`
|
|
454
409
|
**Endpoint**: `GET /projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/changes`
|
|
455
410
|
**Parameters**:
|
|
@@ -462,7 +417,7 @@ export const getAllUsersTool = (server: McpServer) => {
|
|
|
462
417
|
|
|
463
418
|
**Purpose**: Get an overview of all files changed in a PR. Use this as the first step before fetching detailed diffs. Always returns all changes with comment counts included.
|
|
464
419
|
|
|
465
|
-
###
|
|
420
|
+
### get_pull_request_file_diff
|
|
466
421
|
**File**: `src/tools/pull-requests/get_pr_file_diff.ts`
|
|
467
422
|
**Endpoint**: `GET /projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/diff/{path}`
|
|
468
423
|
**Parameters**:
|
|
@@ -474,9 +429,9 @@ export const getAllUsersTool = (server: McpServer) => {
|
|
|
474
429
|
|
|
475
430
|
**Returns**: Structured JSON with hunks, segments, and exact line numbers for each change. Each line includes `source` (FROM line number) and `destination` (TO line number) fields. Existing comments are embedded in the diff. Whitespace changes are always included.
|
|
476
431
|
|
|
477
|
-
**Purpose**: Get line-by-line diff data for commenting on specific lines. Use the line numbers from this response when calling `
|
|
432
|
+
**Purpose**: Get line-by-line diff data for commenting on specific lines. Use the line numbers from this response when calling `add_pr_comment`.
|
|
478
433
|
|
|
479
|
-
###
|
|
434
|
+
### get_pull_request_activities
|
|
480
435
|
**File**: `src/tools/pull-requests/get_pr_activities.ts`
|
|
481
436
|
**Endpoint**: `GET /projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/activities`
|
|
482
437
|
**Parameters**:
|
|
@@ -511,14 +466,14 @@ export const getAllUsersTool = (server: McpServer) => {
|
|
|
511
466
|
- Get all activity: Omit `activityTypes` parameter
|
|
512
467
|
|
|
513
468
|
**Token Optimization**: Response is automatically optimized to reduce token usage by ~50%:
|
|
514
|
-
- Removes `diff` field (use `commentAnchor.path` with `
|
|
469
|
+
- Removes `diff` field (use `commentAnchor.path` with `get_pull_request_file_diff` to fetch code context on demand)
|
|
515
470
|
- Removes `user.links` from all user objects
|
|
516
471
|
- Removes `comment.permittedOperations`
|
|
517
472
|
- Simplifies `reactions` and `likedBy` to counts only
|
|
518
473
|
|
|
519
474
|
**Purpose**: Get an overview of PR activity. Can filter to specific types (e.g., only comments) to reduce response size. Each comment activity includes full comment text, author, and creation date. For inline comments, use `commentAnchor` (path, line, lineType, fileType) to fetch the relevant diff separately.
|
|
520
475
|
|
|
521
|
-
###
|
|
476
|
+
### update_review_status
|
|
522
477
|
**File**: `src/tools/pull-requests/update_review_status.ts`
|
|
523
478
|
**Endpoint**: `PUT /projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/participants/{userSlug}`
|
|
524
479
|
**Parameters**:
|
|
@@ -541,7 +496,7 @@ export const getAllUsersTool = (server: McpServer) => {
|
|
|
541
496
|
|
|
542
497
|
**Note**: The tool makes a lightweight request to `/application-properties` to extract the authenticated username from the `X-AUSERNAME` response header, eliminating the need for users to provide their own slug.
|
|
543
498
|
|
|
544
|
-
###
|
|
499
|
+
### delete_pr_comment
|
|
545
500
|
**File**: `src/tools/pull-requests/delete_pr_comment.ts`
|
|
546
501
|
**Endpoint**: `DELETE /projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/comments/{commentId}`
|
|
547
502
|
**Parameters**:
|
|
@@ -560,7 +515,7 @@ export const getAllUsersTool = (server: McpServer) => {
|
|
|
560
515
|
- Others' comments: Requires REPO_ADMIN permission
|
|
561
516
|
- Comments with replies: Cannot be deleted (will return error)
|
|
562
517
|
|
|
563
|
-
###
|
|
518
|
+
### add_pr_comment_reaction
|
|
564
519
|
**File**: `src/tools/pull-requests/add_pr_comment_reaction.ts`
|
|
565
520
|
**Endpoint**: `PUT /comment-likes/latest/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/comments/{commentId}/reactions/{emoticon}`
|
|
566
521
|
**Parameters**:
|
|
@@ -583,7 +538,7 @@ export const getAllUsersTool = (server: McpServer) => {
|
|
|
583
538
|
|
|
584
539
|
**Note**: Uses the Bitbucket Server comment-likes plugin API (`/rest/comment-likes/latest/`), not the core API.
|
|
585
540
|
|
|
586
|
-
###
|
|
541
|
+
### remove_pr_comment_reaction
|
|
587
542
|
**File**: `src/tools/pull-requests/remove_pr_comment_reaction.ts`
|
|
588
543
|
**Endpoint**: `DELETE /comment-likes/latest/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/comments/{commentId}/reactions/{emoticon}`
|
|
589
544
|
**Parameters**:
|
|
@@ -597,7 +552,7 @@ export const getAllUsersTool = (server: McpServer) => {
|
|
|
597
552
|
|
|
598
553
|
**Purpose**: Remove an emoticon reaction from a pull request comment. Only the user who added the reaction can remove it. If the reaction doesn't exist, the operation still succeeds (idempotent).
|
|
599
554
|
|
|
600
|
-
**Supported Emoticons**: Same as `
|
|
555
|
+
**Supported Emoticons**: Same as `add_pr_comment_reaction`
|
|
601
556
|
|
|
602
557
|
**Note**: Uses the Bitbucket Server comment-likes plugin API (`/rest/comment-likes/latest/`), not the core API.
|
|
603
558
|
|
|
@@ -607,7 +562,7 @@ For agents reviewing PRs and leaving comments on specific lines:
|
|
|
607
562
|
|
|
608
563
|
0. **Discover PRs to review**:
|
|
609
564
|
```
|
|
610
|
-
|
|
565
|
+
get_inbox_pull_requests()
|
|
611
566
|
→ Returns PRs across all projects: [{id, title, description, state, author, projectKey, repositorySlug, ...}, ...]
|
|
612
567
|
```
|
|
613
568
|
Use `id`, `projectKey`, and `repositorySlug` from each PR for the following steps.
|
|
@@ -615,10 +570,10 @@ For agents reviewing PRs and leaving comments on specific lines:
|
|
|
615
570
|
1. **[Optional] Get activity overview or comments**:
|
|
616
571
|
```
|
|
617
572
|
# Get all activity
|
|
618
|
-
|
|
573
|
+
get_pull_request_activities(projectKey, repositorySlug, pullRequestId)
|
|
619
574
|
|
|
620
575
|
# Or get only comments (smaller response)
|
|
621
|
-
|
|
576
|
+
get_pull_request_activities(projectKey, repositorySlug, pullRequestId,
|
|
622
577
|
activityTypes=["COMMENTED", "REVIEW_COMMENTED"])
|
|
623
578
|
→ Returns filtered activities: [{action: "COMMENTED", comment: {text, author, ...}, ...}, ...]
|
|
624
579
|
```
|
|
@@ -626,19 +581,19 @@ For agents reviewing PRs and leaving comments on specific lines:
|
|
|
626
581
|
|
|
627
582
|
2. **Get all changed files**:
|
|
628
583
|
```
|
|
629
|
-
|
|
584
|
+
get_pull_request_changes(projectKey, repositorySlug, pullRequestId)
|
|
630
585
|
→ Returns list of files: [{path, type: "MODIFY", ...}, ...]
|
|
631
586
|
```
|
|
632
587
|
|
|
633
588
|
3. **For each file of interest, get structured diff**:
|
|
634
589
|
```
|
|
635
|
-
|
|
590
|
+
get_pull_request_file_diff(projectKey, repositorySlug, pullRequestId, path="src/main.ts")
|
|
636
591
|
→ Returns: {hunks: [{segments: [{type: "ADDED", lines: [{source: 42, destination: 43, line: "code"}]}]}]}
|
|
637
592
|
```
|
|
638
593
|
|
|
639
594
|
4. **Comment on specific lines**:
|
|
640
595
|
```
|
|
641
|
-
|
|
596
|
+
add_pr_line_comment(
|
|
642
597
|
projectKey, repositorySlug, pullRequestId,
|
|
643
598
|
text="Consider using const here",
|
|
644
599
|
path="src/main.ts",
|
|
@@ -651,13 +606,13 @@ For agents reviewing PRs and leaving comments on specific lines:
|
|
|
651
606
|
5. **Update review status**:
|
|
652
607
|
```
|
|
653
608
|
# Approve the PR
|
|
654
|
-
|
|
609
|
+
update_review_status(
|
|
655
610
|
projectKey, repositorySlug, pullRequestId,
|
|
656
611
|
status="APPROVED"
|
|
657
612
|
)
|
|
658
613
|
|
|
659
614
|
# Or request changes
|
|
660
|
-
|
|
615
|
+
update_review_status(
|
|
661
616
|
projectKey, repositorySlug, pullRequestId,
|
|
662
617
|
status="NEEDS_WORK"
|
|
663
618
|
)
|
|
@@ -709,42 +664,28 @@ See `.env.example` for template.
|
|
|
709
664
|
|
|
710
665
|
### Pagination
|
|
711
666
|
|
|
712
|
-
|
|
667
|
+
The `bitbucket-data-center-client` library handles pagination automatically. Just pass the pagination parameters:
|
|
713
668
|
|
|
714
669
|
```typescript
|
|
715
|
-
const
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
limit: 25,
|
|
719
|
-
},
|
|
670
|
+
const result = await bitbucketService.listProjects({
|
|
671
|
+
start: 0,
|
|
672
|
+
limit: 25,
|
|
720
673
|
});
|
|
721
674
|
```
|
|
722
675
|
|
|
723
|
-
|
|
676
|
+
Paginated responses include:
|
|
724
677
|
- `values`: Array of results
|
|
725
678
|
- `size`: Number of results in this page
|
|
726
679
|
- `limit`: Page size
|
|
727
680
|
- `isLastPage`: Boolean
|
|
728
681
|
- `nextPageStart`: Start value for next page
|
|
729
682
|
|
|
730
|
-
### Error
|
|
683
|
+
### Error Handling
|
|
731
684
|
|
|
732
|
-
Bitbucket Server
|
|
733
|
-
|
|
734
|
-
```json
|
|
735
|
-
{
|
|
736
|
-
"errors": [
|
|
737
|
-
{
|
|
738
|
-
"context": "field_name",
|
|
739
|
-
"message": "Error description",
|
|
740
|
-
"exceptionName": "ExceptionType"
|
|
741
|
-
}
|
|
742
|
-
]
|
|
743
|
-
}
|
|
744
|
-
```
|
|
685
|
+
The library throws errors with Bitbucket Server's error format. Let them bubble up - the MCP SDK will handle them appropriately.
|
|
745
686
|
|
|
746
687
|
## Resources
|
|
747
688
|
|
|
748
|
-
- **
|
|
749
|
-
- **
|
|
750
|
-
- **
|
|
689
|
+
- **Library Documentation**: https://github.com/evrimalacan/bitbucket-data-center-client
|
|
690
|
+
- **Swagger Documentation**: `BitbucketServerSwagger.json` in project root (for reference)
|
|
691
|
+
- **Bitbucket Server REST API Docs**: Available via Bitbucket Server UI (triple dot menu)
|