gitlab-mcp-agent-server 0.2.4 → 0.2.5

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.
@@ -61,7 +61,7 @@ class GitLabOAuthManager {
61
61
  return this.waitForTokenFromOtherProcess(lockFilePath);
62
62
  }
63
63
  async waitForTokenFromOtherProcess(lockFilePath) {
64
- const maxWaitMs = 2 * 60 * 1000;
64
+ const maxWaitMs = 15 * 1000;
65
65
  const pollMs = 1000;
66
66
  let elapsed = 0;
67
67
  console.error('OAuth flow is already running in another process for this instance. Waiting for token...');
@@ -86,7 +86,7 @@ class GitLabOAuthManager {
86
86
  await sleep(pollMs);
87
87
  elapsed += pollMs;
88
88
  }
89
- throw new Error('Timed out waiting for OAuth token from another process. Retry request or complete authorization in the first window.');
89
+ throw new Error(`Timed out waiting for OAuth token from another process. Complete OAuth in the first window or remove stale lock: ${lockFilePath}`);
90
90
  }
91
91
  async refreshToken(refreshToken) {
92
92
  this.assertOAuthClientCredentials();
@@ -124,6 +124,7 @@ class GitLabOAuthManager {
124
124
  authorizeUrl.searchParams.set('state', state);
125
125
  const localEntryUrl = `${redirect.protocol}//${redirect.host}/`;
126
126
  const code = await new Promise((resolve, reject) => {
127
+ let settled = false;
127
128
  const server = (0, node_http_1.createServer)((req, res) => {
128
129
  if (!req.url) {
129
130
  return;
@@ -155,6 +156,7 @@ class GitLabOAuthManager {
155
156
  actionLabel: 'Start OAuth Again'
156
157
  }));
157
158
  server.close();
159
+ settled = true;
158
160
  reject(new Error(`OAuth authorization failed: ${error}`));
159
161
  return;
160
162
  }
@@ -170,6 +172,7 @@ class GitLabOAuthManager {
170
172
  actionLabel: 'Start OAuth Again'
171
173
  }));
172
174
  server.close();
175
+ settled = true;
173
176
  reject(new Error('Invalid OAuth callback: code/state mismatch.'));
174
177
  return;
175
178
  }
@@ -182,9 +185,11 @@ class GitLabOAuthManager {
182
185
  hint: 'This tab can be closed now.'
183
186
  }));
184
187
  server.close();
188
+ settled = true;
185
189
  resolve(authCode);
186
190
  });
187
191
  server.on('error', (error) => {
192
+ settled = true;
188
193
  reject(new Error(`OAuth callback server failed on ${redirect.hostname}:${resolvePort(redirect)}: ${error.message}`));
189
194
  });
190
195
  server.listen(resolvePort(redirect), redirect.hostname, () => {
@@ -196,6 +201,14 @@ class GitLabOAuthManager {
196
201
  console.error(authorizeUrl.toString());
197
202
  }
198
203
  });
204
+ const timeoutMs = 20_000;
205
+ setTimeout(() => {
206
+ if (settled) {
207
+ return;
208
+ }
209
+ server.close();
210
+ reject(new Error(`OAuth was not completed in time. Open ${localEntryUrl} to continue, or use ${authorizeUrl.toString()}`));
211
+ }, timeoutMs);
199
212
  });
200
213
  const tokenResponse = await fetch(`${this.oauthBaseUrl}/oauth/token`, {
201
214
  method: 'POST',
@@ -168,6 +168,11 @@ npx -y gitlab-mcp-agent-server
168
168
  3. Если lock застрял после краша, удали stale lock:
169
169
  - `<tokenStorePath>.oauth.lock`
170
170
 
171
+ `gitlab_list_issues`/другой tool уходит в timeout после удаления token:
172
+ 1. Проверь stale lock и удали его:
173
+ - `rm -f ~/.config/gitlab-mcp/<gitlab-host>/token.json.oauth.lock`
174
+ 2. Повтори запрос и заверши OAuth в браузере в течение окна авторизации.
175
+
171
176
  ## 10. Advanced (необязательно)
172
177
 
173
178
  Если нужен тонкий контроль, можно использовать:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitlab-mcp-agent-server",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "MCP server for GitLab integration via OAuth",
5
5
  "main": "build/src/index.js",
6
6
  "bin": {