gitlab-mcp-agent-server 0.2.6 → 0.2.7

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.
@@ -54,6 +54,13 @@ class GitLabOAuthManager {
54
54
  try {
55
55
  return await this.loginInteractively();
56
56
  }
57
+ catch (error) {
58
+ if (error instanceof OAuthCallbackPortBusyError) {
59
+ console.error(error.message);
60
+ return this.waitForTokenFromOtherProcess(lockFilePath);
61
+ }
62
+ throw error;
63
+ }
57
64
  finally {
58
65
  lock.release();
59
66
  }
@@ -190,6 +197,11 @@ class GitLabOAuthManager {
190
197
  });
191
198
  server.on('error', (error) => {
192
199
  settled = true;
200
+ const errno = error;
201
+ if (errno.code === 'EADDRINUSE') {
202
+ reject(new OAuthCallbackPortBusyError(`OAuth callback port is busy (${redirect.hostname}:${resolvePort(redirect)}). If another OAuth flow is active, finish it and retry.`));
203
+ return;
204
+ }
193
205
  reject(new Error(`OAuth callback server failed on ${redirect.hostname}:${resolvePort(redirect)}: ${error.message}`));
194
206
  });
195
207
  server.listen(resolvePort(redirect), redirect.hostname, () => {
@@ -315,6 +327,12 @@ class OAuthRefreshError extends Error {
315
327
  this.name = 'OAuthRefreshError';
316
328
  }
317
329
  }
330
+ class OAuthCallbackPortBusyError extends Error {
331
+ constructor(message) {
332
+ super(message);
333
+ this.name = 'OAuthCallbackPortBusyError';
334
+ }
335
+ }
318
336
  function shouldReloginOnRefreshFailure(error) {
319
337
  if (!(error instanceof OAuthRefreshError)) {
320
338
  return false;
@@ -375,6 +393,15 @@ function isStaleLock(lockFilePath) {
375
393
  try {
376
394
  const raw = (0, node_fs_1.readFileSync)(lockFilePath, 'utf8');
377
395
  const parsed = JSON.parse(raw);
396
+ if (parsed.startedAt) {
397
+ const startedAtMs = new Date(parsed.startedAt).getTime();
398
+ if (!Number.isNaN(startedAtMs)) {
399
+ const ageMs = Date.now() - startedAtMs;
400
+ if (ageMs > 10 * 60 * 1000) {
401
+ return true;
402
+ }
403
+ }
404
+ }
378
405
  if (!parsed.pid || !Number.isInteger(parsed.pid)) {
379
406
  return true;
380
407
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitlab-mcp-agent-server",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "description": "MCP server for GitLab integration via OAuth",
5
5
  "main": "build/src/index.js",
6
6
  "bin": {