@atercates/bitbucket-mcp 1.0.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 (77) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +347 -0
  3. package/dist/client.d.ts +16 -0
  4. package/dist/client.js +35 -0
  5. package/dist/client.js.map +1 -0
  6. package/dist/config.d.ts +11 -0
  7. package/dist/config.js +54 -0
  8. package/dist/config.js.map +1 -0
  9. package/dist/handlers/branching-model.d.ts +2 -0
  10. package/dist/handlers/branching-model.js +324 -0
  11. package/dist/handlers/branching-model.js.map +1 -0
  12. package/dist/handlers/commits.d.ts +2 -0
  13. package/dist/handlers/commits.js +78 -0
  14. package/dist/handlers/commits.js.map +1 -0
  15. package/dist/handlers/index.d.ts +17 -0
  16. package/dist/handlers/index.js +29 -0
  17. package/dist/handlers/index.js.map +1 -0
  18. package/dist/handlers/pipelines.d.ts +2 -0
  19. package/dist/handlers/pipelines.js +538 -0
  20. package/dist/handlers/pipelines.js.map +1 -0
  21. package/dist/handlers/pr-comments.d.ts +2 -0
  22. package/dist/handlers/pr-comments.js +509 -0
  23. package/dist/handlers/pr-comments.js.map +1 -0
  24. package/dist/handlers/pr-content.d.ts +2 -0
  25. package/dist/handlers/pr-content.js +332 -0
  26. package/dist/handlers/pr-content.js.map +1 -0
  27. package/dist/handlers/pr-tasks.d.ts +2 -0
  28. package/dist/handlers/pr-tasks.js +275 -0
  29. package/dist/handlers/pr-tasks.js.map +1 -0
  30. package/dist/handlers/pull-requests.d.ts +2 -0
  31. package/dist/handlers/pull-requests.js +902 -0
  32. package/dist/handlers/pull-requests.js.map +1 -0
  33. package/dist/handlers/refs.d.ts +2 -0
  34. package/dist/handlers/refs.js +225 -0
  35. package/dist/handlers/refs.js.map +1 -0
  36. package/dist/handlers/repositories.d.ts +2 -0
  37. package/dist/handlers/repositories.js +131 -0
  38. package/dist/handlers/repositories.js.map +1 -0
  39. package/dist/handlers/source.d.ts +2 -0
  40. package/dist/handlers/source.js +35 -0
  41. package/dist/handlers/source.js.map +1 -0
  42. package/dist/handlers/types.d.ts +42 -0
  43. package/dist/handlers/types.js +2 -0
  44. package/dist/handlers/types.js.map +1 -0
  45. package/dist/handlers/users.d.ts +2 -0
  46. package/dist/handlers/users.js +38 -0
  47. package/dist/handlers/users.js.map +1 -0
  48. package/dist/index.d.ts +2 -0
  49. package/dist/index.js +4 -0
  50. package/dist/index.js.map +1 -0
  51. package/dist/logger.d.ts +3 -0
  52. package/dist/logger.js +60 -0
  53. package/dist/logger.js.map +1 -0
  54. package/dist/pagination.d.ts +32 -0
  55. package/dist/pagination.js +116 -0
  56. package/dist/pagination.js.map +1 -0
  57. package/dist/schemas.d.ts +21 -0
  58. package/dist/schemas.js +23 -0
  59. package/dist/schemas.js.map +1 -0
  60. package/dist/server.d.ts +33 -0
  61. package/dist/server.js +124 -0
  62. package/dist/server.js.map +1 -0
  63. package/dist/types.d.ts +296 -0
  64. package/dist/types.js +3 -0
  65. package/dist/types.js.map +1 -0
  66. package/dist/utils.d.ts +18 -0
  67. package/dist/utils.js +17 -0
  68. package/dist/utils.js.map +1 -0
  69. package/docs/README.md +216 -0
  70. package/docs/TOOLS.md +464 -0
  71. package/docs/architecture/ARCHITECTURE.md +302 -0
  72. package/docs/guides/ENVIRONMENT_VARIABLES.md +306 -0
  73. package/docs/guides/GETTING_STARTED.md +267 -0
  74. package/docs/guides/GITHUB_ACTIONS_SETUP.md +148 -0
  75. package/docs/guides/NPM_DEPLOYMENT.md +266 -0
  76. package/docs/guides/PROJECT_STRUCTURE.md +317 -0
  77. package/package.json +84 -0
