From 2df53cbf106c89326d6556b4ce33c6eb255dddeb Mon Sep 17 00:00:00 2001 From: Nicolas FRADIN Date: Thu, 21 May 2026 08:50:21 +0200 Subject: [PATCH] fix: use correct Bitbucket API for user workspaces and clarify repo config The `/workspaces` API endpoint was updated to `/user/workspaces` to correctly retrieve workspaces for the authenticated user. Configuration guidance for `DEFAULT_WORKSPACE` and `DEFAULT_REPO` in documentation and templates now explicitly references deriving these values from the Bitbucket repository URL, simplifying initial setup. --- .env.template | 5 +++-- CLAUDE.md | 4 ++-- README.md | 2 ++ src/clients/repository-client.ts | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.env.template b/.env.template index de9a8be..0d6ff6c 100644 --- a/.env.template +++ b/.env.template @@ -1,7 +1,8 @@ BITBUCKET_MCP_EMAIL=your_email@example.com BITBUCKET_MCP_TOKEN=your_api_token -DEFAULT_WORKSPACE=your-workspace -DEFAULT_REPO=your-repo +# Find these in your Bitbucket repo URL: https://bitbucket.org/my-workspace/my-repo/pull-requests +DEFAULT_WORKSPACE=my-workspace +DEFAULT_REPO=my-repo # Integration test write operations # --------------------------------------------------------------------------------- diff --git a/CLAUDE.md b/CLAUDE.md index 27fe74c..04f0923 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -41,8 +41,8 @@ The server is a 3-layer pipeline: **MCP protocol** -> **Router** -> **Bitbucket |----------|---------| | `BITBUCKET_MCP_EMAIL` | Bitbucket account email (Basic Auth username) | | `BITBUCKET_MCP_TOKEN` | Bitbucket API token (Basic Auth password) | -| `DEFAULT_WORKSPACE` | Optional default workspace slug | -| `DEFAULT_REPO` | Optional default repository slug | +| `DEFAULT_WORKSPACE` | Optional default workspace slug (from your repo URL: `https://bitbucket.org/{workspace}/{repo}/...`) | +| `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`) | diff --git a/README.md b/README.md index d8975c6..0094ba0 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,8 @@ Add the MCP server to your Claude configuration: > **Important:** > - 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. +> - 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). ### 4. Verify diff --git a/src/clients/repository-client.ts b/src/clients/repository-client.ts index 817a1b9..f8576b2 100644 --- a/src/clients/repository-client.ts +++ b/src/clients/repository-client.ts @@ -11,7 +11,7 @@ export class RepositoryClient extends BaseClient { const params: Record = {}; if (options?.page) params.page = options.page; 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; } catch (error) { throw new Error(`Failed to list workspaces: ${this.formatError(error)}`);