feat: Add remaining PR lifecycle and code review tools

- Added create_pull_request, update_pull_request, merge_pull_request tools
- Added list_branches and delete_branch tools (fixed delete to handle 204 response)
- Enhanced add_comment to support inline comments on specific code lines
- Added all code review tools: approve/unapprove, request/remove changes, get diff
- Updated package version to 0.2.0
- Comprehensive documentation for all tools in README
This commit is contained in:
pdogra1299 2025-06-04 19:33:16 +05:30
parent 66c28c421e
commit 6abca3e7d0
3 changed files with 1508 additions and 21 deletions

196
README.md
View file

@ -4,16 +4,23 @@ An MCP (Model Context Protocol) server that provides tools for interacting with
## Features
Currently implemented:
### Currently Implemented Tools
#### Core PR Lifecycle Tools
- `get_pull_request` - Retrieve detailed information about a pull request
- `list_pull_requests` - List pull requests with filters (state, author, pagination)
Planned features:
- `create_pull_request` - Create new pull requests
- `update_pull_request` - Update PR details
- `merge_pull_request` - Merge pull requests
- `delete_branch` - Delete branches
- And more...
- `update_pull_request` - Update PR details (title, description, reviewers, destination branch)
- `add_comment` - Add comments to pull requests (supports replies)
- `merge_pull_request` - Merge pull requests with various strategies
- `delete_branch` - Delete branches after merge
#### Code Review Tools
- `get_pull_request_diff` - Get the diff/changes for a pull request
- `approve_pull_request` - Approve a pull request
- `unapprove_pull_request` - Remove approval from a pull request
- `request_changes` - Request changes on a pull request
- `remove_requested_changes` - Remove change request from a pull request
## Installation
@ -84,7 +91,7 @@ For Bitbucket Server, use:
"command": "node",
"args": ["/absolute/path/to/bitbucket-mcp-server/build/index.js"],
"env": {
"BITBUCKET_USERNAME": "your-username",
"BITBUCKET_USERNAME": "your.email@company.com",
"BITBUCKET_TOKEN": "your-http-access-token",
"BITBUCKET_BASE_URL": "https://bitbucket.yourcompany.com"
}
@ -93,6 +100,10 @@ For Bitbucket Server, use:
}
```
**Important for Bitbucket Server users:**
- Use your full email address as the username (e.g., "john.doe@company.com")
- This is required for approval/review actions to work correctly
## Usage
Once configured, you can use the available tools:
@ -143,6 +154,175 @@ Returns a paginated list of pull requests with:
- For Bitbucket Cloud: Use the username (e.g., "johndoe")
- For Bitbucket Server: Use the full email address (e.g., "john.doe@company.com")
### Create Pull Request
```typescript
{
"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)
}
}
```
### Update Pull Request
```typescript
{
"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 - replaces existing reviewers
}
}
```
### Add Comment
Add general comments or inline comments on specific lines of code:
```typescript
// General comment
{
"tool": "add_comment",
"arguments": {
"workspace": "PROJ",
"repository": "my-repo",
"pull_request_id": 123,
"comment_text": "Great work! Just one small suggestion...",
"parent_comment_id": 456 // Optional - for replies
}
}
// Inline comment on specific code
{
"tool": "add_comment",
"arguments": {
"workspace": "PROJ",
"repository": "my-repo",
"pull_request_id": 123,
"comment_text": "This variable should be renamed for clarity",
"file_path": "src/main.js",
"line_number": 42,
"line_type": "ADDED" // ADDED, REMOVED, or CONTEXT
}
}
```
**Note on inline comments:**
- `file_path`: The path to the file as shown in the diff
- `line_number`: The line number as shown in the diff
- `line_type`:
- `ADDED` - For newly added lines (green in diff)
- `REMOVED` - For deleted lines (red in diff)
- `CONTEXT` - For unchanged context lines
### Merge Pull Request
```typescript
{
"tool": "merge_pull_request",
"arguments": {
"workspace": "PROJ",
"repository": "my-repo",
"pull_request_id": 123,
"merge_strategy": "squash", // Optional: merge-commit, squash, fast-forward
"close_source_branch": true, // Optional
"commit_message": "Custom merge message" // Optional
}
}
```
### List Branches
```typescript
{
"tool": "list_branches",
"arguments": {
"workspace": "PROJ",
"repository": "my-repo",
"filter": "feature", // Optional: filter by name pattern
"limit": 25, // Optional (default: 25)
"start": 0 // Optional: for pagination (default: 0)
}
}
```
Returns a paginated list of branches with:
- Branch name and ID
- Latest commit hash
- Default branch indicator
- Pagination info
### Delete Branch
```typescript
{
"tool": "delete_branch",
"arguments": {
"workspace": "PROJ",
"repository": "my-repo",
"branch_name": "feature/old-feature",
"force": false // Optional (default: false)
}
}
```
**Note**: Branch deletion requires appropriate permissions. The branch will be permanently deleted.
### Get Pull Request Diff
```typescript
{
"tool": "get_pull_request_diff",
"arguments": {
"workspace": "PROJ",
"repository": "my-repo",
"pull_request_id": 123,
"context_lines": 5 // Optional (default: 3)
}
}
```
### Approve Pull Request
```typescript
{
"tool": "approve_pull_request",
"arguments": {
"workspace": "PROJ",
"repository": "my-repo",
"pull_request_id": 123
}
}
```
### Request Changes
```typescript
{
"tool": "request_changes",
"arguments": {
"workspace": "PROJ",
"repository": "my-repo",
"pull_request_id": 123,
"comment": "Please address the following issues..." // Optional
}
}
```
## Development
- `npm run dev` - Watch mode for development

View file

@ -1,6 +1,6 @@
{
"name": "bitbucket-mcp-server",
"version": "0.1.0",
"version": "0.2.0",
"description": "MCP server for Bitbucket API integration",
"type": "module",
"main": "./build/index.js",

File diff suppressed because it is too large Load diff