mcp-bitbucket-server 1.0.0 → 1.1.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 +131 -3
- 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.d.ts +1 -1
- package/dist/tools/projects/list_projects.d.ts.map +1 -1
- package/dist/tools/projects/list_projects.js +13 -39
- package/dist/tools/projects/list_projects.js.map +1 -1
- package/dist/tools/pull-requests/add_pr_comment.d.ts.map +1 -1
- package/dist/tools/pull-requests/add_pr_comment.js +1 -2
- package/dist/tools/pull-requests/add_pr_comment.js.map +1 -1
- package/dist/tools/pull-requests/get_inbox_pull_requests.d.ts +1 -1
- package/dist/tools/pull-requests/get_inbox_pull_requests.d.ts.map +1 -1
- package/dist/tools/pull-requests/get_inbox_pull_requests.js +12 -26
- package/dist/tools/pull-requests/get_inbox_pull_requests.js.map +1 -1
- package/dist/tools/pull-requests/get_pr_activities.d.ts +1 -1
- package/dist/tools/pull-requests/get_pr_activities.d.ts.map +1 -1
- package/dist/tools/pull-requests/get_pr_activities.js +55 -80
- package/dist/tools/pull-requests/get_pr_activities.js.map +1 -1
- package/dist/tools/pull-requests/get_pr_changes.d.ts +1 -1
- package/dist/tools/pull-requests/get_pr_changes.d.ts.map +1 -1
- package/dist/tools/pull-requests/get_pr_changes.js +12 -22
- package/dist/tools/pull-requests/get_pr_changes.js.map +1 -1
- package/dist/tools/pull-requests/get_pr_file_diff.d.ts +1 -1
- package/dist/tools/pull-requests/get_pr_file_diff.d.ts.map +1 -1
- package/dist/tools/pull-requests/get_pr_file_diff.js +12 -22
- package/dist/tools/pull-requests/get_pr_file_diff.js.map +1 -1
- package/dist/tools/pull-requests/index.d.ts +3 -2
- package/dist/tools/pull-requests/index.d.ts.map +1 -1
- package/dist/tools/pull-requests/index.js +3 -2
- package/dist/tools/pull-requests/index.js.map +1 -1
- package/dist/tools/pull-requests/update_review_status.d.ts +3 -0
- package/dist/tools/pull-requests/update_review_status.d.ts.map +1 -0
- package/dist/tools/pull-requests/update_review_status.js +35 -0
- package/dist/tools/pull-requests/update_review_status.js.map +1 -0
- package/dist/tools/repositories/list_repositories.d.ts.map +1 -1
- package/dist/tools/repositories/list_repositories.js +1 -5
- package/dist/tools/repositories/list_repositories.js.map +1 -1
- package/dist/tools/users/get_all_users.d.ts.map +1 -1
- package/dist/tools/users/get_all_users.js +1 -2
- package/dist/tools/users/get_all_users.js.map +1 -1
- package/dist/tools/users/get_user_profile.d.ts.map +1 -1
- package/dist/tools/users/get_user_profile.js +10 -26
- package/dist/tools/users/get_user_profile.js.map +1 -1
- package/dist/types/common.d.ts +19 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/common.js +2 -0
- package/dist/types/common.js.map +1 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +11 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/pull-request.d.ts +488 -0
- package/dist/types/pull-request.d.ts.map +1 -0
- package/dist/types/pull-request.js +2 -0
- package/dist/types/pull-request.js.map +1 -0
- package/dist/types/repository.d.ts +70 -0
- package/dist/types/repository.d.ts.map +1 -0
- package/dist/types/repository.js +2 -0
- package/dist/types/repository.js.map +1 -0
- package/package.json +1 -1
package/CLAUDE.md
CHANGED
|
@@ -7,7 +7,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
|
|
7
7
|
This is an MCP (Model Context Protocol) server for Bitbucket Server/Data Center integration. The server provides tools for:
|
|
8
8
|
- **User management**: Get user profile, list all users
|
|
9
9
|
- **Repository operations**: List repositories in a project
|
|
10
|
-
- **Pull request operations**: Get changed files, get structured diffs, add comments (general, replies, and inline)
|
|
10
|
+
- **Pull request operations**: Get changed files, get structured diffs, add comments (general, replies, and inline), update review status (approve/request changes)
|
|
11
11
|
|
|
12
12
|
## Architecture
|
|
13
13
|
|
|
@@ -65,6 +65,11 @@ src/
|
|
|
65
65
|
├── index.ts # Main entry point, MCP server setup
|
|
66
66
|
├── services/
|
|
67
67
|
│ └── bitbucket.ts # Axios client instance (export const bitbucketClient)
|
|
68
|
+
├── types/
|
|
69
|
+
│ ├── index.ts # Barrel export for all types
|
|
70
|
+
│ ├── common.ts # Shared types (PaginatedResponse)
|
|
71
|
+
│ ├── pull-request.ts # Pull request types (RestComment, RestPullRequest, etc.)
|
|
72
|
+
│ └── repository.ts # Repository-specific types
|
|
68
73
|
└── tools/
|
|
69
74
|
├── index.ts # Tool registration
|
|
70
75
|
├── users/
|
|
@@ -83,9 +88,77 @@ src/
|
|
|
83
88
|
├── add_pr_comment.ts # POST /projects/.../pull-requests/.../comments
|
|
84
89
|
├── get_pr_changes.ts # GET /projects/.../pull-requests/.../changes
|
|
85
90
|
├── get_pr_file_diff.ts # GET /projects/.../pull-requests/.../diff/{path}
|
|
86
|
-
|
|
91
|
+
├── get_pr_activities.ts # GET /projects/.../pull-requests/.../activities
|
|
92
|
+
└── update_review_status.ts # PUT /projects/.../pull-requests/.../participants/{userSlug}
|
|
87
93
|
```
|
|
88
94
|
|
|
95
|
+
## TypeScript Types
|
|
96
|
+
|
|
97
|
+
TypeScript type definitions for Bitbucket Server API responses are located in `src/types/`:
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
src/types/
|
|
101
|
+
├── index.ts # Barrel export (import from here)
|
|
102
|
+
├── common.ts # Shared types (PaginatedResponse)
|
|
103
|
+
├── pull-request.ts # Pull request types (RestComment, RestPullRequest, RestPullRequestParticipant, etc.)
|
|
104
|
+
└── repository.ts # Repository-specific types
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Type Naming Conventions
|
|
108
|
+
|
|
109
|
+
- **Match Swagger schema names exactly**: `RestRepository`, `RestProject`, `RestPullRequest`
|
|
110
|
+
- **Use interfaces for objects**: `interface RestRepository { ... }`
|
|
111
|
+
- **Use union types for enums**: `type RepositoryState = "AVAILABLE" | "OFFLINE"`
|
|
112
|
+
- **Generic wrapper types**: `PaginatedResponse<T>` for paginated endpoints
|
|
113
|
+
- **Response type aliases**: `RepositoriesResponse = PaginatedResponse<RestRepository>`
|
|
114
|
+
|
|
115
|
+
### Adding New Types
|
|
116
|
+
|
|
117
|
+
1. **Find the schema in Swagger**:
|
|
118
|
+
```bash
|
|
119
|
+
grep -n '"RestTypeName"' BitbucketServerSwagger.json
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
2. **Create/update type file** (e.g., `src/types/domain.ts`):
|
|
123
|
+
```typescript
|
|
124
|
+
// Focus on readonly properties (what API returns)
|
|
125
|
+
export interface RestTypeName {
|
|
126
|
+
id: number;
|
|
127
|
+
name: string;
|
|
128
|
+
// ... other fields
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export type DomainResponse = PaginatedResponse<RestTypeName>;
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
3. **Export from barrel file** (`src/types/index.ts`):
|
|
135
|
+
```typescript
|
|
136
|
+
export type { RestTypeName, DomainResponse } from "./domain.js";
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
4. **Use in tool**:
|
|
140
|
+
```typescript
|
|
141
|
+
import type { DomainResponse } from "../../types/index.js";
|
|
142
|
+
|
|
143
|
+
const response = await bitbucketClient.get<DomainResponse>("/endpoint");
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Type Design Principles
|
|
147
|
+
|
|
148
|
+
Following the project's simplicity philosophy:
|
|
149
|
+
|
|
150
|
+
**✅ DO:**
|
|
151
|
+
- Map types directly from Swagger schemas
|
|
152
|
+
- Focus on readonly properties (API responses)
|
|
153
|
+
- Keep types simple and minimal
|
|
154
|
+
- Use generic `PaginatedResponse<T>` for all paginated endpoints
|
|
155
|
+
|
|
156
|
+
**❌ DON'T:**
|
|
157
|
+
- Over-engineer with complex utility types
|
|
158
|
+
- Include writeOnly properties (used for requests)
|
|
159
|
+
- Add properties that aren't useful
|
|
160
|
+
- Create unnecessary type abstractions
|
|
161
|
+
|
|
89
162
|
## Tool Development Workflow
|
|
90
163
|
|
|
91
164
|
### 1. Find the Endpoint in Swagger
|
|
@@ -115,6 +188,7 @@ Follow this simple pattern:
|
|
|
115
188
|
import { z } from "zod";
|
|
116
189
|
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
117
190
|
import { bitbucketClient } from "../../services/bitbucket.js";
|
|
191
|
+
import type { YourResponseType } from "../../types/index.js";
|
|
118
192
|
|
|
119
193
|
const schema = z.object({
|
|
120
194
|
requiredParam: z.string().describe("Description from Swagger"),
|
|
@@ -132,7 +206,7 @@ export const toolNameTool = (server: McpServer) => {
|
|
|
132
206
|
async (params) => {
|
|
133
207
|
const { requiredParam, optionalParam } = schema.parse(params);
|
|
134
208
|
|
|
135
|
-
const response = await bitbucketClient.get("/endpoint", {
|
|
209
|
+
const response = await bitbucketClient.get<YourResponseType>("/endpoint", {
|
|
136
210
|
params: optionalParam ? { optionalParam } : {},
|
|
137
211
|
});
|
|
138
212
|
|
|
@@ -164,6 +238,16 @@ export function registerTools(server: McpServer) {
|
|
|
164
238
|
}
|
|
165
239
|
```
|
|
166
240
|
|
|
241
|
+
### 5. Run the Linter
|
|
242
|
+
|
|
243
|
+
Always run the linter after implementing a new tool:
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
npm run lint
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
The linter will auto-fix formatting, catch unused variables, and ensure code quality. Fix any warnings before committing.
|
|
250
|
+
|
|
167
251
|
## Code Style Guidelines
|
|
168
252
|
|
|
169
253
|
### Keep It Simple
|
|
@@ -364,6 +448,29 @@ export const getAllUsersTool = (server: McpServer) => {
|
|
|
364
448
|
|
|
365
449
|
**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.
|
|
366
450
|
|
|
451
|
+
### bitbucket_update_review_status
|
|
452
|
+
**File**: `src/tools/pull-requests/update_review_status.ts`
|
|
453
|
+
**Endpoint**: `PUT /projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/participants/{userSlug}`
|
|
454
|
+
**Parameters**:
|
|
455
|
+
- `projectKey` (required): The Bitbucket Server project key
|
|
456
|
+
- `repositorySlug` (required): The repository slug
|
|
457
|
+
- `pullRequestId` (required): The pull request ID
|
|
458
|
+
- `status` (required): Review status - `APPROVED`, `NEEDS_WORK`, or `UNAPPROVED`
|
|
459
|
+
|
|
460
|
+
**Auto-detected**:
|
|
461
|
+
- `userSlug`: Automatically detected from the authenticated user via `X-AUSERNAME` response header
|
|
462
|
+
|
|
463
|
+
**Returns**: Updated participant object with review status, role, and lastReviewedCommit.
|
|
464
|
+
|
|
465
|
+
**Purpose**: Change the authenticated user's review status for a PR. Automatically adds the user as a participant/reviewer if not already. The API automatically updates `lastReviewedCommit` to the latest commit when status is `APPROVED` or `NEEDS_WORK`. Only requires `REPO_READ` permission.
|
|
466
|
+
|
|
467
|
+
**Status Values**:
|
|
468
|
+
- `APPROVED` - Approve the PR
|
|
469
|
+
- `NEEDS_WORK` - Request changes (shows as "Requested changes" in UI from 8.10+)
|
|
470
|
+
- `UNAPPROVED` - Neutral/remove approval
|
|
471
|
+
|
|
472
|
+
**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.
|
|
473
|
+
|
|
367
474
|
## Pull Request Review Workflow
|
|
368
475
|
|
|
369
476
|
For agents reviewing PRs and leaving comments on specific lines:
|
|
@@ -411,11 +518,27 @@ For agents reviewing PRs and leaving comments on specific lines:
|
|
|
411
518
|
)
|
|
412
519
|
```
|
|
413
520
|
|
|
521
|
+
5. **Update review status**:
|
|
522
|
+
```
|
|
523
|
+
# Approve the PR
|
|
524
|
+
bitbucket_update_review_status(
|
|
525
|
+
projectKey, repositorySlug, pullRequestId,
|
|
526
|
+
status="APPROVED"
|
|
527
|
+
)
|
|
528
|
+
|
|
529
|
+
# Or request changes
|
|
530
|
+
bitbucket_update_review_status(
|
|
531
|
+
projectKey, repositorySlug, pullRequestId,
|
|
532
|
+
status="NEEDS_WORK"
|
|
533
|
+
)
|
|
534
|
+
```
|
|
535
|
+
|
|
414
536
|
**Key Points**:
|
|
415
537
|
- Use `destination` line numbers from the diff for the `TO` side (most common)
|
|
416
538
|
- Use `source` line numbers for the `FROM` side
|
|
417
539
|
- Match `lineType` to the segment type from the diff (ADDED/REMOVED/CONTEXT)
|
|
418
540
|
- The structured diff ensures exact line number accuracy
|
|
541
|
+
- `userSlug` is automatically detected - no need to provide it
|
|
419
542
|
|
|
420
543
|
## Development Commands
|
|
421
544
|
|
|
@@ -431,8 +554,13 @@ node dist/index.js
|
|
|
431
554
|
|
|
432
555
|
# Type checking
|
|
433
556
|
npx tsc --noEmit
|
|
557
|
+
|
|
558
|
+
# Lint and auto-fix issues
|
|
559
|
+
npm run lint
|
|
434
560
|
```
|
|
435
561
|
|
|
562
|
+
**IMPORTANT**: Always run `npm run lint` after making code changes. The linter will auto-fix formatting issues and catch unused variables, type errors, and other code quality issues.
|
|
563
|
+
|
|
436
564
|
## Environment Setup
|
|
437
565
|
|
|
438
566
|
Required environment variables in `.env`:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAazE,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,QAkB9C"}
|
package/dist/tools/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { addPrCommentTool, getPrChangesTool, getPrFileDiffTool, getPrActivitiesTool, getInboxPullRequestsTool } from './pull-requests/index.js';
|
|
2
1
|
import { listProjectsTool } from './projects/index.js';
|
|
2
|
+
import { addPrCommentTool, getInboxPullRequestsTool, getPrActivitiesTool, getPrChangesTool, getPrFileDiffTool, updateReviewStatusTool, } from './pull-requests/index.js';
|
|
3
3
|
import { listRepositoriesTool } from './repositories/index.js';
|
|
4
4
|
import { getAllUsersTool, getUserProfileTool } from './users/index.js';
|
|
5
5
|
export function registerTools(server) {
|
|
@@ -16,5 +16,6 @@ export function registerTools(server) {
|
|
|
16
16
|
getPrChangesTool(server);
|
|
17
17
|
getPrFileDiffTool(server);
|
|
18
18
|
getPrActivitiesTool(server);
|
|
19
|
+
updateReviewStatusTool(server);
|
|
19
20
|
}
|
|
20
21
|
//# sourceMappingURL=index.js.map
|
package/dist/tools/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EACL,gBAAgB,EAChB,wBAAwB,EACxB,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEvE,MAAM,UAAU,aAAa,CAAC,MAAiB;IAC7C,aAAa;IACb,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAC3B,eAAe,CAAC,MAAM,CAAC,CAAC;IAExB,gBAAgB;IAChB,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAEzB,mBAAmB;IACnB,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAE7B,qBAAqB;IACrB,wBAAwB,CAAC,MAAM,CAAC,CAAC;IACjC,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACzB,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACzB,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC1B,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAC5B,sBAAsB,CAAC,MAAM,CAAC,CAAC;AACjC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list_projects.d.ts","sourceRoot":"","sources":["../../../src/tools/projects/list_projects.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"list_projects.d.ts","sourceRoot":"","sources":["../../../src/tools/projects/list_projects.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAWzE,eAAO,MAAM,gBAAgB,GAAI,QAAQ,SAAS,SAwBjD,CAAC"}
|
|
@@ -1,50 +1,24 @@
|
|
|
1
|
-
import { z } from
|
|
2
|
-
import { bitbucketClient } from
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { bitbucketClient } from '../../services/bitbucket.js';
|
|
3
3
|
const schema = z.object({
|
|
4
|
-
name: z
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
permission: z
|
|
9
|
-
.string()
|
|
10
|
-
.optional()
|
|
11
|
-
.describe("Filter by permission (e.g., PROJECT_READ, PROJECT_WRITE, PROJECT_ADMIN)"),
|
|
12
|
-
start: z
|
|
13
|
-
.number()
|
|
14
|
-
.optional()
|
|
15
|
-
.describe("Starting index for pagination (default: 0)"),
|
|
16
|
-
limit: z
|
|
17
|
-
.number()
|
|
18
|
-
.optional()
|
|
19
|
-
.describe("Maximum number of projects to return (default: 25)"),
|
|
4
|
+
name: z.string().optional().describe('Filter projects by name (partial match)'),
|
|
5
|
+
permission: z.string().optional().describe('Filter by permission (e.g., PROJECT_READ, PROJECT_WRITE, PROJECT_ADMIN)'),
|
|
6
|
+
start: z.number().optional().describe('Starting index for pagination (default: 0)'),
|
|
7
|
+
limit: z.number().optional().describe('Maximum number of projects to return (default: 25)'),
|
|
20
8
|
});
|
|
21
9
|
export const listProjectsTool = (server) => {
|
|
22
|
-
server.registerTool(
|
|
23
|
-
title:
|
|
24
|
-
description:
|
|
10
|
+
server.registerTool('bitbucket_list_projects', {
|
|
11
|
+
title: 'List Projects',
|
|
12
|
+
description: 'Retrieve a page of projects. Only projects for which the authenticated user has PROJECT_VIEW permission will be returned. Can filter by name or permission level.',
|
|
25
13
|
inputSchema: schema.shape,
|
|
26
|
-
}, async (
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
if (name !== undefined) {
|
|
30
|
-
queryParams.name = name;
|
|
31
|
-
}
|
|
32
|
-
if (permission !== undefined) {
|
|
33
|
-
queryParams.permission = permission;
|
|
34
|
-
}
|
|
35
|
-
if (start !== undefined) {
|
|
36
|
-
queryParams.start = start.toString();
|
|
37
|
-
}
|
|
38
|
-
if (limit !== undefined) {
|
|
39
|
-
queryParams.limit = limit.toString();
|
|
40
|
-
}
|
|
41
|
-
const response = await bitbucketClient.get("/projects", {
|
|
42
|
-
params: Object.keys(queryParams).length > 0 ? queryParams : undefined,
|
|
14
|
+
}, async ({ name, permission, start, limit }) => {
|
|
15
|
+
const response = await bitbucketClient.get('/projects', {
|
|
16
|
+
params: { name, permission, start, limit },
|
|
43
17
|
});
|
|
44
18
|
return {
|
|
45
19
|
content: [
|
|
46
20
|
{
|
|
47
|
-
type:
|
|
21
|
+
type: 'text',
|
|
48
22
|
text: JSON.stringify(response.data, null, 2),
|
|
49
23
|
},
|
|
50
24
|
],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list_projects.js","sourceRoot":"","sources":["../../../src/tools/projects/list_projects.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"list_projects.js","sourceRoot":"","sources":["../../../src/tools/projects/list_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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add_pr_comment.d.ts","sourceRoot":"","sources":["../../../src/tools/pull-requests/add_pr_comment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"add_pr_comment.d.ts","sourceRoot":"","sources":["../../../src/tools/pull-requests/add_pr_comment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAiBzE,eAAO,MAAM,gBAAgB,GAAI,QAAQ,SAAS,SA0CjD,CAAC"}
|
|
@@ -16,8 +16,7 @@ export const addPrCommentTool = (server) => {
|
|
|
16
16
|
title: 'Add Pull Request Comment',
|
|
17
17
|
description: 'Add a comment to a pull request. Supports general comments, replies, and inline file/line comments',
|
|
18
18
|
inputSchema: schema.shape,
|
|
19
|
-
}, async (
|
|
20
|
-
const { projectKey, repositorySlug, pullRequestId, text, parentId, path, line, lineType, fileType } = schema.parse(params);
|
|
19
|
+
}, async ({ projectKey, repositorySlug, pullRequestId, text, parentId, path, line, lineType, fileType }) => {
|
|
21
20
|
const body = { text };
|
|
22
21
|
if (parentId) {
|
|
23
22
|
body.parent = { id: parentId };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add_pr_comment.js","sourceRoot":"","sources":["../../../src/tools/pull-requests/add_pr_comment.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"add_pr_comment.js","sourceRoot":"","sources":["../../../src/tools/pull-requests/add_pr_comment.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAG9D,MAAM,MAAM,GAAG,CAAC,CAA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AQ,EAAE,EAAE,EAAE;QACtG,MAAM,IAAI,GAAmB,EAAE,IAAI,EAAE,CAAC;QAEtC,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,CAAC,MAAM,GAAG,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC;QACjC,CAAC;QAED,IAAI,IAAI,EAAE,CAAC;YACT,IAAI,CAAC,MAAM,GAAG;gBACZ,IAAI;gBACJ,QAAQ,EAAE,WAAW;gBACrB,GAAG,CAAC,IAAI,IAAI;oBACV,IAAI;oBACJ,QAAQ,EAAE,QAAQ,IAAI,SAAS;oBAC/B,QAAQ,EAAE,QAAQ,IAAI,IAAI;iBAC3B,CAAC;aACH,CAAC;QACJ,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,eAAe,CAAC,IAAI,CACzC,aAAa,UAAU,UAAU,cAAc,kBAAkB,aAAa,WAAW,EACzF,IAAI,CACL,CAAC;QAEF,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;iBAC7C;aACF;SACF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { McpServer } from
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
export declare const getInboxPullRequestsTool: (server: McpServer) => void;
|
|
3
3
|
//# sourceMappingURL=get_inbox_pull_requests.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get_inbox_pull_requests.d.ts","sourceRoot":"","sources":["../../../src/tools/pull-requests/get_inbox_pull_requests.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get_inbox_pull_requests.d.ts","sourceRoot":"","sources":["../../../src/tools/pull-requests/get_inbox_pull_requests.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAezE,eAAO,MAAM,wBAAwB,GAAI,QAAQ,SAAS,SAgDzD,CAAC"}
|
|
@@ -1,31 +1,17 @@
|
|
|
1
|
-
import { z } from
|
|
2
|
-
import { bitbucketClient } from
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { bitbucketClient } from '../../services/bitbucket.js';
|
|
3
3
|
const schema = z.object({
|
|
4
|
-
start: z
|
|
5
|
-
|
|
6
|
-
.optional()
|
|
7
|
-
.describe("Starting index for pagination (default: 0)"),
|
|
8
|
-
limit: z
|
|
9
|
-
.number()
|
|
10
|
-
.optional()
|
|
11
|
-
.describe("Maximum number of pull requests to return (default: 25)"),
|
|
4
|
+
start: z.number().optional().describe('Starting index for pagination (default: 0)'),
|
|
5
|
+
limit: z.number().optional().describe('Maximum number of pull requests to return (default: 25)'),
|
|
12
6
|
});
|
|
13
7
|
export const getInboxPullRequestsTool = (server) => {
|
|
14
|
-
server.registerTool(
|
|
15
|
-
title:
|
|
8
|
+
server.registerTool('bitbucket_get_inbox_pull_requests', {
|
|
9
|
+
title: 'Get Inbox Pull Requests',
|
|
16
10
|
description: "Returns pull requests in the authenticated user's inbox where they are assigned as a reviewer. Returns PRs across all projects and repositories in one call. Each PR includes only essential review information: id, title, description, state, author name, projectKey, and repositorySlug - everything needed to review the PR using other tools. Response is heavily optimized to reduce token usage by ~92%.",
|
|
17
11
|
inputSchema: schema.shape,
|
|
18
|
-
}, async (
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
if (start !== undefined) {
|
|
22
|
-
queryParams.start = start.toString();
|
|
23
|
-
}
|
|
24
|
-
if (limit !== undefined) {
|
|
25
|
-
queryParams.limit = limit.toString();
|
|
26
|
-
}
|
|
27
|
-
const response = await bitbucketClient.get("/inbox/pull-requests", {
|
|
28
|
-
params: Object.keys(queryParams).length > 0 ? queryParams : undefined,
|
|
12
|
+
}, async ({ start, limit }) => {
|
|
13
|
+
const response = await bitbucketClient.get('/inbox/pull-requests', {
|
|
14
|
+
params: { start, limit },
|
|
29
15
|
});
|
|
30
16
|
// Strip to minimal PR - only what agent needs to review
|
|
31
17
|
const minimalPr = (pr) => {
|
|
@@ -38,7 +24,7 @@ export const getInboxPullRequestsTool = (server) => {
|
|
|
38
24
|
projectKey: pr.toRef.repository.project.key,
|
|
39
25
|
repositorySlug: pr.toRef.repository.slug,
|
|
40
26
|
createdDate: pr.createdDate,
|
|
41
|
-
updatedDate: pr.updatedDate
|
|
27
|
+
updatedDate: pr.updatedDate,
|
|
42
28
|
};
|
|
43
29
|
};
|
|
44
30
|
const minimal = {
|
|
@@ -47,12 +33,12 @@ export const getInboxPullRequestsTool = (server) => {
|
|
|
47
33
|
isLastPage: response.data.isLastPage,
|
|
48
34
|
start: response.data.start,
|
|
49
35
|
nextPageStart: response.data.nextPageStart,
|
|
50
|
-
values: response.data.values.map(minimalPr)
|
|
36
|
+
values: response.data.values.map(minimalPr),
|
|
51
37
|
};
|
|
52
38
|
return {
|
|
53
39
|
content: [
|
|
54
40
|
{
|
|
55
|
-
type:
|
|
41
|
+
type: 'text',
|
|
56
42
|
text: JSON.stringify(minimal, null, 2),
|
|
57
43
|
},
|
|
58
44
|
],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get_inbox_pull_requests.js","sourceRoot":"","sources":["../../../src/tools/pull-requests/get_inbox_pull_requests.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get_inbox_pull_requests.js","sourceRoot":"","sources":["../../../src/tools/pull-requests/get_inbox_pull_requests.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAQ9D,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;IACtB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,4CAA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,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,KAAK;YAC1B,aAAa,EAAE,QAAQ,CAAC,IAAI,CAAC,aAAa;YAC1C,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC;SAC5C,CAAC;QAEF,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;iBACvC;aACF;SACF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get_pr_activities.d.ts","sourceRoot":"","sources":["../../../src/tools/pull-requests/get_pr_activities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"get_pr_activities.d.ts","sourceRoot":"","sources":["../../../src/tools/pull-requests/get_pr_activities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAiDzE,eAAO,MAAM,mBAAmB,GAAI,QAAQ,SAAS,SAuGpD,CAAC"}
|
|
@@ -1,63 +1,47 @@
|
|
|
1
|
-
import { z } from
|
|
2
|
-
import { bitbucketClient } from
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { bitbucketClient } from '../../services/bitbucket.js';
|
|
3
3
|
// Activity action types from Bitbucket Server Swagger
|
|
4
4
|
const ActivityType = z.enum([
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
5
|
+
'APPROVED',
|
|
6
|
+
'AUTO_MERGE_CANCELLED',
|
|
7
|
+
'AUTO_MERGE_REQUESTED',
|
|
8
|
+
'COMMENTED',
|
|
9
|
+
'DECLINED',
|
|
10
|
+
'DELETED',
|
|
11
|
+
'MERGED',
|
|
12
|
+
'OPENED',
|
|
13
|
+
'REOPENED',
|
|
14
|
+
'RESCOPED',
|
|
15
|
+
'REVIEW_COMMENTED',
|
|
16
|
+
'REVIEW_DISCARDED',
|
|
17
|
+
'REVIEW_FINISHED',
|
|
18
|
+
'REVIEWED',
|
|
19
|
+
'UNAPPROVED',
|
|
20
|
+
'UPDATED',
|
|
21
21
|
]);
|
|
22
22
|
const schema = z.object({
|
|
23
|
-
projectKey: z.string().describe(
|
|
24
|
-
repositorySlug: z.string().describe(
|
|
25
|
-
pullRequestId: z.number().describe(
|
|
23
|
+
projectKey: z.string().describe('The Bitbucket project key'),
|
|
24
|
+
repositorySlug: z.string().describe('The repository slug'),
|
|
25
|
+
pullRequestId: z.number().describe('The pull request ID'),
|
|
26
26
|
activityTypes: z
|
|
27
27
|
.array(ActivityType)
|
|
28
28
|
.optional()
|
|
29
29
|
.describe('Filter activities by type. Example: ["COMMENTED", "REVIEW_COMMENTED"] to get only comments, or ["APPROVED", "UNAPPROVED"] for approvals.'),
|
|
30
|
-
start: z
|
|
31
|
-
|
|
32
|
-
.optional()
|
|
33
|
-
.describe("Starting index for pagination (default: 0)"),
|
|
34
|
-
limit: z
|
|
35
|
-
.number()
|
|
36
|
-
.optional()
|
|
37
|
-
.describe("Maximum number of items to return (default: 25)"),
|
|
30
|
+
start: z.number().optional().describe('Starting index for pagination (default: 0)'),
|
|
31
|
+
limit: z.number().optional().describe('Maximum number of items to return (default: 25)'),
|
|
38
32
|
});
|
|
39
33
|
export const getPrActivitiesTool = (server) => {
|
|
40
|
-
server.registerTool(
|
|
41
|
-
title:
|
|
34
|
+
server.registerTool('bitbucket_get_pull_request_activities', {
|
|
35
|
+
title: 'Get Pull Request Activities',
|
|
42
36
|
description: "Gets activity on a pull request including comments, approvals, merges, reviews, and updates. Can optionally filter by activity types (e.g., only comments). Returns a paginated list with action types like COMMENTED, APPROVED, DECLINED, MERGED, REVIEWED, etc. Use activityTypes parameter to filter: e.g., ['COMMENTED', 'REVIEW_COMMENTED'] for only comments. Response is optimized for token usage - use commentAnchor.path with get_pr_file_diff to fetch code context when needed.",
|
|
43
37
|
inputSchema: schema.shape,
|
|
44
|
-
}, async (
|
|
45
|
-
const { projectKey, repositorySlug, pullRequestId, activityTypes, start, limit } = schema.parse(params);
|
|
46
|
-
const queryParams = {};
|
|
47
|
-
if (start !== undefined) {
|
|
48
|
-
queryParams.start = start.toString();
|
|
49
|
-
}
|
|
50
|
-
if (limit !== undefined) {
|
|
51
|
-
queryParams.limit = limit.toString();
|
|
52
|
-
}
|
|
53
|
-
queryParams.fromType = "COMMENT";
|
|
38
|
+
}, async ({ projectKey, repositorySlug, pullRequestId, activityTypes, start, limit }) => {
|
|
54
39
|
const response = await bitbucketClient.get(`/projects/${projectKey}/repos/${repositorySlug}/pull-requests/${pullRequestId}/activities`, {
|
|
55
|
-
params:
|
|
40
|
+
params: { fromType: 'COMMENT', start, limit },
|
|
56
41
|
});
|
|
57
|
-
// Helper function to strip user
|
|
42
|
+
// Helper function to strip user links (API returns links but we exclude from type)
|
|
58
43
|
const stripUserBloat = (user) => {
|
|
59
|
-
|
|
60
|
-
return user;
|
|
44
|
+
// biome-ignore lint/correctness/noUnusedVariables: Removing links field from API response
|
|
61
45
|
const { links, ...userWithoutLinks } = user;
|
|
62
46
|
return userWithoutLinks;
|
|
63
47
|
};
|
|
@@ -72,46 +56,37 @@ export const getPrActivitiesTool = (server) => {
|
|
|
72
56
|
};
|
|
73
57
|
// Helper function to simplify likedBy to just count
|
|
74
58
|
const simplifyLikedBy = (likedBy) => {
|
|
75
|
-
if (!likedBy)
|
|
76
|
-
return likedBy;
|
|
77
59
|
return { total: likedBy.total || 0 };
|
|
78
60
|
};
|
|
79
61
|
// Helper function to strip bloat from comments
|
|
80
62
|
const stripBloatFromComment = (comment) => {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
// Recursively strip from nested comments (replies)
|
|
98
|
-
if (strippedComment.comments && Array.isArray(strippedComment.comments)) {
|
|
99
|
-
strippedComment.comments = strippedComment.comments.map(stripBloatFromComment);
|
|
100
|
-
}
|
|
101
|
-
return strippedComment;
|
|
63
|
+
// biome-ignore lint/correctness/noUnusedVariables: Removing anchor, commentAnchor, and permittedOperations from API response
|
|
64
|
+
const { anchor, commentAnchor, permittedOperations, ...rest } = comment;
|
|
65
|
+
// Build clean comment with stripped user and simplified properties (no commentAnchor)
|
|
66
|
+
const cleanComment = {
|
|
67
|
+
...rest,
|
|
68
|
+
author: stripUserBloat(comment.author),
|
|
69
|
+
properties: comment.properties
|
|
70
|
+
? {
|
|
71
|
+
reactions: comment.properties.reactions ? simplifyReactions(comment.properties.reactions) : undefined,
|
|
72
|
+
likedBy: comment.properties.likedBy ? simplifyLikedBy(comment.properties.likedBy) : undefined,
|
|
73
|
+
}
|
|
74
|
+
: undefined,
|
|
75
|
+
comments: comment.comments ? comment.comments.map(stripBloatFromComment) : undefined,
|
|
76
|
+
};
|
|
77
|
+
return cleanComment;
|
|
102
78
|
};
|
|
103
|
-
// Strip bloat from all activities
|
|
79
|
+
// Strip bloat from all activities (remove diff field which is large)
|
|
104
80
|
const strippedValues = response.data.values.map((activity) => {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
return activityWithoutDiff;
|
|
81
|
+
// biome-ignore lint/correctness/noUnusedVariables: Removing diff field from API response
|
|
82
|
+
const { diff, ...rest } = activity;
|
|
83
|
+
// Build clean activity with stripped user and comment
|
|
84
|
+
const cleanActivity = {
|
|
85
|
+
...rest,
|
|
86
|
+
user: stripUserBloat(activity.user),
|
|
87
|
+
comment: activity.comment ? stripBloatFromComment(activity.comment) : undefined,
|
|
88
|
+
};
|
|
89
|
+
return cleanActivity;
|
|
115
90
|
});
|
|
116
91
|
// Filter by activity types if specified
|
|
117
92
|
let responseData = {
|
|
@@ -129,7 +104,7 @@ export const getPrActivitiesTool = (server) => {
|
|
|
129
104
|
return {
|
|
130
105
|
content: [
|
|
131
106
|
{
|
|
132
|
-
type:
|
|
107
|
+
type: 'text',
|
|
133
108
|
text: JSON.stringify(responseData, null, 2),
|
|
134
109
|
},
|
|
135
110
|
],
|