@kornilovsergei/bitbucket-mcp-server 0.0.0-stage → 4.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.
Files changed (180) hide show
  1. package/CHANGELOG.md +681 -0
  2. package/LICENSE +21 -0
  3. package/README.md +234 -2
  4. package/build/config/http.d.ts +12 -0
  5. package/build/config/http.d.ts.map +1 -0
  6. package/build/config/http.js +48 -0
  7. package/build/config/http.js.map +1 -0
  8. package/build/config/index.d.ts +15 -0
  9. package/build/config/index.d.ts.map +1 -0
  10. package/build/config/index.js +257 -0
  11. package/build/config/index.js.map +1 -0
  12. package/build/core/access.d.ts +8 -0
  13. package/build/core/access.d.ts.map +1 -0
  14. package/build/core/access.js +22 -0
  15. package/build/core/access.js.map +1 -0
  16. package/build/core/api-client.d.ts +72 -0
  17. package/build/core/api-client.d.ts.map +1 -0
  18. package/build/core/api-client.js +423 -0
  19. package/build/core/api-client.js.map +1 -0
  20. package/build/core/cache.d.ts +56 -0
  21. package/build/core/cache.d.ts.map +1 -0
  22. package/build/core/cache.js +169 -0
  23. package/build/core/cache.js.map +1 -0
  24. package/build/core/file-list.d.ts +8 -0
  25. package/build/core/file-list.d.ts.map +1 -0
  26. package/build/core/file-list.js +75 -0
  27. package/build/core/file-list.js.map +1 -0
  28. package/build/core/local-files.d.ts +3 -0
  29. package/build/core/local-files.d.ts.map +1 -0
  30. package/build/core/local-files.js +56 -0
  31. package/build/core/local-files.js.map +1 -0
  32. package/build/core/paths.d.ts +16 -0
  33. package/build/core/paths.d.ts.map +1 -0
  34. package/build/core/paths.js +42 -0
  35. package/build/core/paths.js.map +1 -0
  36. package/build/core/query-budget.d.ts +7 -0
  37. package/build/core/query-budget.d.ts.map +1 -0
  38. package/build/core/query-budget.js +84 -0
  39. package/build/core/query-budget.js.map +1 -0
  40. package/build/core/redact.d.ts +8 -0
  41. package/build/core/redact.d.ts.map +1 -0
  42. package/build/core/redact.js +40 -0
  43. package/build/core/redact.js.map +1 -0
  44. package/build/core/safe-regex.d.ts +14 -0
  45. package/build/core/safe-regex.d.ts.map +1 -0
  46. package/build/core/safe-regex.js +223 -0
  47. package/build/core/safe-regex.js.map +1 -0
  48. package/build/core/scan.d.ts +45 -0
  49. package/build/core/scan.d.ts.map +1 -0
  50. package/build/core/scan.js +102 -0
  51. package/build/core/scan.js.map +1 -0
  52. package/build/core/snapshot.d.ts +86 -0
  53. package/build/core/snapshot.d.ts.map +1 -0
  54. package/build/core/snapshot.js +502 -0
  55. package/build/core/snapshot.js.map +1 -0
  56. package/build/core/throttle.d.ts +38 -0
  57. package/build/core/throttle.d.ts.map +1 -0
  58. package/build/core/throttle.js +110 -0
  59. package/build/core/throttle.js.map +1 -0
  60. package/build/formatting/attachment-formatter.d.ts +20 -0
  61. package/build/formatting/attachment-formatter.d.ts.map +1 -0
  62. package/build/formatting/attachment-formatter.js +32 -0
  63. package/build/formatting/attachment-formatter.js.map +1 -0
  64. package/build/formatting/diff-parser.d.ts +20 -0
  65. package/build/formatting/diff-parser.d.ts.map +1 -0
  66. package/build/formatting/diff-parser.js +165 -0
  67. package/build/formatting/diff-parser.js.map +1 -0
  68. package/build/formatting/formatters.d.ts +45 -0
  69. package/build/formatting/formatters.d.ts.map +1 -0
  70. package/build/formatting/formatters.js +212 -0
  71. package/build/formatting/formatters.js.map +1 -0
  72. package/build/formatting/respond.d.ts +37 -0
  73. package/build/formatting/respond.d.ts.map +1 -0
  74. package/build/formatting/respond.js +93 -0
  75. package/build/formatting/respond.js.map +1 -0
  76. package/build/formatting/server-json-diff.d.ts +36 -0
  77. package/build/formatting/server-json-diff.d.ts.map +1 -0
  78. package/build/formatting/server-json-diff.js +55 -0
  79. package/build/formatting/server-json-diff.js.map +1 -0
  80. package/build/formatting/suggestion-formatter.d.ts +6 -0
  81. package/build/formatting/suggestion-formatter.d.ts.map +1 -0
  82. package/build/formatting/suggestion-formatter.js +17 -0
  83. package/build/formatting/suggestion-formatter.js.map +1 -0
  84. package/build/handlers/attachment-handlers.d.ts +10 -0
  85. package/build/handlers/attachment-handlers.d.ts.map +1 -0
  86. package/build/handlers/attachment-handlers.js +81 -0
  87. package/build/handlers/attachment-handlers.js.map +1 -0
  88. package/build/handlers/branch-handlers.d.ts +19 -0
  89. package/build/handlers/branch-handlers.d.ts.map +1 -0
  90. package/build/handlers/branch-handlers.js +373 -0
  91. package/build/handlers/branch-handlers.js.map +1 -0
  92. package/build/handlers/file-handlers.d.ts +13 -0
  93. package/build/handlers/file-handlers.d.ts.map +1 -0
  94. package/build/handlers/file-handlers.js +296 -0
  95. package/build/handlers/file-handlers.js.map +1 -0
  96. package/build/handlers/grep-handlers.d.ts +14 -0
  97. package/build/handlers/grep-handlers.d.ts.map +1 -0
  98. package/build/handlers/grep-handlers.js +267 -0
  99. package/build/handlers/grep-handlers.js.map +1 -0
  100. package/build/handlers/project-handlers.d.ts +10 -0
  101. package/build/handlers/project-handlers.d.ts.map +1 -0
  102. package/build/handlers/project-handlers.js +98 -0
  103. package/build/handlers/project-handlers.js.map +1 -0
  104. package/build/handlers/pull-request-handlers.d.ts +51 -0
  105. package/build/handlers/pull-request-handlers.d.ts.map +1 -0
  106. package/build/handlers/pull-request-handlers.js +990 -0
  107. package/build/handlers/pull-request-handlers.js.map +1 -0
  108. package/build/handlers/review-handlers.d.ts +27 -0
  109. package/build/handlers/review-handlers.d.ts.map +1 -0
  110. package/build/handlers/review-handlers.js +174 -0
  111. package/build/handlers/review-handlers.js.map +1 -0
  112. package/build/handlers/search-handlers.d.ts +32 -0
  113. package/build/handlers/search-handlers.d.ts.map +1 -0
  114. package/build/handlers/search-handlers.js +261 -0
  115. package/build/handlers/search-handlers.js.map +1 -0
  116. package/build/http-server.d.ts +43 -0
  117. package/build/http-server.d.ts.map +1 -0
  118. package/build/http-server.js +252 -0
  119. package/build/http-server.js.map +1 -0
  120. package/build/index.d.ts +3 -0
  121. package/build/index.d.ts.map +1 -0
  122. package/build/index.js +47 -0
  123. package/build/index.js.map +1 -0
  124. package/build/server.d.ts +22 -0
  125. package/build/server.d.ts.map +1 -0
  126. package/build/server.js +126 -0
  127. package/build/server.js.map +1 -0
  128. package/build/service.d.ts +11 -0
  129. package/build/service.d.ts.map +1 -0
  130. package/build/service.js +174 -0
  131. package/build/service.js.map +1 -0
  132. package/build/tools/definitions.d.ts +3 -0
  133. package/build/tools/definitions.d.ts.map +1 -0
  134. package/build/tools/definitions.js +582 -0
  135. package/build/tools/definitions.js.map +1 -0
  136. package/build/tools/guards.d.ts +245 -0
  137. package/build/tools/guards.d.ts.map +1 -0
  138. package/build/tools/guards.js +164 -0
  139. package/build/tools/guards.js.map +1 -0
  140. package/build/tools/registry.d.ts +16 -0
  141. package/build/tools/registry.d.ts.map +1 -0
  142. package/build/tools/registry.js +51 -0
  143. package/build/tools/registry.js.map +1 -0
  144. package/build/types/bitbucket.d.ts +610 -0
  145. package/build/types/bitbucket.d.ts.map +1 -0
  146. package/build/types/bitbucket.js +2 -0
  147. package/build/types/bitbucket.js.map +1 -0
  148. package/build/types/config.d.ts +207 -0
  149. package/build/types/config.d.ts.map +1 -0
  150. package/build/types/config.js +5 -0
  151. package/build/types/config.js.map +1 -0
  152. package/build/types/diff.d.ts +24 -0
  153. package/build/types/diff.d.ts.map +1 -0
  154. package/build/types/diff.js +3 -0
  155. package/build/types/diff.js.map +1 -0
  156. package/build/types/files.d.ts +9 -0
  157. package/build/types/files.d.ts.map +1 -0
  158. package/build/types/files.js +3 -0
  159. package/build/types/files.js.map +1 -0
  160. package/build/types/http.d.ts +49 -0
  161. package/build/types/http.d.ts.map +1 -0
  162. package/build/types/http.js +3 -0
  163. package/build/types/http.js.map +1 -0
  164. package/build/types/index.d.ts +9 -0
  165. package/build/types/index.d.ts.map +1 -0
  166. package/build/types/index.js +9 -0
  167. package/build/types/index.js.map +1 -0
  168. package/build/types/search.d.ts +66 -0
  169. package/build/types/search.d.ts.map +1 -0
  170. package/build/types/search.js +4 -0
  171. package/build/types/search.js.map +1 -0
  172. package/build/types/snapshot.d.ts +70 -0
  173. package/build/types/snapshot.d.ts.map +1 -0
  174. package/build/types/snapshot.js +3 -0
  175. package/build/types/snapshot.js.map +1 -0
  176. package/build/types/tools.d.ts +38 -0
  177. package/build/types/tools.d.ts.map +1 -0
  178. package/build/types/tools.js +3 -0
  179. package/build/types/tools.js.map +1 -0
  180. package/package.json +77 -4