@@ -0,0 +1,317 @@
1
+ # Project Structure & Configuration Files
2
+
3
+ This guide explains the purpose of important configuration files and directories in the Bitbucket MCP project.
4
+
5
+ ## Core Directories
6
+
7
+ ### `src/`
8
+ The source code for the MCP server.
9
+
10
+ - **`index.ts`** - Entry point. Loads configuration and starts the MCP server
11
+ - **`server.ts`** - Main MCP server setup, tool registration, and request routing
12
+ - **`client.ts`** - Bitbucket API client wrapper using Axios with pagination support
13
+ - **`config.ts`** - Environment variable parsing and URL normalization
14
+ - **`logger.ts`** - Winston-based file logging setup
15
+ - **`types.ts`** - TypeScript interfaces for Bitbucket API entities
16
+ - **`schemas.ts`** - Shared JSON schemas for pagination
17
+ - **`utils.ts`** - Helper functions (response formatting, etc.)
18
+ - **`pagination.ts`** - Custom pagination handler for Bitbucket API
19
+ - **`handlers/`** - Feature modules (repositories, pull-requests, pipelines, etc.)
20
+
21
+ ### `dist/`
22
+ Compiled JavaScript output from TypeScript. Generated by `pnpm build`. Executed via `pnpm start`.
23
+
24
+ ### `__tests__/`
25
+ Test files (Vitest format). Mirrors the `src/` structure for easy navigation.
26
+
27
+ ### `docs/`
28
+ User-facing documentation:
29
+ - `README.md` - Documentation index
30
+ - `TOOLS.md` - Complete 59-tool reference with examples
31
+ - `guides/` - Setup, deployment, environment variables, this file
32
+ - `architecture/` - Technical design and extension guide
33
+
34
+ ---
35
+
36
+ ## Configuration Files
37
+
38
+ ### `server.json`
39
+ **Purpose:** MCP server metadata and configuration schema.
40
+
41
+ **Contents:**
42
+ - `$schema` - Points to official MCP schema for validation
43
+ - `name` - Unique identifier (e.g., `io.github.bitbucket-mcp/bitbucket-mcp`)
44
+ - `title` - Display name ("Bitbucket MCP")
45
+ - `description` - Server description
46
+ - `version` - Package version (synced from `package.json`)
47
+ - `packages` - NPM package info for registry discovery
48
+
49
+ **When used:**
50
+ - MCP clients (Cursor, Claude) read this to understand how to invoke the server
51
+ - Used by the official MCP registry for discoverability
52
+ - Validated by `scripts/validate-server-json.mjs`
53
+
54
+ **Do NOT edit manually.** The version is synced automatically from `package.json` during builds.
55
+
56
+ ---
57
+
58
+ ## Registry Directory
59
+
60
+ ### `registry/`
61
+ Contains manifest for MCP registry integration.
62
+
63
+ #### `bitbucket-mcp.manifest.json`
64
+ **Purpose:** Metadata for the official MCP registry (GitHub's model-context-protocol/registry).
65
+
66
+ **Contents:**
67
+ - `name`, `slug`, `version` - Basic metadata
68
+ - `description`, `homepage`, `repository` - Project links
69
+ - `license`, `author`, `keywords` - Licensing and discovery
70
+ - `icon` - Bitbucket favicon
71
+ - `transport` - Communication protocol (`stdio`)
72
+ - `startCommand` - How to launch the server (`node dist/index.js`)
73
+ - `configSchema` - JSON Schema defining all environment variable options
74
+
75
+ **When used:**
76
+ - When the MCP registry processes your server submission
77
+ - Consumed by MCP clients to show available configuration options
78
+ - Helps users understand what environment variables they need
79
+
80
+ **Generated by:** `scripts/generate-registry-manifest.cjs` (runs automatically)
81
+
82
+ **Example client usage:**
83
+ ```json
84
+ {
85
+ "mcpServers": {
86
+ "bitbucket": {
87
+ "command": "npx",
88
+ "args": ["-y", "bitbucket-mcp@latest"],
89
+ "env": {
90
+ "BITBUCKET_TOKEN": "app_password_here",
91
+ "BITBUCKET_WORKSPACE": "my-workspace"
92
+ }
93
+ }
94
+ }
95
+ }
96
+ ```
97
+
98
+ ---
99
+
100
+ ## Scripts Directory
101
+
102
+ ### `scripts/`
103
+ Build and validation utilities.
104
+
105
+ #### `generate-registry-manifest.cjs`
106
+ **Purpose:** Automatically generate `registry/bitbucket-mcp.manifest.json` from `package.json`.
107
+
108
+ **What it does:**
109
+ 1. Reads `package.json` (version, description, repository, etc.)
110
+ 2. Merges with hardcoded registry metadata (icon, transport, startCommand)
111
+ 3. Writes to `registry/bitbucket-mcp.manifest.json`
112
+
113
+ **When it runs:**
114
+ - Manually: `node scripts/generate-registry-manifest.cjs`
115
+ - Automatically as part of the build process (via `package.json` scripts)
116
+
117
+ **Why it exists:**
118
+ - Single source of truth: package.json is the authority
119
+ - Prevents version mismatches between NPM and registry
120
+ - Ensures metadata is always up-to-date
121
+
122
+ **Do NOT edit** `registry/bitbucket-mcp.manifest.json` directly. Edit `package.json` instead, then regenerate.
123
+
124
+ #### `validate-server-json.mjs`
125
+ **Purpose:** Validate `server.json` against the official MCP server schema.
126
+
127
+ **What it does:**
128
+ 1. Reads `server.json`
129
+ 2. Fetches the official MCP server schema from `static.modelcontextprotocol.io`
130
+ 3. Validates JSON structure and field types
131
+ 4. Reports validation errors
132
+
133
+ **When it runs:**
134
+ - Manually: `node scripts/validate-server-json.mjs`
135
+ - Automatically as part of CI/CD (GitHub Actions)
136
+
137
+ **Why it exists:**
138
+ - Ensures your `server.json` is compatible with MCP clients
139
+ - Catches configuration errors before deployment
140
+ - Guarantees registry acceptance
141
+
142
+ **Example output:**
143
+ ```
144
+ ✓ server.json is valid against the schema.
145
+ ```
146
+
147
+ ---
148
+
149
+ ## Package Management Files
150
+
151
+ ### `package.json`
152
+ Main Node.js configuration.
153
+
154
+ **Key sections:**
155
+ - `version` - Current semantic version (5.0.6)
156
+ - `name` - NPM package name (`bitbucket-mcp`)
157
+ - `description` - Short project description
158
+ - `main` - Entry point for imports (`dist/index.js`)
159
+ - `bin` - CLI command mapping (`bitbucket-mcp` → `dist/index.js`)
160
+ - `type` - Module system (`module` = ESM)
161
+ - `scripts` - Development and build commands
162
+ - `dependencies` - Production dependencies
163
+ - `devDependencies` - Development tools (TypeScript, Vitest, ESLint, etc.)
164
+ - `files` - Files included in NPM package
165
+
166
+ **Important scripts:**
167
+ - `build` - Compile TypeScript to `dist/`
168
+ - `dev` - Run in development mode with watch
169
+ - `start` - Run compiled server
170
+ - `test` - Run Vitest suite
171
+ - `lint` - Check code with ESLint
172
+ - `format` - Format code with Prettier
173
+ - `inspector` - Launch MCP inspector for debugging
174
+
175
+ ### `pnpm-lock.yaml`
176
+ Lockfile for reproducible builds with pnpm (like `package-lock.json` for npm).
177
+
178
+ ### `pnpm-workspace.yaml`
179
+ Workspace configuration (if using monorepo structure). Currently minimal.
180
+
181
+ ---
182
+
183
+ ## Build & Compilation Files
184
+
185
+ ### `tsconfig.json`
186
+ TypeScript compiler configuration.
187
+
188
+ **Key settings:**
189
+ - `module` - Output module format (`esnext` = modern JS)
190
+ - `target` - JavaScript version (`es2020`)
191
+ - `strict` - Strict type checking enabled
192
+ - `skipLibCheck` - Skip type checking of dependencies
193
+ - `include` - Files to compile (`src/**/*`)
194
+ - `exclude` - Files to ignore (`node_modules`, `dist`, `__tests__`)
195
+
196
+ ### `vitest.config.ts`
197
+ Vitest test runner configuration.
198
+
199
+ **Key settings:**
200
+ - `environment: "node"` - Run tests in Node.js (not browser)
201
+ - `globals: true` - No need to import test functions
202
+
203
+ ### `eslint.config.js`
204
+ ESLint code quality configuration (flat config format).
205
+
206
+ **What it checks:**
207
+ - TypeScript syntax errors
208
+ - Unused variables
209
+ - Proper function signatures
210
+ - Naming conventions
211
+
212
+ ### `.prettierrc`
213
+ Code formatting configuration.
214
+
215
+ **Settings:**
216
+ - Semicolons at end of lines
217
+ - Double quotes for strings
218
+ - 2-space indentation
219
+ - Trailing commas where valid
220
+
221
+ ---
222
+
223
+ ## Deployment & CI/CD
224
+
225
+ ### `.github/workflows/publish-mcp.yml`
226
+ GitHub Actions workflow for automated NPM publishing.
227
+
228
+ **What it does:**
229
+ 1. Runs on version tags (e.g., `v5.0.6`)
230
+ 2. Installs dependencies with pnpm
231
+ 3. Builds and tests the project
232
+ 4. Publishes to NPM registry
233
+ 5. Updates the official MCP registry
234
+
235
+ ### `Dockerfile`
236
+ Containerized deployment configuration.
237
+
238
+ **Usage:**
239
+ ```bash
240
+ docker build -t bitbucket-mcp .
241
+ docker run -e BITBUCKET_TOKEN=... bitbucket-mcp
242
+ ```
243
+
244
+ ### `DEPLOYMENT.txt`
245
+ Quick reference for deployment steps and environment setup.
246
+
247
+ ---
248
+
249
+ ## Application Metadata
250
+
251
+ ### `server.json` vs `registry/bitbucket-mcp.manifest.json`
252
+
253
+ | File | Purpose | Audience | Auto-generated |
254
+ |------|---------|----------|---|
255
+ | `server.json` | MCP client configuration | MCP clients (Cursor, Claude) | Yes (version synced) |
256
+ | `registry/bitbucket-mcp.manifest.json` | MCP registry metadata | MCP registry, discoverability | Yes (from package.json) |
257
+
258
+ **Workflow:**
259
+ 1. You update `package.json` version
260
+ 2. CI/CD regenerates both files
261
+ 3. MCP clients read `server.json`
262
+ 4. Registry reads manifest file
263
+ 5. Users discover via registry
264
+
265
+ ---
266
+
267
+ ## What You Can Delete (If Unnecessary)
268
+
269
+ ❌ **DO NOT DELETE:**
270
+ - `server.json` - Required for MCP protocol
271
+ - `registry/bitbucket-mcp.manifest.json` - Required for registry
272
+ - `scripts/*.mjs` - Used in build/validation pipeline
273
+ - `package.json` - Project metadata
274
+ - `tsconfig.json` - TypeScript compilation
275
+
276
+ ✅ **SAFE TO DELETE (if not using):**
277
+ - `Dockerfile` - Only if not deploying to containers
278
+ - `.github/workflows/` - Only if not using GitHub Actions
279
+ - `DEPLOYMENT.txt` - Only if you have separate deployment docs
280
+
281
+ ---
282
+
283
+ ## Environment Variables Required for Deployment
284
+
285
+ When deploying to NPM, you need these environment variables:
286
+
287
+ ### GitHub Actions (for automated publishing)
288
+ ```bash
289
+ NPM_TOKEN=npm_... # NPM authentication token
290
+ GITHUB_TOKEN=ghp_... # GitHub API token (usually auto-provided)
291
+ ```
292
+
293
+ ### Local Development
294
+ ```bash
295
+ BITBUCKET_TOKEN=... # Your app password
296
+ BITBUCKET_WORKSPACE=... # Your Bitbucket workspace
297
+ ```
298
+
299
+ See [ENVIRONMENT_VARIABLES.md](ENVIRONMENT_VARIABLES.md) for complete reference.
300
+
301
+ ---
302
+
303
+ ## Summary
304
+
305
+ | Directory/File | Purpose | Who Edits It | Auto-Generated |
306
+ |---|---|---|---|
307
+ | `src/` | Source code | You | ❌ |
308
+ | `dist/` | Compiled JS | Build system | ✅ |
309
+ | `__tests__/` | Tests | You | ❌ |
310
+ | `docs/` | Documentation | You | ❌ |
311
+ | `server.json` | MCP config | Version auto-synced | ⚠️ |
312
+ | `registry/*.json` | Registry metadata | Generated from package.json | ✅ |
313
+ | `scripts/` | Build utilities | You (rarely) | ❌ |
314
+ | `package.json` | Dependencies & metadata | You | ❌ |
315
+ | `tsconfig.json` | TypeScript config | You (rarely) | ❌ |
316
+ | `.github/workflows/` | CI/CD automation | You (rarely) | ❌ |
317
+
package/package.json ADDED
@@ -0,0 +1,84 @@
1
+ {
2
+ "name": "@atercates/bitbucket-mcp",
3
+ "version": "1.0.0",
4
+ "description": "Model Context Protocol (MCP) server for Bitbucket Cloud and Server API integration",
5
+ "mcpName": "io.github.bitbucket-mcp/bitbucket-mcp",
6
+ "type": "module",
7
+ "private": false,
8
+ "main": "dist/index.js",
9
+ "bin": {
10
+ "bitbucket-mcp": "dist/index.js"
11
+ },
12
+ "files": [
13
+ "dist",
14
+ "README.md",
15
+ "LICENSE",
16
+ "docs"
17
+ ],
18
+ "keywords": [
19
+ "bitbucket",
20
+ "bitbucket-cloud",
21
+ "bitbucket-server",
22
+ "mcp",
23
+ "model-context-protocol",
24
+ "ai",
25
+ "llm"
26
+ ],
27
+ "author": "Bitbucket MCP Team",
28
+ "license": "MIT",
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "git+https://github.com/atercates/bitbucket-mcp"
32
+ },
33
+ "homepage": "https://github.com/atercates/bitbucket-mcp#readme",
34
+ "bugs": {
35
+ "url": "https://github.com/atercates/bitbucket-mcp/issues"
36
+ },
37
+ "dependencies": {
38
+ "@modelcontextprotocol/sdk": "1.27.1",
39
+ "axios": "^1.13.6",
40
+ "winston": "^3.19.0",
41
+ "zod": "^4.3.6"
42
+ },
43
+ "devDependencies": {
44
+ "@eslint/js": "^10.0.1",
45
+ "@types/express": "^5.0.6",
46
+ "@types/node": "^25.5.0",
47
+ "ajv": "^8.18.0",
48
+ "ajv-formats": "^3.0.1",
49
+ "eslint": "^9.39.4",
50
+ "eslint-config-prettier": "^10.1.8",
51
+ "eslint-plugin-prettier": "^5.5.5",
52
+ "prettier": "^3.8.1",
53
+ "tsx": "^4.21.0",
54
+ "typescript": "^5.8.3",
55
+ "typescript-eslint": "^8.57.2",
56
+ "vitest": "^4.1.1"
57
+ },
58
+ "engines": {
59
+ "node": ">=18"
60
+ },
61
+ "publishConfig": {
62
+ "access": "public"
63
+ },
64
+ "scripts": {
65
+ "build": "tsc && chmod +x dist/index.js",
66
+ "start": "node dist/index.js",
67
+ "dev": "tsx watch src/index.ts",
68
+ "version": "git add -A src",
69
+ "postversion": "git push && git push --tags",
70
+ "publish:patch": "pnpm version patch && pnpm publish",
71
+ "publish:minor": "pnpm version minor && pnpm publish",
72
+ "publish:major": "pnpm version major && pnpm publish",
73
+ "release": "pnpm publish:patch",
74
+ "test": "vitest run",
75
+ "test:watch": "vitest",
76
+ "lint": "eslint src",
77
+ "lint:fix": "eslint src --fix",
78
+ "format": "prettier --write \"src/**/*.ts\"",
79
+ "format:check": "prettier --check \"src/**/*.ts\"",
80
+ "inspector": "pnpm dlx @modelcontextprotocol/inspector dist/index.js",
81
+ "registry:manifest": "node scripts/generate-registry-manifest.cjs",
82
+ "registry:validate": "node scripts/validate-server-json.mjs"
83
+ }
84
+ }