Compare commits
3 Commits
148fe7e51b
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 2df53cbf10 | |||
| 8a410c7fd7 | |||
| 5d911d91a7 |
@@ -1,11 +1,16 @@
|
|||||||
BITBUCKET_MCP_EMAIL=your_email@example.com
|
BITBUCKET_MCP_EMAIL=your_email@example.com
|
||||||
BITBUCKET_MCP_TOKEN=your_api_token
|
BITBUCKET_MCP_TOKEN=your_api_token
|
||||||
DEFAULT_WORKSPACE=your-workspace
|
# Find these in your Bitbucket repo URL: https://bitbucket.org/my-workspace/my-repo/pull-requests
|
||||||
DEFAULT_REPO=your-repo
|
DEFAULT_WORKSPACE=my-workspace
|
||||||
|
DEFAULT_REPO=my-repo
|
||||||
|
|
||||||
# Integration test write operations
|
# Integration test write operations
|
||||||
|
# ---------------------------------------------------------------------------------
|
||||||
# Set RUN_WRITE_TESTS=true to enable tests that create/modify/delete data.
|
# Set RUN_WRITE_TESTS=true to enable tests that create/modify/delete data.
|
||||||
|
#
|
||||||
# TEST_PR_ID must also be set — write tests will only run against this specific PR
|
# TEST_PR_ID must also be set — write tests will only run against this specific PR
|
||||||
# to avoid accidentally modifying unrelated pull requests.
|
# to avoid accidentally modifying unrelated pull requests.
|
||||||
|
# ---------------------------------------------------------------------------------
|
||||||
# RUN_WRITE_TESTS=true
|
# RUN_WRITE_TESTS=true
|
||||||
# TEST_PR_ID=123
|
# TEST_PR_ID=123
|
||||||
|
# ---------------------------------------------------------------------------------
|
||||||
|
|||||||
10
CLAUDE.md
10
CLAUDE.md
@@ -41,9 +41,15 @@ The server is a 3-layer pipeline: **MCP protocol** -> **Router** -> **Bitbucket
|
|||||||
|----------|---------|
|
|----------|---------|
|
||||||
| `BITBUCKET_MCP_EMAIL` | Bitbucket account email (Basic Auth username) |
|
| `BITBUCKET_MCP_EMAIL` | Bitbucket account email (Basic Auth username) |
|
||||||
| `BITBUCKET_MCP_TOKEN` | Bitbucket API token (Basic Auth password) |
|
| `BITBUCKET_MCP_TOKEN` | Bitbucket API token (Basic Auth password) |
|
||||||
| `DEFAULT_WORKSPACE` | Optional default workspace slug |
|
| `DEFAULT_WORKSPACE` | Optional default workspace slug (from your repo URL: `https://bitbucket.org/{workspace}/{repo}/...`) |
|
||||||
| `DEFAULT_REPO` | Optional default repository slug |
|
| `DEFAULT_REPO` | Optional default repository slug (from your repo URL: `https://bitbucket.org/{workspace}/{repo}/...`) |
|
||||||
|
| `RUN_WRITE_TESTS` | Set to `true` to enable write integration tests |
|
||||||
|
| `TEST_PR_ID` | PR ID to use for write integration tests (required when `RUN_WRITE_TESTS=true`) |
|
||||||
|
|
||||||
|
Copy `.env.template` to `.env` and fill in your values for local development and testing.
|
||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
|
|
||||||
Tests use vitest with 30s timeouts. Unit tests mock the Bitbucket client; integration tests call the real API and require valid credentials in the environment.
|
Tests use vitest with 30s timeouts. Unit tests mock the Bitbucket client; integration tests call the real API and require valid credentials in the environment.
|
||||||
|
|
||||||
|
Write integration tests (approve/unapprove, comments, tasks) are skipped by default. They require both `RUN_WRITE_TESTS=true` and `TEST_PR_ID` to be set. Write tests never pick a random PR — if `TEST_PR_ID` is missing the test is skipped with a warning.
|
||||||
|
|||||||
20
README.md
20
README.md
@@ -95,6 +95,8 @@ Add the MCP server to your Claude configuration:
|
|||||||
> **Important:**
|
> **Important:**
|
||||||
> - Replace `/absolute/path/to/bitbucket-mcp` with the actual absolute path where you cloned the repo.
|
> - Replace `/absolute/path/to/bitbucket-mcp` with the actual absolute path where you cloned the repo.
|
||||||
> - `DEFAULT_WORKSPACE` and `DEFAULT_REPO` are optional but convenient — they let you omit those parameters from every tool call.
|
> - `DEFAULT_WORKSPACE` and `DEFAULT_REPO` are optional but convenient — they let you omit those parameters from every tool call.
|
||||||
|
> - Read them directly from your Bitbucket repo URL: `https://bitbucket.org/{workspace}/{repository}/pull-requests`
|
||||||
|
> For example, `https://bitbucket.org/my-workspace/my-repo/pull-requests` → `DEFAULT_WORKSPACE=my-workspace`, `DEFAULT_REPO=my-repo`
|
||||||
> - Get your API token from [Atlassian API Tokens](https://id.atlassian.com/manage-profile/security/api-tokens).
|
> - Get your API token from [Atlassian API Tokens](https://id.atlassian.com/manage-profile/security/api-tokens).
|
||||||
|
|
||||||
### 4. Verify
|
### 4. Verify
|
||||||
@@ -225,13 +227,17 @@ Response:
|
|||||||
|
|
||||||
### Running Locally
|
### Running Locally
|
||||||
|
|
||||||
For development, you can use a `.env` file instead of configuring credentials in the MCP client:
|
For development, you can use a `.env` file instead of configuring credentials in the MCP client. Copy `.env.template` to `.env` and fill in your values:
|
||||||
|
|
||||||
```env
|
```env
|
||||||
BITBUCKET_MCP_EMAIL=your_email@example.com
|
BITBUCKET_MCP_EMAIL=your_email@example.com
|
||||||
BITBUCKET_MCP_TOKEN=your_api_token
|
BITBUCKET_MCP_TOKEN=your_api_token
|
||||||
DEFAULT_WORKSPACE=my-workspace
|
DEFAULT_WORKSPACE=my-workspace
|
||||||
DEFAULT_REPO=my-repo
|
DEFAULT_REPO=my-repo
|
||||||
|
|
||||||
|
# Only needed when running write integration tests (see Testing below)
|
||||||
|
# RUN_WRITE_TESTS=true
|
||||||
|
# TEST_PR_ID=123
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@@ -261,14 +267,14 @@ npx tsc --noEmit
|
|||||||
npm run test:coverage
|
npm run test:coverage
|
||||||
```
|
```
|
||||||
|
|
||||||
**Write operation tests** (approve/unapprove, comments, tasks) are disabled by default. To enable them, set two variables in your `.env`:
|
**Write operation tests** (approve/unapprove, comments, tasks) are disabled by default and require two additional variables in your `.env`:
|
||||||
|
|
||||||
```env
|
| Variable | Description |
|
||||||
RUN_WRITE_TESTS=true
|
|----------|-------------|
|
||||||
TEST_PR_ID=123 # ID of a PR you own and can safely modify
|
| `RUN_WRITE_TESTS=true` | Opt in to running write tests |
|
||||||
```
|
| `TEST_PR_ID=<id>` | ID of a PR you own and can safely modify |
|
||||||
|
|
||||||
`TEST_PR_ID` is required — write tests will not fall back to a random PR. If it is not set, each write test is skipped with a warning. This prevents accidental modifications to production PRs.
|
`TEST_PR_ID` is mandatory — write tests will never fall back to a random PR from the repository. If it is not set, each write test is skipped with a warning. This prevents accidental modifications to PRs you don't intend to touch.
|
||||||
|
|
||||||
### Project Structure
|
### Project Structure
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export class RepositoryClient extends BaseClient {
|
|||||||
const params: Record<string, any> = {};
|
const params: Record<string, any> = {};
|
||||||
if (options?.page) params.page = options.page;
|
if (options?.page) params.page = options.page;
|
||||||
if (options?.pagelen) params.pagelen = options.pagelen;
|
if (options?.pagelen) params.pagelen = options.pagelen;
|
||||||
const response = await this.axiosInstance.get('/workspaces', { params });
|
const response = await this.axiosInstance.get('/user/workspaces', { params });
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new Error(`Failed to list workspaces: ${this.formatError(error)}`);
|
throw new Error(`Failed to list workspaces: ${this.formatError(error)}`);
|
||||||
|
|||||||
Reference in New Issue
Block a user