package/CHANGELOG.md ADDED
@@ -0,0 +1,681 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## 4.1.0 (fork)
9
+
10
+ ### Features
11
+
12
+ * HTTP mode: `--http` (or `BITBUCKET_MCP_TRANSPORT=http`) serves every MCP client from one process over Streamable HTTP on `127.0.0.1:8790/mcp`, one MCP session per client sharing the API client, rate limiter and caches. Loopback only unless an API key is set; Host and Origin checks against DNS rebinding and web pages; body, session count and idle-session limits (`src/http-server.ts`)
13
+ * `bitbucket-mcp-server service install|uninstall|status`: runs HTTP mode as a macOS LaunchAgent (`src/service.ts`)
14
+
15
+ ## 4.0.1 (fork)
16
+
17
+ ### Bug Fixes
18
+
19
+ * diffs on Bitbucket Server older than 7.x: `get_commit_detail` and `get_pull_request_diff` got HTTP 406 for `Accept: text/plain`; on 406 the diff is now read as JSON and rendered to unified diff text (`src/formatting/server-json-diff.ts`)
20
+
21
+ ## [4.0.0](https://github.com/pdogra1299/bitbucket-mcp-server/compare/v3.0.1...v4.0.0) (2026-10-26)
22
+
23
+ ### ⚠ BREAKING CHANGES
24
+
25
+ * Node.js 22 or newer is required (18 and 20 are end-of-life).
26
+ * attachment uploads are disabled until BITBUCKET_ATTACHMENT_ROOT names the only directory they may read from.
27
+ * grep/search_code regexes with a quantified group that contains another quantifier (e.g. `(\d+\s*)+`) are rejected with a rewrite hint.
28
+
29
+ ### Bug Fixes
30
+
31
+ * harden against path steering, file exfiltration, ReDoS and token leaks ([8cc9495](https://github.com/pdogra1299/bitbucket-mcp-server/commit/8cc949532a53d99798bf7db66b0c9721a2b0b3b5))
32
+
33
+ ## [3.0.1](https://github.com/pdogra1299/bitbucket-mcp-server/compare/v3.0.0...v3.0.1) (2026-09-26)
34
+
35
+ ### Bug Fixes
36
+
37
+ * **ci:** add ci, release and commit policy workflows ([b73ee2d](https://github.com/pdogra1299/bitbucket-mcp-server/commit/b73ee2d0f17ee7a9f8134fcd3794d4d43cf8a349))
38
+ * **release:** pin conventionalcommits preset to v8 for writer compatibility ([e9cb095](https://github.com/pdogra1299/bitbucket-mcp-server/commit/e9cb0958f07bc1dd2a8020d7c8a9574315507f48))
39
+
40
+ ## [3.0.0] - 2026-07-09
41
+
42
+ Complete revamp: grep-like repo search, drastically fewer Bitbucket API calls, rate-limit-safe transport, compact token-efficient responses, and a consolidated 25-tool surface. Design and verified API research in `REVAMP_PLAN.md`.
43
+
44
+ ### Added
45
+
46
+ - **`grep` tool — search a repo like ripgrep on a local clone (Server/DC only).** One `archive?at=<sha>` download per repo+commit is streamed (tar.gz, constant memory), regex-scanned line-by-line, and cached in an in-memory byte-budget LRU with content-hash blob dedup across branches. Warm queries cost **1 API call** (the freshness check) instead of a listing + up to 3000 raw file GETs. Full regex, any branch, no index gaps, `content`/`files`/`count` modes, context lines, ripgrep-style output with `as_of <commit>`. Falls back to a bounded per-file scan when the archive endpoint is unavailable. Completeness contract: retention caps never reduce scan coverage (oversized text files are stream-scanned and re-fetched individually on warm hits); binaries are skipped and counted, never silent.
47
+ - **Client-side rate-limit pacing.** All requests flow through a token bucket sized to Bitbucket DC's per-user limiter (default 5 req/s sustained, burst 50 — DC's server default is 60/5) plus a global concurrency cap, making 429s mathematically avoidable on default instances. Bounded retries with full-jitter backoff (Retry-After honored opportunistically; DC documents none), in-flight GET coalescing, keep-alive sockets, request timeouts.
48
+ - **Central config module (`src/config`).** Every numeric policy (rate limits, retries, snapshot budgets, page sizes, truncation caps) is env-overridable — nothing hard-coded at call sites. See `CONFIG_REFERENCE` for the full table. Legacy env names (`BITBUCKET_DEFAULT_PARALLELISM`, `BITBUCKET_MAX_SCAN_FILES`, …) still work.
49
+ - **`version` pass-through on all mutations.** `update/merge/decline_pull_request` and `manage_comment` accept the entity `version` from a prior read (now included in `get_pull_request`/list outputs), turning 2-call mutations into 1 call, with an automatic refetch-and-retry on 409 conflicts.
50
+ - **Cross-repo PR listing.** `list_pull_requests` without `repository` uses the dashboard endpoint (Server) — "my PRs across all repos" in one call.
51
+
52
+ ### Changed
53
+
54
+ - **Diffs are raw unified diff text** (`Accept: text/plain`) — ~5–10× fewer tokens than the old per-line JSON objects with zero information loss (line numbers derive from `@@` headers). Applies to `get_pull_request_diff` and `get_commit_detail`; `get_commit_detail` gains `detail:"files"` for a body-less changed-file list.
55
+ - **`get_file_content` reads a line window server-side in ONE call** (browse endpoint pages over lines; ≤5000/page) instead of metadata + full raw download; `full_content`/negative `start_line` still fetch whole files.
56
+ - **`get_file_blame` fetches only the pages covering the requested window** — a 50-line blame in a 100k-line file is 1 call (was up to 100). Output is a compact commit legend + line spans.
57
+ - **`get_pull_request` is 1 call for metadata** (merge commit + closed date + comment/task counts come from the PR resource itself) and at most 3–4 with `include_comments`/`include_file_changes`/`include_tasks` (tasks via the `blocker-comments` endpoint, DC 7.2+). Activities pagination is honest: server clamps at 500/page and truncation is reported (the old `limit=1000` silently lost data). `merged_by` is extracted from the same activities page that serves comments — no extra calls.
58
+ - **`search_code`**: the redundant case-variant second query is removed (the index is case-insensitive per Atlassian docs); the zero-hit index-gap probe is a single one-page listing (was up to 40 calls); pagination stops with steering text at the search server's ~1000-result window; output is ripgrep-style text.
59
+ - **All responses compacted**: no pretty-printed JSON, ISO-8601 dates, no argument echoes or derivable fields, bulk content as plain text blocks, all truncation explicitly marked, error details capped, text attachment downloads capped (config).
60
+ - **Repo restructured**: `src/{config,core,formatting,handlers,tools,types}` with a canonical types barrel, `type` aliases only (no `interface`), and a tool registry that enforces group/availability filtering at dispatch (hidden tools are no longer callable by name). `BITBUCKET_TOOL_GROUPS` values are validated with warnings.
61
+
62
+ ### Removed (breaking — consolidation, same capabilities)
63
+
64
+ | v2 tool | v3 replacement |
65
+ |---|---|
66
+ | `find_in_files` | `grep` (query = regex) |
67
+ | `search_files` | `grep` (omit query; `glob`) |
68
+ | `list_pr_tasks` | `get_pull_request` with `include_tasks: true` |
69
+ | `create_pr_task` | `add_comment` with `severity: "BLOCKER"` |
70
+ | `update_pr_task` | `manage_comment` `action: "edit"` |
71
+ | `delete_pr_task` / `delete_comment` | `manage_comment` `action: "delete"` |
72
+ | `set_pr_task_status` | `manage_comment` `action: "resolve"` / `"reopen"` |
73
+ | `convert_pr_item` | `manage_comment` `action: "to_task"` / `"to_comment"` |
74
+ | `set_pr_approval` | `set_review_status` `status: "APPROVED"` / `"UNAPPROVED"` |
75
+
76
+ Update Claude Code permission allowlists (`mcp__bitbucket__*`) and prompts accordingly. 33 → 25 tools; tool-definition context cost drops ~30%.
77
+
78
+ ## [2.3.1] - 2026-07-05
79
+
80
+ ### Fixed
81
+
82
+ - **Auth and server errors now include Bitbucket's request id for log correlation.** 401 (authentication failed), 403 (permission denied), and generic API error messages append `[bitbucket-ref: <x-arequestid>]` when Bitbucket returns the `x-arequestid` response header, so operators can correlate a failure to the exact entry in the Bitbucket Data Center access logs. No change when the header is absent; 404 responses are untouched. ([#16](https://github.com/pdogra1299/bitbucket-mcp-server/pull/16))
83
+
84
+ ## [2.3.0] - 2026-07-03
85
+
86
+ ### Fixed
87
+
88
+ - **`find_in_files` no longer fabricates rate-limit errors from permission denials.** Previously, 3 consecutive HTTP 403s aborted the whole scan and reported `RATE_LIMITED: Bitbucket returned 429/403...` — but 403 is authorization, not throttling, so a permission-scoped directory could falsely kill the scan. 403'd files are now skipped individually and reported via a new `PERMISSION_DENIED` warning (with `files_permission_denied` in diagnostics); the scan continues. The racy shared `consecutive403s` counter is gone. Only HTTP 429 means rate-limiting.
89
+ - **HTTP 429 during a scan is retried instead of instantly aborting.** Each throttled file fetch is retried up to 3 attempts, honoring the `Retry-After` header (fallback: 2s/4s exponential backoff with jitter, 30s cap). Only after retries are exhausted does the scan stop — keeping all results gathered so far — with an accurate `RATE_LIMITED` warning.
90
+ - **Repository file listings now paginate.** `find_in_files`, the index-gap probe, and `search_files` previously issued a single `limit=100000` request and silently dropped everything past the first page on instances that clamp page size. Listings now follow `isLastPage`/`nextPageStart` (Server) and the `next` cursor (Cloud, `search_files`), and surface `FILE_LIST_TRUNCATED` / `file_list_truncated` when the pagination safety cap is genuinely hit.
91
+ - **`get_file_blame` reports truncation.** If the 100-page safety cap stops blame pagination early, the response now carries `truncated: true` and a warning instead of silently returning partial blame.
92
+ - **Real Bitbucket throttling is labeled as such.** `handleApiError` now maps HTTP 429 to a clear "Rate limited by Bitbucket" message including `Retry-After` when present, instead of the generic API-error text.
93
+
94
+ ### Added
95
+
96
+ - **In-memory file-list cache (60s TTL)** shared by `find_in_files`, the index-gap probe, and `search_files` — repeated searches against the same repo/branch no longer re-download the full file tree each call. API-only; nothing is written to disk.
97
+ - **`comment_limit` parameter on `get_pull_request`** (default 20, previously a hard-coded slice) to fetch more active comments when a PR has long discussions.
98
+ - **Env-tunable scan knobs:** `BITBUCKET_DEFAULT_PARALLELISM` (default 4), `BITBUCKET_MAX_PARALLELISM` (cap 20), `BITBUCKET_MAX_SCAN_FILES` (default 3000).
99
+
100
+ ## [2.2.0] - 2026-06-05
101
+
102
+ ### Added
103
+
104
+ - **File attachments (Bitbucket Server / Data Center only).** Upload local files and embed them in PR comments and descriptions:
105
+ - New **`attachments`** parameter on `add_comment`, `create_pull_request`, and `update_pull_request`. Each item is a local file path string or `{ file_path, alt_text?, render? }`. Files are uploaded to the repository and a Markdown reference (`attachment:N/M`) is appended automatically — `render: "image"` embeds inline (`![alt](…)`), `"link"` embeds a download link, `"auto"` (default) picks based on file type. For `update_pull_request`, attachments-only updates append to the existing description instead of replacing it.
106
+ - New **`manage_attachments`** tool (new `attachments` tool group, Server only) with `action: "download"` (returns text/image/metadata by numeric id) and `action: "delete"` (by numeric id, requires `REPO_ADMIN`). No `list` action — Bitbucket exposes no attachment-listing API.
107
+ - **Bitbucket Cloud** has no public attachment API; using `attachments` or `manage_attachments` on a Cloud connection returns a clear, explanatory error.
108
+
109
+ ### Changed
110
+
111
+ - **API client** gained multipart upload (`uploadAttachment`) and binary download (`downloadAttachment`) support; previously the client was JSON-only. The upload posts to the prefix-less `/projects/{key}/repos/{slug}/attachments` path (the servlet that actually accepts uploads on Bitbucket DC), falling back to the `/rest/api/1.0/...` form, and sends `Accept: */*` — verified against a live Bitbucket Data Center instance where axios's default `Accept` header is rejected with HTTP 405 by the fronting proxy. Download/delete use the documented `/rest/api/1.0/.../attachments/{id}` resource (delete requires `REPO_ADMIN`).
112
+ - Added `form-data` as a direct dependency (previously only transitive via axios).
113
+
114
+ ## [2.1.0] - 2026-05-10
115
+
116
+ ### Added
117
+
118
+ - **`find_in_files` tool** — Content search by listing files and reading them through the raw endpoint. The escape hatch for everything Bitbucket's index does not cover: full PCRE regex, languages the index ignores (e.g. `.hs`), feature branches, and files Bitbucket's index missed despite indexing the language. Same dense JSON output as `search_code`. Concurrency-capped (default 4) with rate-limit detection (429 aborts immediately; 3+ consecutive 403s aborts; transient single 403s are tolerated as per-file permission denials). Surfaces honest diagnostics: `files_scanned`, `files_attempted`, `files_failed`, `files_truncated`. **Bitbucket Server only.**
119
+
120
+ - **New `search_code` parameters** mapping directly to documented Bitbucket modifiers:
121
+ - `lang` (`lang:`), `ext` (`ext:`), `path` (`path:`), `archived` (`archived:`), `fork` (`fork:`), `exclude_terms` (each becomes `-term`).
122
+ - `regex_filter` — client-side regex applied to returned hit lines as a post-filter; lets you narrow without spending Bitbucket query budget.
123
+ - `case_variants` — runs the query with snake_case ↔ camelCase converted and merges results in one tool call.
124
+
125
+ - **Index-reach probe** — when `search_code` returns zero hits, the server lists matching files via the same filters; if files exist it surfaces an `INDEX_GAP_LIKELY` warning that names the file count, calls out an unrecognized `lang:` filter when present, and tells the LLM to fall back to `find_in_files`. Distinguishes `PROBE_UNAVAILABLE` (probe could not run) from real zero-results.
126
+
127
+ - **Soft-degrade query builder** — Bitbucket caps queries at 250 characters and 9 expressions. When constructed clauses exceed either cap, optional clauses (drop priority: `exclude_terms` → `archived` → `fork` → `ext` → `lang` → `path` → `repo`) are removed one at a time with a `QUERY_TRUNCATED` warning. Previously this returned a hard error.
128
+
129
+ - **Dense JSON response shape** for both search tools:
130
+ - Only matched lines are returned (previously surrounding-context lines were rendered as if they were matches, inflating output ~10x).
131
+ - Distinct `total_files` and `total_matches`, plus an `engine` field (`bitbucket_index` or `find_in_files`) so callers know which path served the result.
132
+ - `diagnostics` block exposes `expression_count`, `query_length`, `dropped_clauses`, and (for `find_in_files`) honest scan counts.
133
+
134
+ - **Structured warnings** at every failure mode: `INDEX_GAP_LIKELY`, `REGEX_FILTER_REJECTED_ALL`, `PROBE_UNAVAILABLE`, `RATE_LIMITED`, `FETCH_FAILURES`, `FILES_TRUNCATED`, `POSSIBLE_FALSE_NEGATIVE`, `QUERY_TRUNCATED`, `INVALID_REGEX`, `DEPRECATED_PARAM`. Each names the specific cause and the next action.
135
+
136
+ ### Changed
137
+
138
+ - **Tool descriptions rewritten** for `search_code`, `find_in_files`, `search_files`, `search_repositories`. Lead with USE WHEN / DO NOT USE WHEN, document Bitbucket index quirks (punctuation stripping, ALL-CAPS operators, single-character terms ignored), and state hard limits (250-char query, 9 expressions, 512 KiB per file, default branch only). Language-neutral throughout — no per-language regex tables baked into the server.
139
+
140
+ - **`search_code` parameter renames** — `search_query` → `query`, `file_pattern` → `ext` / `path`. Old names still accepted with a `DEPRECATED_PARAM` warning. `search_context` and `include_patterns` are accepted but ignored with a deprecation warning (their patterns collapsed at index time due to Bitbucket's punctuation-stripping behavior).
141
+
142
+ - **`search_repositories`** modernized to the dense JSON shape; accepts both `query` and `search_query` (deprecated).
143
+
144
+ ### Fixed
145
+
146
+ - **`search_code` smart-query layer was a no-op.** The previous `buildContextualPatterns` generated 7 OR'd patterns (`"foo ="`, `"foo:"`, `"function foo"`, etc.) that all collapsed to bare-term searches at index time because Bitbucket strips punctuation other than `.` and `_`. Worse, the OR-expanded query overflowed the 250-character cap for any identifier roughly 16 characters or longer, returning a hard error. Removed in favor of raw query passthrough plus optional `regex_filter` post-filter.
147
+
148
+ - **Output bloat** — `formatCodeSearchOutput` printed every line in `hitContexts` (including blank lines, docstring fences, surrounding context) as `Line N: ...`, conflating actual hits with their surroundings. Replaced with a hit-only formatter that filters on Bitbucket's `<em>` markers.
149
+
150
+ - **Silent fetch failures** in file fan-outs were treated as "no match" and returned with confidence. Now tracked separately; `FETCH_FAILURES` warning includes counts and a sample of failing paths.
151
+
152
+ - **Inconsistent API path versions** — `listFiles` used `/rest/api/latest/...` while raw content used `/rest/api/1.0/...`. Unified to `latest`.
153
+
154
+ - **Filters JSON included `undefined` keys** — now stripped.
155
+
156
+ ### Notes
157
+
158
+ - The Bitbucket index itself has known coverage gaps that cannot be fixed from the MCP layer (e.g. some real source files are simply missing from the index even on the default branch, languages like Haskell appear unindexed in some installations). This release does not paper over those gaps; it makes them visible to the LLM via `INDEX_GAP_LIKELY` and provides `find_in_files` as a working recovery path.
159
+
160
+ ## [2.0.4] - 2026-04-21
161
+
162
+ ### Added
163
+ - **`get_file_blame` tool** — Per-line blame for a file: who last modified each line, the commit hash, author, and timestamp. Supports `branch`, `start_line`/`line_count` windowing, and `group_by_commit` to toggle between range-compressed output (default) and one-entry-per-line output. Feed the returned `commit_id` into `get_commit_detail` to see what actually changed. **Bitbucket Server only** — Bitbucket Cloud does not expose a blame API.
164
+
165
+ ## [2.0.3] - 2026-04-08
166
+
167
+ ### Added
168
+ - **`get_commit_detail` tool** — Get the diff for a specific commit (by SHA) with structured line-by-line information. Supports `context_lines`, `file_path`, `include_patterns`, and `exclude_patterns` filtering. Works on both Bitbucket Server (structured JSON response) and Bitbucket Cloud (unified diff with optional filtering).
169
+
170
+ ## [2.0.2] - 2026-03-29
171
+
172
+ ### Fixed
173
+ - **Validate `search_code` query length before calling Bitbucket API** — returns a clear error when the constructed query exceeds Bitbucket's 250-character limit, preventing a confusing API-level failure and showing the full constructed query to help users shorten their search
174
+
175
+ ## [2.0.1] - 2026-03-07
176
+
177
+ ### Fixed
178
+ - Republish to restore README display on npm registry page
179
+
180
+ ## [2.0.0] - 2026-03-07
181
+
182
+ ### BREAKING CHANGES
183
+
184
+ - **Merged 8 inverse-operation tool pairs into 4 unified tools** — any client or LLM prompt referencing the old tool names must be updated:
185
+
186
+ | Removed (old) | Replacement |
187
+ |---|---|
188
+ | `approve_pull_request` | `set_pr_approval` with `approved: true` |
189
+ | `unapprove_pull_request` | `set_pr_approval` with `approved: false` |
190
+ | `request_changes` | `set_review_status` with `request_changes: true` |
191
+ | `remove_requested_changes` | `set_review_status` with `request_changes: false` |
192
+ | `mark_pr_task_done` | `set_pr_task_status` with `done: true` |
193
+ | `unmark_pr_task_done` | `set_pr_task_status` with `done: false` |
194
+ | `convert_comment_to_task` | `convert_pr_item` with `direction: "to_task"` |
195
+ | `convert_task_to_comment` | `convert_pr_item` with `direction: "to_comment"` |
196
+
197
+ - **Removed fields from `list_pull_requests` response** — slim list format no longer includes `is_open`, `is_closed`, `api_url`, `description`. Use `get_pull_request` for full details.
198
+
199
+ - **Removed fields from `list_projects` / `list_repositories` responses** — `id`, `state`, `is_forkable`, `clone_urls` removed (not useful for LLM navigation).
200
+
201
+ - **Removed fields from commit responses** — `author.email` and `parents[]` removed from `FormattedCommit`. Use `is_merge_commit` boolean (retained) instead of checking `parents.length`.
202
+
203
+ - **Removed fields from file/directory responses** — `size` removed from `list_directory_content` entries; `size` and `encoding` removed from `get_file_content`; `workspace`, `repository`, `total_files_scanned` removed from `search_files`.
204
+
205
+ - **Removed fields from diff response** — `message`, `from_hash`, `to_hash` removed from `get_pull_request_diff` structured response.
206
+
207
+ ### Added
208
+
209
+ - **Tool group filtering via `BITBUCKET_TOOL_GROUPS` environment variable**:
210
+ - Set a comma-separated list of group names to expose only the tools your use case needs
211
+ - Groups: `pr_core`, `pr_comments`, `pr_review`, `pr_tasks`, `commits`, `branches`, `files`, `search`, `discovery`
212
+ - Example: `BITBUCKET_TOOL_GROUPS=pr_core,pr_review,files` exposes only 12 tools (~2,100 tokens) instead of all 29
213
+ - When unset, all applicable tools are exposed (default behaviour)
214
+
215
+ - **Automatic server-only tool filtering for Bitbucket Cloud**:
216
+ - When connected to Bitbucket Cloud, 10 server-only tools are automatically hidden from the LLM
217
+ - Cloud users see 21 tools instead of 29, saving ~1,100 tokens per request without any configuration
218
+ - Server-only tools: `list_pr_tasks`, `create_pr_task`, `update_pr_task`, `set_pr_task_status`, `delete_pr_task`, `convert_pr_item`, `list_branch_commits`, `search_code`, `search_repositories`, and `search_files`
219
+
220
+ - **Tool group metadata** on every tool definition (`group` + `availability` fields) for runtime filtering
221
+
222
+ ### Changed
223
+
224
+ - **Token usage reduced by ~25% (Server) to ~43% (Cloud)** in tool definition payload sent to LLM on every request:
225
+ - Before: 33 tools, ~6,800 tokens
226
+ - After (Server, all groups): 29 tools, ~5,100 tokens
227
+ - After (Cloud, auto-filtered): 21 tools, ~3,900 tokens
228
+ - After (minimal group preset): 12 tools, ~2,100 tokens
229
+
230
+ - **Shared parameter constants** (`W`, `R`, `PRID`, `BRANCH`, `LIMIT`, `START`, `TASK_ID`) used across all tool definitions to avoid repeating identical parameter descriptions
231
+
232
+ - **Compressed tool descriptions** — all tool and parameter descriptions trimmed to remove redundant wording while preserving full semantic meaning
233
+
234
+ - **Author filter in `list_branch_commits`** now matches by `author.name` only (email was removed from `FormattedCommit`)
235
+
236
+ ## [1.4.0] - 2026-01-28
237
+
238
+ ### Added
239
+
240
+ - **New `search_files` tool for finding files by name or path pattern**:
241
+ - Search for files using glob patterns (e.g., `*.ts`, `**/*Controller*`, `src/**/*.res`)
242
+ - Case-insensitive matching for user-friendly searches (like VS Code's Ctrl+P)
243
+ - Supports searching within specific subdirectories via `path` parameter
244
+ - Branch selection support to search files on any branch
245
+ - Configurable result limit (default: 100) with truncation indicator
246
+ - Returns comprehensive response with:
247
+ - Matched file paths
248
+ - Total files scanned in repository
249
+ - Total matches found
250
+ - Truncation status when results exceed limit
251
+ - Works with both Bitbucket Server and Cloud
252
+ - Uses Bitbucket Server's `/files` endpoint for efficient recursive file listing
253
+ - Client-side glob filtering using `minimatch` library
254
+
255
+ ### Technical Details
256
+
257
+ - Added `isSearchFilesArgs` type guard for input validation
258
+ - Added `handleSearchFiles` method to `FileHandlers` class
259
+ - Uses `minimatch` with `matchBase: true` and `nocase: true` options for flexible pattern matching
260
+ - Bitbucket Server: Single API call fetches all files recursively
261
+ - Bitbucket Cloud: Uses `/src` endpoint with `max_depth` parameter
262
+
263
+ ## [1.4.1] - 2026-02-23
264
+
265
+ ### Fixed
266
+
267
+ - **Pinned `minimatch` to `9.0.5` to avoid `9.0.6` runtime crash for `npx` consumers**
268
+ - Ensures registry installs do not pull the broken `9.0.6` release
269
+
270
+ ## [1.3.0] - 2026-01-25
271
+
272
+ ### Added
273
+
274
+ - **New `search_repositories` tool (Bitbucket Server only)**:
275
+ - Search for repositories by name or description across all accessible projects
276
+ - Optional filtering by project/workspace
277
+ - Uses Bitbucket Server's search API for efficient repository discovery
278
+ - Configurable result limit
279
+
280
+ - **New `decline_pull_request` tool**:
281
+ - Decline/reject a pull request with optional comment
282
+ - Works with both Bitbucket Server and Cloud
283
+ - Fetches current PR version automatically to handle optimistic locking
284
+
285
+ - **New `delete_comment` tool**:
286
+ - Delete a comment from a pull request
287
+ - Handles version tracking automatically
288
+ - Returns appropriate error for comments with replies (which cannot be deleted)
289
+ - Only comment author, PR author, or repo admin can delete comments
290
+
291
+ - **New PR Task Management tools (Bitbucket Server only)**:
292
+ - Tasks are checklist items on pull requests (implemented as BLOCKER severity comments)
293
+ - `list_pr_tasks` - List all tasks on a PR with open/resolved summary
294
+ - `create_pr_task` - Create a new task directly on a PR
295
+ - `update_pr_task` - Edit the text of an existing task
296
+ - `mark_pr_task_done` - Mark a task as resolved
297
+ - `unmark_pr_task_done` - Reopen a resolved task
298
+ - `delete_pr_task` - Delete a task from a PR
299
+ - `convert_comment_to_task` - Convert a regular comment to a task
300
+ - `convert_task_to_comment` - Convert a task back to a regular comment
301
+
302
+ ### Changed
303
+
304
+ - Enhanced `BitbucketServerSearchRequest` type to include `repositories` entity and `limits` for pagination
305
+ - Enhanced `BitbucketServerSearchResult` type to include repository search results
306
+ - Added new type guards for all new tools
307
+ - Updated README with comprehensive documentation for all new tools
308
+
309
+ ### Technical Details
310
+
311
+ - Tasks use `severity: "BLOCKER"` for tasks and `severity: "NORMAL"` for regular comments
312
+ - Task state can be `OPEN` or `RESOLVED`
313
+ - All task operations require version tracking for optimistic locking
314
+
315
+ ## [1.2.3] - 2026-01-20
316
+
317
+ ### Added
318
+ - **Structured diff response for `get_pull_request_diff` tool (Bitbucket Server)**:
319
+ - Returns structured JSON with line-by-line information instead of raw unified diff
320
+ - Each line includes `source_line`, `destination_line`, `type` (ADDED/REMOVED/CONTEXT), and `content`
321
+ - Files organized into hunks with start positions and spans
322
+ - Makes it easy for AI tools to add inline comments with correct line numbers
323
+ - Native file path filtering via Bitbucket API (added file path to URL)
324
+
325
+ ### Changed
326
+ - **Bitbucket Server now uses JSON API** (`Accept: application/json`) instead of text/plain for diff endpoint
327
+ - Response format changed from `{ diff: "raw diff string" }` to structured `{ files: [...] }` format
328
+ - Updated tool description to document structured response and line number usage
329
+ - Updated README with comprehensive documentation of new response format
330
+
331
+ ### How to Use for Inline Comments
332
+ | Line Type | Line Number to Use | `line_type` param |
333
+ |-----------|-------------------|-------------------|
334
+ | `ADDED` | `destination_line` | `"ADDED"` |
335
+ | `REMOVED` | `source_line` | `"REMOVED"` |
336
+ | `CONTEXT` | `destination_line` | `"CONTEXT"` |
337
+
338
+ ### Note
339
+ - Bitbucket Cloud continues to use raw diff format (unchanged)
340
+ - Glob pattern filtering (`include_patterns`/`exclude_patterns`) still works client-side
341
+
342
+ ## [1.1.3] - 2026-01-08
343
+
344
+ ### Fixed
345
+ - **Fixed username encoding for Bitbucket Server participant endpoints**:
346
+ - Usernames containing `+` characters (e.g., `user+1@domain.com`) are now properly converted to slug format
347
+ - Both `@` and `+` are replaced with `_` to match Bitbucket Server's user slug format
348
+ - Affects `approve_pull_request`, `unapprove_pull_request`, `request_changes`, and `remove_requested_changes` tools
349
+ - Previously, the `+` character would cause 404 errors when approving/requesting changes on PRs
350
+
351
+ ## [1.1.2] - 2025-10-14
352
+
353
+ ### Added
354
+ - **CI/CD build status support in `list_pr_commits` tool**:
355
+ - Added `include_build_status` optional parameter to fetch build/CI status for pull request commits
356
+ - Returns build status with counts: successful, failed, in_progress, and unknown builds
357
+ - Uses same Bitbucket Server UI API endpoint as `list_branch_commits` for consistency
358
+ - Graceful degradation: failures in fetching build status don't break commit listing
359
+ - Currently only supports Bitbucket Server (Cloud has different build status APIs)
360
+ - Useful for tracking CI/CD pipeline status for all commits in a pull request
361
+
362
+ ### Changed
363
+ - Enhanced README.md with comprehensive documentation for new v1.1.0 features:
364
+ - Added usage examples and documentation for `include_build_status` parameter in `list_branch_commits` tool
365
+ - Added complete documentation for `list_projects` tool with examples, parameters, and response format
366
+ - Added complete documentation for `list_repositories` tool with examples, parameters, and response format
367
+ - Improved feature list to include new Project and Repository Discovery Tools section
368
+
369
+ ## [1.1.0] - 2025-10-14
370
+
371
+ ### Added
372
+ - **CI/CD build status support in `list_branch_commits` tool**:
373
+ - Added `include_build_status` optional parameter to fetch build/CI status for commits
374
+ - Returns build status with counts: successful, failed, in_progress, and unknown builds
375
+ - Uses Bitbucket Server UI API endpoint for efficient batch fetching of build summaries
376
+ - Graceful degradation: failures in fetching build status don't break commit listing
377
+ - Currently only supports Bitbucket Server (Cloud has different build status APIs)
378
+ - Useful for tracking CI/CD pipeline status alongside commit history
379
+
380
+ - **New `list_projects` tool for project/workspace discovery**:
381
+ - List all accessible Bitbucket projects (Server) or workspaces (Cloud)
382
+ - Optional filtering by project name and permission level
383
+ - Returns project metadata: key, ID, name, description, visibility, and type
384
+ - Pagination support with `limit` and `start` parameters
385
+ - Works with both Bitbucket Server and Cloud with unified response format
386
+
387
+ - **New `list_repositories` tool for repository discovery**:
388
+ - List repositories within a specific project/workspace or across all accessible repos
389
+ - Optional filtering by repository name and permission level
390
+ - Returns comprehensive repository details:
391
+ - Basic info: slug, ID, name, description, state
392
+ - Project association: project key and name
393
+ - Clone URLs for both HTTP(S) and SSH
394
+ - Repository settings: visibility, forkable status
395
+ - Pagination support with `limit` and `start` parameters
396
+ - Bitbucket Cloud requires workspace parameter (documented in response)
397
+ - Bitbucket Server supports listing all accessible repos without workspace filter
398
+
399
+ ### Changed
400
+ - Added `ProjectHandlers` class following the modular architecture pattern
401
+ - Enhanced TypeScript interfaces with project and repository types:
402
+ - `BitbucketServerProject` and `BitbucketCloudProject`
403
+ - `BitbucketServerRepository` and `BitbucketCloudRepository`
404
+ - `BitbucketServerBuildSummary` and `BuildStatus`
405
+ - Added custom params serializer for multiple `commitId` parameters in build status API
406
+ - Enhanced `FormattedCommit` interface with optional `build_status` field
407
+ - Updated API client with `getBuildSummaries` method for batch build status fetching
408
+
409
+ ## [1.0.1] - 2025-08-08
410
+
411
+ ### Fixed
412
+ - **Improved search_code tool response formatting**:
413
+ - Added simplified `formatCodeSearchOutput` for cleaner AI consumption
414
+ - Enhanced HTML entity decoding (handles &quot;, &lt;, &gt;, &amp;, &#x2F;, &#x27;)
415
+ - Improved response structure showing file paths and line numbers clearly
416
+ - Removed HTML formatting tags for better readability
417
+
418
+ ### Changed
419
+ - Search results now use simplified formatter by default for better AI tool integration
420
+ - Enhanced query display to show actual search patterns used
421
+
422
+ ## [1.0.0] - 2025-07-25
423
+
424
+ ### Added
425
+ - **New `search_code` tool for searching code across repositories**:
426
+ - Search for code snippets, functions, or any text within Bitbucket repositories
427
+ - Supports searching within a specific repository or across all repositories in a workspace
428
+ - File path pattern filtering with glob patterns (e.g., `*.java`, `src/**/*.ts`)
429
+ - Returns matched lines with highlighted segments showing exact matches
430
+ - Pagination support for large result sets
431
+ - Currently only supports Bitbucket Server (Cloud API support planned for future)
432
+ - Added `SearchHandlers` class following the modular architecture pattern
433
+ - Added TypeScript interfaces for search requests and responses
434
+ - Added `formatSearchResults` formatter function for consistent output
435
+
436
+ ### Changed
437
+ - Major version bump to 1.0.0 indicating stable API with comprehensive feature set
438
+ - Enhanced documentation with search examples
439
+
440
+ ## [0.10.0] - 2025-07-03
441
+
442
+ ### Added
443
+ - **New `list_branch_commits` tool for retrieving commit history**:
444
+ - List all commits in a specific branch with detailed information
445
+ - Advanced filtering options:
446
+ - `since` and `until` parameters for date range filtering (ISO date strings)
447
+ - `author` parameter to filter by author email/username
448
+ - `include_merge_commits` parameter to include/exclude merge commits (default: true)
449
+ - `search` parameter to search in commit messages
450
+ - Returns branch head information and paginated commit list
451
+ - Each commit includes hash, message, author details, date, parents, and merge status
452
+ - Supports both Bitbucket Server and Cloud APIs with appropriate parameter mapping
453
+ - Useful for reviewing commit history, tracking changes, and analyzing branch activity
454
+
455
+ - **New `list_pr_commits` tool for pull request commits**:
456
+ - List all commits that are part of a specific pull request
457
+ - Returns PR title and paginated commit list
458
+ - Simpler than branch commits - focused specifically on PR changes
459
+ - Each commit includes same detailed information as branch commits
460
+ - Supports pagination with `limit` and `start` parameters
461
+ - Useful for reviewing all changes in a PR before merging
462
+
463
+ ### Changed
464
+ - Added new TypeScript interfaces for commit types:
465
+ - `BitbucketServerCommit` and `BitbucketCloudCommit` for API responses
466
+ - `FormattedCommit` for consistent commit representation
467
+ - Added formatter functions `formatServerCommit` and `formatCloudCommit` for unified output
468
+ - Enhanced type guards with `isListBranchCommitsArgs` and `isListPrCommitsArgs`
469
+
470
+ ## [0.9.1] - 2025-01-27
471
+
472
+ ### Fixed
473
+ - **Fixed `update_pull_request` reviewer preservation**:
474
+ - When updating a PR without specifying reviewers, existing reviewers are now preserved
475
+ - Previously, omitting the `reviewers` parameter would clear all reviewers
476
+ - Now properly includes existing reviewers in the API request when not explicitly updating them
477
+ - When updating reviewers, approval status is preserved for existing reviewers
478
+ - This prevents accidentally removing reviewers when only updating PR title or description
479
+
480
+ ### Changed
481
+ - Updated tool documentation to clarify reviewer behavior in `update_pull_request`
482
+ - Enhanced README with detailed explanation of reviewer handling
483
+
484
+ ## [0.9.0] - 2025-01-26
485
+
486
+ ### Added
487
+ - **Code snippet support in `add_comment` tool**:
488
+ - Added `code_snippet` parameter to find line numbers automatically using code text
489
+ - Added `search_context` parameter with `before` and `after` arrays to disambiguate multiple matches
490
+ - Added `match_strategy` parameter with options:
491
+ - `"strict"` (default): Fails with detailed error when multiple matches found
492
+ - `"best"`: Auto-selects the highest confidence match
493
+ - Returns detailed error with all occurrences when multiple matches found in strict mode
494
+ - Particularly useful for AI-powered code review tools that analyze diffs
495
+ - Created comprehensive line matching algorithm that:
496
+ - Parses diffs to find exact code snippets
497
+ - Calculates confidence scores based on context matching
498
+ - Handles added, removed, and context lines appropriately
499
+
500
+ ### Changed
501
+ - Enhanced `add_comment` tool to resolve line numbers from code snippets when `line_number` is not provided
502
+ - Improved error messages to include preview and suggestions for resolving ambiguous matches
503
+
504
+ ## [0.8.0] - 2025-01-26
505
+
506
+ ### Added
507
+ - **Code suggestions support in `add_comment` tool**:
508
+ - Added `suggestion` parameter to add code suggestions in comments
509
+ - Added `suggestion_end_line` parameter for multi-line suggestions
510
+ - Suggestions are formatted using GitHub-style markdown ````suggestion` blocks
511
+ - Works with both single-line and multi-line code replacements
512
+ - Requires `file_path` and `line_number` to be specified when using suggestions
513
+ - Compatible with both Bitbucket Cloud and Server
514
+ - Created `suggestion-formatter.ts` utility for formatting suggestion comments
515
+
516
+ ### Changed
517
+ - Enhanced `add_comment` tool to validate suggestion requirements
518
+ - Updated tool response to indicate when a comment contains a suggestion
519
+
520
+ ## [0.7.0] - 2025-01-26
521
+
522
+ ### Added
523
+ - **Enhanced `get_pull_request_diff` with filtering capabilities**:
524
+ - Added `include_patterns` parameter to filter diff by file patterns (whitelist)
525
+ - Added `exclude_patterns` parameter to exclude files from diff (blacklist)
526
+ - Added `file_path` parameter to get diff for a specific file only
527
+ - Patterns support standard glob syntax (e.g., `*.js`, `src/**/*.res`, `node_modules/**`)
528
+ - Response includes filtering metadata showing total files, included/excluded counts, and excluded file list
529
+ - Added `minimatch` dependency for glob pattern matching
530
+ - Created `DiffParser` utility class for parsing and filtering unified diff format
531
+
532
+ ### Changed
533
+ - Modified `get_pull_request_diff` tool to support optional filtering without breaking existing usage
534
+ - Updated tool definition and type guards to include new optional parameters
535
+ - Enhanced documentation with comprehensive examples of filtering usage
536
+
537
+ ## [0.6.1] - 2025-01-26
538
+
539
+ ### Added
540
+ - Support for nested comment replies in Bitbucket Server
541
+ - Added `replies` field to `FormattedComment` interface to support nested comment threads
542
+ - Comments now include nested replies that are still relevant (not orphaned or resolved)
543
+ - Total and active comment counts now include nested replies
544
+
545
+ ### Changed
546
+ - Updated comment fetching logic to handle Bitbucket Server's nested comment structure
547
+ - Server uses `comments` array inside each comment object for replies
548
+ - Cloud continues to use `parent` field for reply relationships
549
+ - Improved comment filtering to exclude orphaned inline comments when code has changed
550
+
551
+ ### Fixed
552
+ - Fixed missing comment replies in PR details - replies are now properly included in the response
553
+
554
+ ## [0.6.0] - 2025-01-26
555
+
556
+ ### Added
557
+ - **Enhanced `get_pull_request` with active comments and file changes**:
558
+ - Fetches and displays active (unresolved) comments that need attention
559
+ - Shows up to 20 most recent active comments with:
560
+ - Comment text, author, and creation date
561
+ - Inline comment details (file path and line number)
562
+ - Comment state (OPEN/RESOLVED for Server)
563
+ - Provides comment counts:
564
+ - `active_comment_count`: Total unresolved comments
565
+ - `total_comment_count`: Total comments including resolved
566
+ - Includes file change statistics:
567
+ - List of all modified files with lines added/removed
568
+ - File status (added, modified, removed, renamed)
569
+ - Summary statistics (total files, lines added/removed)
570
+ - Added new TypeScript interfaces for comments and file changes
571
+ - Added `FormattedComment` and `FormattedFileChange` types for consistent response format
572
+
573
+ ### Changed
574
+ - Modified `handleGetPullRequest` to make parallel API calls for better performance
575
+ - Enhanced error handling to gracefully continue if comment/file fetching fails
576
+
577
+ ## [0.5.0] - 2025-01-21
578
+
579
+ ### Added
580
+ - **New file and directory handling tools**:
581
+ - `list_directory_content` - List files and directories in any repository path
582
+ - Shows file/directory type, size, and full paths
583
+ - Supports browsing specific branches
584
+ - Works with both Bitbucket Server and Cloud APIs
585
+ - `get_file_content` - Retrieve file content with smart truncation for large files
586
+ - Automatic smart defaults by file type (config: 200 lines, docs: 300 lines, code: 500 lines)
587
+ - Pagination support with `start_line` and `line_count` parameters
588
+ - Tail functionality using negative `start_line` values (e.g., -50 for last 50 lines)
589
+ - Automatic truncation for files >50KB to prevent token overload
590
+ - Files >1MB require explicit `full_content: true` parameter
591
+ - Returns metadata including file size, encoding, and last modified info
592
+ - Added `FileHandlers` class following existing modular architecture patterns
593
+ - Added TypeScript interfaces for file/directory entries and metadata
594
+ - Added type guards `isListDirectoryContentArgs` and `isGetFileContentArgs`
595
+
596
+ ### Changed
597
+ - Enhanced documentation with comprehensive examples for file handling tools
598
+
599
+ ## [0.4.0] - 2025-01-21
600
+
601
+ ### Added
602
+ - **New `get_branch` tool for comprehensive branch information**:
603
+ - Returns detailed branch information including name, ID, and latest commit details
604
+ - Lists all open pull requests originating from the branch with approval status
605
+ - Optionally includes merged pull requests when `include_merged_prs` is true
606
+ - Provides useful statistics like PR counts and days since last commit
607
+ - Supports both Bitbucket Server and Cloud APIs
608
+ - Particularly useful for checking if a branch has open PRs before deletion
609
+ - Added TypeScript interfaces for `BitbucketServerBranch` and `BitbucketCloudBranch`
610
+ - Added type guard `isGetBranchArgs` for input validation
611
+
612
+ ### Changed
613
+ - Updated documentation to include the new `get_branch` tool with comprehensive examples
614
+
615
+ ## [0.3.0] - 2025-01-06
616
+
617
+ ### Added
618
+ - **Enhanced merge commit details in `get_pull_request`**:
619
+ - Added `merge_commit_hash` field for both Cloud and Server
620
+ - Added `merged_by` field showing who performed the merge
621
+ - Added `merged_at` timestamp for when the merge occurred
622
+ - Added `merge_commit_message` with the merge commit message
623
+ - For Bitbucket Server: Fetches merge details from activities API when PR is merged
624
+ - For Bitbucket Cloud: Extracts merge information from existing response fields
625
+
626
+ ### Changed
627
+ - **Major code refactoring for better maintainability**:
628
+ - Split monolithic `index.ts` into modular architecture
629
+ - Created separate handler classes for different tool categories:
630
+ - `PullRequestHandlers` for PR lifecycle operations
631
+ - `BranchHandlers` for branch management
632
+ - `ReviewHandlers` for code review tools
633
+ - Extracted types into dedicated files (`types/bitbucket.ts`, `types/guards.ts`)
634
+ - Created utility modules (`utils/api-client.ts`, `utils/formatters.ts`)
635
+ - Centralized tool definitions in `tools/definitions.ts`
636
+ - Improved error handling and API client abstraction
637
+ - Better separation of concerns between Cloud and Server implementations
638
+
639
+ ### Fixed
640
+ - Improved handling of merge commit information retrieval failures
641
+ - Fixed API parameter passing for GET requests across all handlers (was passing config as third parameter instead of fourth)
642
+ - Updated Bitbucket Server branch listing to use `/rest/api/latest/` endpoint with proper parameters
643
+ - Branch filtering now works correctly with the `filterText` parameter for Bitbucket Server
644
+
645
+ ## [0.2.0] - 2025-06-04
646
+
647
+ ### Added
648
+ - Complete implementation of all Bitbucket MCP tools
649
+ - Support for both Bitbucket Cloud and Server
650
+ - Core PR lifecycle tools:
651
+ - `create_pull_request` - Create new pull requests
652
+ - `update_pull_request` - Update PR details
653
+ - `merge_pull_request` - Merge pull requests
654
+ - `list_branches` - List repository branches
655
+ - `delete_branch` - Delete branches
656
+ - Enhanced `add_comment` with inline comment support
657
+ - Code review tools:
658
+ - `get_pull_request_diff` - Get PR diff/changes
659
+ - `approve_pull_request` - Approve PRs
660
+ - `unapprove_pull_request` - Remove approval
661
+ - `request_changes` - Request changes on PRs
662
+ - `remove_requested_changes` - Remove change requests
663
+ - npm package configuration for easy installation via npx
664
+
665
+ ### Fixed
666
+ - Author filter for Bitbucket Server (uses `role.1=AUTHOR` and `username.1=email`)
667
+ - Branch deletion handling for 204 No Content responses
668
+
669
+ ### Changed
670
+ - Package name to `@nexus2520/bitbucket-mcp-server` for npm publishing
671
+
672
+ ## [0.1.0] - 2025-06-03
673
+
674
+ ### Added
675
+ - Initial implementation with basic tools:
676
+ - `get_pull_request` - Get PR details
677
+ - `list_pull_requests` - List PRs with filters
678
+ - Support for Bitbucket Cloud with app passwords
679
+ - Support for Bitbucket Server with HTTP access tokens
680
+ - Authentication setup script
681
+ - Comprehensive documentation