@atercates/bitbucket-mcp 1.0.0 → 1.0.1

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.
@@ -0,0 +1,169 @@
1
+ # Guía de Setup: Trusted Publishing con NPM + GitHub Actions
2
+
3
+ ## Qué es Trusted Publishing
4
+
5
+ Trusted Publishing permite publicar paquetes en npm **sin tokens secretos** (NPM_TOKEN). Usa OIDC (OpenID Connect) para que GitHub Actions se autentique directamente con npm, eliminando el riesgo de tokens expuestos o robados.
6
+
7
+ ---
8
+
9
+ ## Paso 1: Configurar Trusted Publishing en npmjs.com
10
+
11
+ 1. Inicia sesión en [npmjs.com](https://www.npmjs.com)
12
+ 2. Ve a tu paquete: `@atercates/bitbucket-mcp`
13
+ 3. Haz clic en **Settings** (pestaña)
14
+ 4. Busca la sección **Publishing access** → **Trusted Publisher**
15
+ 5. Rellena los campos **exactamente** así:
16
+
17
+ | Campo | Valor |
18
+ |-------|-------|
19
+ | **Repository owner** | `atercates` |
20
+ | **Repository name** | `bitbucket-mcp` |
21
+ | **Workflow filename** | `auto-publish.yml` |
22
+ | **Environment** | *(dejar vacío)* |
23
+
24
+ 6. Haz clic en **Add** o **Save**
25
+
26
+ > **IMPORTANTE**: Los valores deben coincidir exactamente con tu repositorio y nombre del archivo del workflow. Si alguno no coincide, la autenticación OIDC fallará.
27
+
28
+ ---
29
+
30
+ ## Paso 2: Limpiar secretos obsoletos (si los hay)
31
+
32
+ Si tenías un `NPM_TOKEN` configurado como secreto en GitHub:
33
+
34
+ 1. Ve a tu repo en GitHub → **Settings** → **Secrets and variables** → **Actions**
35
+ 2. **Elimina** el secreto `NPM_TOKEN` (interfiere con OIDC)
36
+
37
+ > Con Trusted Publishing ya no necesitas ningún token de npm. El workflow se autentica automáticamente vía OIDC.
38
+
39
+ ---
40
+
41
+ ## Paso 3: Verificar el workflow
42
+
43
+ El archivo `.github/workflows/auto-publish.yml` necesita estos elementos clave:
44
+
45
+ ### Permisos requeridos
46
+
47
+ ```yaml
48
+ permissions:
49
+ contents: write # Para crear tags y releases
50
+ id-token: write # Para generar tokens OIDC (CRÍTICO)
51
+ ```
52
+
53
+ ### setup-node con registry-url
54
+
55
+ ```yaml
56
+ - uses: actions/setup-node@v4
57
+ with:
58
+ node-version: '20'
59
+ registry-url: 'https://registry.npmjs.org' # Obligatorio para OIDC
60
+ ```
61
+
62
+ ### npm actualizado (>= 11.5.1)
63
+
64
+ ```yaml
65
+ - name: Upgrade npm for OIDC support
66
+ run: npm install -g npm@latest
67
+ ```
68
+
69
+ ### Comando de publicación
70
+
71
+ ```yaml
72
+ - name: Publish to npm
73
+ run: pnpm publish --provenance --access public --no-git-checks
74
+ ```
75
+
76
+ Flags importantes:
77
+ - `--provenance`: Genera atestación de procedencia (vincula el paquete al commit exacto)
78
+ - `--access public`: Necesario para paquetes con scope (`@atercates/...`)
79
+ - `--no-git-checks`: Evita que pnpm valide el estado git (ya lo controlamos nosotros)
80
+
81
+ > **NO** uses `NODE_AUTH_TOKEN` ni `NPM_TOKEN` como variable de entorno en el paso de publicación. OIDC maneja la autenticación automáticamente.
82
+
83
+ ---
84
+
85
+ ## Paso 4: Verificar que funciona
86
+
87
+ 1. Haz un cambio en `src/` y push a `master`
88
+ 2. Ve a **Actions** en tu repo de GitHub
89
+ 3. El workflow "Build, Test & Auto-Publish" debería ejecutarse
90
+ 4. Verifica que el paso "Publish to npm" muestre algo como:
91
+
92
+ ```
93
+ npm notice Publishing to https://registry.npmjs.org/ with tag latest and provenance
94
+ ```
95
+
96
+ 5. En npmjs.com, tu paquete debería mostrar un badge de **Provenance** verde
97
+
98
+ ---
99
+
100
+ ## Flujo del Pipeline
101
+
102
+ ```
103
+ Push a master (cambios en src/)
104
+
105
+ ├── Job: build-and-test
106
+ │ ├── Install dependencies
107
+ │ ├── Lint
108
+ │ ├── Test
109
+ │ └── Build
110
+
111
+ └── Job: publish (necesita build-and-test exitoso)
112
+ ├── Checkout con historial completo
113
+ ├── Setup Node + registry npm
114
+ ├── Detectar si hay cambios desde último tag
115
+ ├── Bump versión patch en package.json
116
+ ├── Publicar con OIDC + provenance
117
+ ├── Push commit de versión + tag
118
+ └── Crear GitHub Release
119
+ ```
120
+
121
+ ---
122
+
123
+ ## Errores comunes y soluciones
124
+
125
+ ### `npm error code ENEEDAUTH`
126
+ - **Causa**: Falta `registry-url` en setup-node, o npm < 11.5.1
127
+ - **Solución**: Verifica que `registry-url: 'https://registry.npmjs.org'` está configurado y que ejecutas `npm install -g npm@latest`
128
+
129
+ ### `Trusted publishing configuration mismatch`
130
+ - **Causa**: Los datos en npmjs.com no coinciden con el workflow
131
+ - **Solución**: Verifica que owner, repo, workflow filename y environment coincidan exactamente
132
+
133
+ ### `npm error code E403 - Forbidden`
134
+ - **Causa**: Token NPM_TOKEN interfiriendo con OIDC, o el paquete no tiene Trusted Publisher configurado
135
+ - **Solución**: Elimina NPM_TOKEN de secrets y verifica la configuración en npmjs.com
136
+
137
+ ### `npm warn publish Skipping provenance`
138
+ - **Causa**: El runner no es GitHub-hosted, o falta `id-token: write`
139
+ - **Solución**: Verifica los permisos del workflow y que usas `ubuntu-latest`
140
+
141
+ ### El workflow se ejecuta pero no publica
142
+ - **Causa**: No hay cambios en `src/` desde el último tag
143
+ - **Solución**: El workflow solo publica cuando detecta cambios en código fuente. Es el comportamiento esperado.
144
+
145
+ ---
146
+
147
+ ## Publicación manual (local)
148
+
149
+ Si necesitas publicar manualmente desde tu máquina:
150
+
151
+ ```bash
152
+ # Necesitas estar autenticado en npm: npm login
153
+ pnpm version patch
154
+ pnpm publish --access public
155
+ git push && git push --tags
156
+ ```
157
+
158
+ > Nota: La publicación local NO genera provenance. Solo GitHub Actions con OIDC lo hace.
159
+
160
+ ---
161
+
162
+ ## Checklist final
163
+
164
+ - [ ] Trusted Publisher configurado en npmjs.com con los datos exactos del repo
165
+ - [ ] No hay `NPM_TOKEN` en los secrets de GitHub Actions
166
+ - [ ] El workflow tiene `id-token: write` en permissions
167
+ - [ ] `setup-node` tiene `registry-url: 'https://registry.npmjs.org'`
168
+ - [ ] El comando publish usa `--provenance --access public`
169
+ - [ ] npm se actualiza a >= 11.5.1 en el workflow
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atercates/bitbucket-mcp",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Model Context Protocol (MCP) server for Bitbucket Cloud and Server API integration",
5
5
  "mcpName": "io.github.bitbucket-mcp/bitbucket-mcp",
6
6
  "type": "module",
@@ -28,11 +28,11 @@
28
28
  "license": "MIT",
29
29
  "repository": {
30
30
  "type": "git",
31
- "url": "git+https://github.com/atercates/bitbucket-mcp"
31
+ "url": "git+https://github.com/ATERCATES/bitbucket-mcp"
32
32
  },
33
- "homepage": "https://github.com/atercates/bitbucket-mcp#readme",
33
+ "homepage": "https://github.com/ATERCATES/bitbucket-mcp#readme",
34
34
  "bugs": {
35
- "url": "https://github.com/atercates/bitbucket-mcp/issues"
35
+ "url": "https://github.com/ATERCATES/bitbucket-mcp/issues"
36
36
  },
37
37
  "dependencies": {
38
38
  "@modelcontextprotocol/sdk": "1.27.1",
@@ -1,306 +0,0 @@
1
- # Environment Variables Reference
2
-
3
- Complete list of environment variables needed to configure and deploy the Bitbucket MCP server.
4
-
5
- ## Authentication (Required - Select One)
6
-
7
- ### Token Authentication (Recommended)
8
-
9
- ```bash
10
- # App password from Bitbucket
11
- BITBUCKET_TOKEN=your_app_password_here
12
- ```
13
-
14
- **How to get:**
15
- 1. Go to https://bitbucket.org/account/settings/app-passwords/
16
- 2. Click "Create app password"
17
- 3. Select permissions: Pipelines:Read, Repositories:Read+Write, Pull requests:Read+Write
18
- 4. Copy the generated password
19
-
20
- ### Basic Authentication
21
-
22
- ```bash
23
- # Email and app password
24
- BITBUCKET_USERNAME=your_email@example.com
25
- BITBUCKET_PASSWORD=your_app_password_here
26
- ```
27
-
28
- ## Server Configuration (Optional)
29
-
30
- ```bash
31
- # API base URL (defaults to Bitbucket Cloud)
32
- BITBUCKET_URL=https://api.bitbucket.org/2.0
33
-
34
- # For self-hosted Bitbucket Server:
35
- BITBUCKET_URL=https://bitbucket.mycompany.com/rest/api/2.0
36
-
37
- # Default workspace (auto-extracted if not set)
38
- BITBUCKET_WORKSPACE=my-workspace
39
-
40
- # Allow dangerous operations (delete branch, delete tag, etc.)
41
- BITBUCKET_ALLOW_DANGEROUS=true # default: false
42
- ```
43
-
44
- ## Logging Configuration (Optional)
45
-
46
- ```bash
47
- # Disable file-based logging
48
- BITBUCKET_LOG_DISABLE=true
49
-
50
- # Custom log file path
51
- BITBUCKET_LOG_FILE=/var/log/bitbucket-mcp/server.log
52
-
53
- # Custom log directory
54
- BITBUCKET_LOG_DIR=/var/log/bitbucket-mcp
55
-
56
- # Create per-working-directory subdirectories
57
- BITBUCKET_LOG_PER_CWD=true
58
- ```
59
-
60
- ## NPM Publishing (Deployment)
61
-
62
- ### Local Deployment
63
-
64
- ```bash
65
- # npm account credentials
66
- # These are configured via: npm login
67
- # Stored in: ~/.npmrc (do NOT commit)
68
- ```
69
-
70
- ### CI/CD Deployment (GitHub Actions, etc.)
71
-
72
- ```bash
73
- # npm access token for automation
74
- NPM_TOKEN=npm_your_token_here_1234567890
75
-
76
- # or use npm credentials
77
- NPM_USERNAME=your_npm_username
78
- NPM_PASSWORD=your_npm_password
79
- NPM_EMAIL=your_email@example.com
80
- ```
81
-
82
- **How to get NPM_TOKEN:**
83
- 1. Go to https://www.npmjs.com/settings/~/tokens
84
- 2. Click "Generate New Token"
85
- 3. Select type: "Automation" (for CI/CD)
86
- 4. Copy the token
87
- 5. Add to GitHub Secrets as `NPM_TOKEN`
88
-
89
- ## Development Environment
90
-
91
- ```bash
92
- # Development mode (use tsx watch)
93
- NODE_ENV=development
94
- pnpm dev
95
-
96
- # Production build
97
- NODE_ENV=production
98
- pnpm build
99
- pnpm start
100
- ```
101
-
102
- ## Complete Example: Local Setup
103
-
104
- ```bash
105
- # Step 1: Create app password on Bitbucket
106
- # Go to https://bitbucket.org/account/settings/app-passwords/
107
-
108
- # Step 2: Set environment variables
109
- export BITBUCKET_TOKEN="your_app_password"
110
- export BITBUCKET_WORKSPACE="my-workspace"
111
-
112
- # Optional: Enable logging
113
- export BITBUCKET_LOG_DISABLE=false
114
-
115
- # Optional: Allow dangerous operations
116
- export BITBUCKET_ALLOW_DANGEROUS=true
117
-
118
- # Step 3: Run the server
119
- pnpm start
120
- # OR
121
- npx -y bitbucket-mcp@latest
122
- ```
123
-
124
- ## Complete Example: Docker Deployment
125
-
126
- ```dockerfile
127
- FROM node:18-alpine
128
- WORKDIR /app
129
- COPY . .
130
- RUN pnpm install && pnpm build
131
-
132
- ENV BITBUCKET_TOKEN=${BITBUCKET_TOKEN}
133
- ENV BITBUCKET_WORKSPACE=${BITBUCKET_WORKSPACE}
134
- ENV BITBUCKET_LOG_DISABLE=false
135
- ENV BITBUCKET_ALLOW_DANGEROUS=${BITBUCKET_ALLOW_DANGEROUS:-false}
136
-
137
- CMD ["node", "dist/index.js"]
138
- ```
139
-
140
- ```bash
141
- # Run Docker container
142
- docker run -e BITBUCKET_TOKEN=your_token \
143
- -e BITBUCKET_WORKSPACE=my-workspace \
144
- bitbucket-mcp:latest
145
- ```
146
-
147
- ## Complete Example: GitHub Actions Workflow
148
-
149
- ```yaml
150
- name: Deploy to npm
151
-
152
- on:
153
- push:
154
- tags:
155
- - 'v*'
156
-
157
- jobs:
158
- publish:
159
- runs-on: ubuntu-latest
160
- steps:
161
- - uses: actions/checkout@v3
162
-
163
- - uses: pnpm/action-setup@v2
164
- with:
165
- version: 8
166
-
167
- - uses: actions/setup-node@v3
168
- with:
169
- node-version: '18'
170
- registry-url: 'https://registry.npmjs.org'
171
- cache: 'pnpm'
172
-
173
- - run: pnpm install
174
- - run: pnpm build
175
- - run: pnpm test
176
- - run: pnpm publish
177
- env:
178
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
179
- ```
180
-
181
- **GitHub Secrets to configure:**
182
- - `NPM_TOKEN`: npm automation token
183
-
184
- ## Configuration by Environment
185
-
186
- ### Development
187
-
188
- ```bash
189
- BITBUCKET_TOKEN=dev_token
190
- BITBUCKET_WORKSPACE=dev-workspace
191
- BITBUCKET_LOG_DISABLE=false
192
- BITBUCKET_ALLOW_DANGEROUS=true
193
- NODE_ENV=development
194
- ```
195
-
196
- ### Staging
197
-
198
- ```bash
199
- BITBUCKET_TOKEN=staging_token
200
- BITBUCKET_WORKSPACE=staging-workspace
201
- BITBUCKET_LOG_DISABLE=false
202
- BITBUCKET_ALLOW_DANGEROUS=false
203
- NODE_ENV=production
204
- ```
205
-
206
- ### Production
207
-
208
- ```bash
209
- BITBUCKET_TOKEN=${BITBUCKET_TOKEN}
210
- BITBUCKET_WORKSPACE=${BITBUCKET_WORKSPACE}
211
- BITBUCKET_LOG_DISABLE=false
212
- BITBUCKET_ALLOW_DANGEROUS=false
213
- NODE_ENV=production
214
- ```
215
-
216
- ## Environment Variable Priority
217
-
218
- When multiple configuration sources exist, priority is:
219
-
220
- 1. **Command-line environment variables** (highest)
221
- ```bash
222
- BITBUCKET_TOKEN=value pnpm start
223
- ```
224
-
225
- 2. **.env file in current directory**
226
- ```bash
227
- # .env
228
- BITBUCKET_TOKEN=value
229
- ```
230
-
231
- 3. **.env.local file** (for local overrides)
232
- ```bash
233
- # .env.local (in .gitignore)
234
- BITBUCKET_TOKEN=local_value
235
- ```
236
-
237
- 4. **System environment variables**
238
- ```bash
239
- export BITBUCKET_TOKEN=value
240
- ```
241
-
242
- 5. **Default values** (lowest, if any)
243
-
244
- ## Security Best Practices
245
-
246
- 1. **Never commit secrets**
247
- - Add `.env` and `.env.local` to `.gitignore`
248
- - Store tokens in environment or secret management
249
-
250
- 2. **Use strong tokens**
251
- - Use app passwords with minimal required scopes
252
- - Rotate tokens regularly
253
-
254
- 3. **Enable 2FA on npm account**
255
- - https://docs.npmjs.com/about-two-factor-authentication
256
-
257
- 4. **Use specific npm tokens for CI/CD**
258
- - Create automation tokens instead of personal tokens
259
- - Restrict token scope to "publish"
260
-
261
- 5. **Disable dangerous operations in production**
262
- - Only set `BITBUCKET_ALLOW_DANGEROUS=true` in development
263
- - This prevents accidental data loss
264
-
265
- ## Troubleshooting
266
-
267
- ### "Invalid credentials" error
268
-
269
- ```bash
270
- # Verify token is set
271
- echo $BITBUCKET_TOKEN
272
-
273
- # Test credentials
274
- curl -X GET https://api.bitbucket.org/2.0/user \
275
- -H "Authorization: Bearer $BITBUCKET_TOKEN"
276
- ```
277
-
278
- ### "Workspace not found"
279
-
280
- ```bash
281
- # Verify workspace name
282
- echo $BITBUCKET_WORKSPACE
283
-
284
- # List your workspaces
285
- curl -X GET https://api.bitbucket.org/2.0/workspaces \
286
- -H "Authorization: Bearer $BITBUCKET_TOKEN"
287
- ```
288
-
289
- ### npm publish fails with "ENEEDAUTH"
290
-
291
- ```bash
292
- # Check npm login
293
- npm whoami
294
-
295
- # Login again
296
- npm login
297
-
298
- # Or use token directly
299
- echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
300
- ```
301
-
302
- ## See Also
303
-
304
- - [Getting Started Guide](GETTING_STARTED.md)
305
- - [NPM Deployment Guide](NPM_DEPLOYMENT.md)
306
- - [Architecture Documentation](../architecture/ARCHITECTURE.md)