@zereight/mcp-gitlab 2.3.19 → 2.3.20-next.197

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.
package/README.ko.md CHANGED
@@ -558,6 +558,10 @@ Authorization: Bearer glpat-xxxxxxxxxxxxxxxxxxxx
558
558
 
559
559
  설정은 [`MAX_SESSIONS`](./docs/configuration/environment-variables.md#max_sessions), `MAX_REQUESTS_PER_MINUTE`, `SESSION_TIMEOUT_SECONDS`를 참고하세요.
560
560
 
561
+ #### Streamable HTTP 세션 타임아웃
562
+
563
+ Streamable HTTP 세션도 모든 모드에서 같은 `SESSION_TIMEOUT_SECONDS` 유휴 타임아웃을 사용합니다. `REMOTE_AUTHORIZATION`이나 `GITLAB_MCP_OAUTH` 없이 서버 측 토큰을 쓰는 경우도 포함됩니다. 그 시간 동안 `POST /mcp` 요청이 없는 세션은 종료되고, 다음 요청은 `404`를 받으므로 클라이언트가 다시 initialize합니다. `GET /mcp` 스트림이 열려 있으면 스트림이 닫히거나 다음 `POST /mcp`가 올 때까지 타이머가 멈춥니다. 따라서 스트림을 열어 둔 클라이언트도 마지막 `POST` 이후 `SESSION_TIMEOUT_SECONDS`가 지나면 만료됩니다.
564
+
561
565
  ### 원격 인증 설정(멀티 유저 지원)
562
566
 
563
567
  `REMOTE_AUTHORIZATION=true`를 사용하면 MCP 서버는 여러 사용자를 지원할 수 있습니다. 각 사용자는 HTTP 헤더로 자신의 GitLab 토큰을 전달합니다. 다음 경우 유용합니다.
@@ -614,7 +618,7 @@ Private-Token: glpat-xxxxxxxxxxxxxxxxxxxx
614
618
 
615
619
  - 원격 인증은 **Streamable HTTP 전송에서만** 동작합니다.
616
620
  - 각 세션은 격리됩니다. 한 세션의 토큰은 다른 세션 데이터에 접근할 수 없습니다. 세션이 종료되면 토큰은 자동으로 정리됩니다.
617
- - **세션 타임아웃:** 인증 토큰은 `SESSION_TIMEOUT_SECONDS`(기본 1시간) 동안 비활성 상태가 지속되면 만료됩니다. 만료 후 클라이언트는 인증 헤더를 다시 보내야 합니다. 전송 세션은 유지됩니다.
621
+ - **세션 타임아웃:** 인증 토큰은 `SESSION_TIMEOUT_SECONDS`(기본 1시간) 동안 비활성 상태가 지속되면 만료됩니다. 만료되면 세션이 종료되고 다음 요청은 `404`를 받으므로, 클라이언트는 인증 헤더와 함께 다시 initialize합니다.
618
622
  - 각 요청은 해당 세션의 타임아웃 타이머를 초기화합니다.
619
623
  - **Rate limiting:** `/mcp` 요청은 클라이언트 IP당 `MAX_REQUESTS_PER_MINUTE`로 제한되며, OAuth 또는 원격 인증 사용 시 MCP 세션당으로도 제한됩니다(기본 60). IP당 한도는 고정 60초 윈도우를 사용하고 서버 프로세스별로 집계되며 `GET /mcp`에도 적용됩니다. stateless 모드에서는 세션당 한도를 건너뜁니다. 자세한 내용은 [environment-variables.md](docs/configuration/environment-variables.md#max_requests_per_minute)를 참고하세요.
620
624
  - **Capacity limit:** 서버는 최대 `MAX_SESSIONS` 동시 세션을 허용합니다(기본 1000).
package/README.md CHANGED
@@ -595,6 +595,10 @@ For callback proxy mode details, see [GitLab MCP OAuth Callback Proxy](./docs/au
595
595
 
596
596
  Tune these with [`MAX_SESSIONS`](./docs/configuration/environment-variables.md#max_sessions), `MAX_REQUESTS_PER_MINUTE`, and `SESSION_TIMEOUT_SECONDS`.
597
597
 
598
+ #### Streamable HTTP session timeout
599
+
600
+ Streamable HTTP sessions use the same `SESSION_TIMEOUT_SECONDS` idle timeout in every mode, including a server-side token without `REMOTE_AUTHORIZATION` or `GITLAB_MCP_OAUTH`: a session with no `POST /mcp` request for that long is closed, and its next request gets `404` so the client re-initializes. An open `GET /mcp` stream pauses the timer until the stream closes or the next `POST /mcp` arrives, so a client with a stream open still expires `SESSION_TIMEOUT_SECONDS` after its last `POST`.
601
+
598
602
  ### Remote Authorization Setup (Multi-User Support)
599
603
 
600
604
  When using `REMOTE_AUTHORIZATION=true`, the MCP server can support multiple users, each with their own GitLab token passed via HTTP headers. This is useful for:
@@ -653,7 +657,7 @@ The token is stored per session (identified by `mcp-session-id` header) and reus
653
657
  - Remote authorization **only works with Streamable HTTP transport**
654
658
  - Each session is isolated - tokens from one session cannot access another session's data
655
659
  Tokens are automatically cleaned up when sessions close
656
- - **Session timeout:** Auth tokens expire after `SESSION_TIMEOUT_SECONDS` (default 1 hour) of inactivity. After timeout, the client must send auth headers again. The transport session remains active.
660
+ - **Session timeout:** Auth tokens expire after `SESSION_TIMEOUT_SECONDS` (default 1 hour) of inactivity. After timeout the session is closed and its next request gets `404`, so the client re-initializes with its auth headers.
657
661
  - Each request resets the timeout timer for that session
658
662
  - **Rate limiting:** `/mcp` requests are limited to `MAX_REQUESTS_PER_MINUTE` per client IP, and per MCP session when using OAuth or remote authorization (default 60). The per-IP limit uses a fixed 60-second window, counts per server process, and also covers `GET /mcp`; stateless mode skips the per-session limit. See [environment-variables.md](docs/configuration/environment-variables.md#max_requests_per_minute).
659
663
  - **Capacity limit:** Server accepts up to `MAX_SESSIONS` concurrent sessions (default 1000)
package/README.pt-BR.md CHANGED
@@ -558,6 +558,10 @@ Para detalhes do modo de proxy de callback, veja [GitLab MCP OAuth Callback Prox
558
558
 
559
559
  Ajuste esses limites com [`MAX_SESSIONS`](./docs/configuration/environment-variables.md#max_sessions), `MAX_REQUESTS_PER_MINUTE` e `SESSION_TIMEOUT_SECONDS`.
560
560
 
561
+ #### Timeout de sessão Streamable HTTP
562
+
563
+ Sessões Streamable HTTP usam o mesmo timeout de inatividade `SESSION_TIMEOUT_SECONDS` em todos os modos, inclusive com um token do lado do servidor sem `REMOTE_AUTHORIZATION` ou `GITLAB_MCP_OAUTH`: uma sessão sem requisição `POST /mcp` durante esse tempo é encerrada, e a próxima requisição recebe `404`, então o cliente inicializa de novo. Um stream `GET /mcp` aberto pausa o timer até o stream fechar ou chegar o próximo `POST /mcp`; assim, um cliente com o stream aberto ainda expira `SESSION_TIMEOUT_SECONDS` após o último `POST`.
564
+
561
565
  ### Configuração de autorização remota (suporte multiusuário)
562
566
 
563
567
  Com `REMOTE_AUTHORIZATION=true`, o servidor MCP pode atender vários usuários, cada um fornecendo seu próprio token do GitLab por headers HTTP. Isso é útil para:
@@ -614,7 +618,7 @@ O token é armazenado por sessão (identificada pelo header `mcp-session-id`) e
614
618
 
615
619
  - A autorização remota **funciona apenas com o transporte Streamable HTTP**
616
620
  - Cada sessão é isolada. O token de uma sessão não pode acessar os dados de outra sessão. Os tokens são limpos automaticamente quando a sessão é encerrada.
617
- - **Timeout de sessão:** os tokens de autenticação expiram após `SESSION_TIMEOUT_SECONDS` (padrão 1 hora) sem atividade. Após o timeout, o cliente precisa enviar novamente os headers de autenticação. A sessão de transporte permanece ativa.
621
+ - **Timeout de sessão:** os tokens de autenticação expiram após `SESSION_TIMEOUT_SECONDS` (padrão 1 hora) sem atividade. Após o timeout a sessão é encerrada e a próxima requisição recebe `404`, então o cliente inicializa de novo com os headers de autenticação.
618
622
  - Cada requisição reinicia o timer de timeout da sessão.
619
623
  - **Rate limiting:** requisições a `/mcp` são limitadas por IP do cliente a `MAX_REQUESTS_PER_MINUTE`; ao usar OAuth ou autorização remota, também são limitadas por sessão MCP (padrão 60). O limite por IP usa uma janela fixa de 60 segundos, conta por processo do servidor e também cobre `GET /mcp`; o modo stateless ignora o limite por sessão. Veja [environment-variables.md](docs/configuration/environment-variables.md#max_requests_per_minute).
620
624
  - **Limite de capacidade:** o servidor aceita no máximo `MAX_SESSIONS` sessões simultâneas (padrão 1000).
package/README.zh-CN.md CHANGED
@@ -557,6 +557,10 @@ Authorization: Bearer glpat-xxxxxxxxxxxxxxxxxxxx
557
557
 
558
558
  可通过 [`MAX_SESSIONS`](./docs/configuration/environment-variables.md#max_sessions)、`MAX_REQUESTS_PER_MINUTE` 和 `SESSION_TIMEOUT_SECONDS` 调整这些限制。
559
559
 
560
+ #### Streamable HTTP 会话超时
561
+
562
+ Streamable HTTP 会话在所有模式下都使用同一个 `SESSION_TIMEOUT_SECONDS` 空闲超时,包括不启用 `REMOTE_AUTHORIZATION` 或 `GITLAB_MCP_OAUTH`、只用服务端 token 的模式:超过该时长没有 `POST /mcp` 请求的会话会被关闭,之后的请求返回 `404`,客户端会重新 initialize。`GET /mcp` 流打开时计时器暂停,直到流关闭或收到下一个 `POST /mcp`;因此保持流打开的客户端,在最后一次 `POST` 之后经过 `SESSION_TIMEOUT_SECONDS` 仍会过期。
563
+
560
564
  ### 远程授权设置(多用户支持)
561
565
 
562
566
  使用 `REMOTE_AUTHORIZATION=true` 时,MCP 服务器可以支持多个用户,每个用户通过 HTTP 请求头传入自己的 GitLab token。适用于:
@@ -613,7 +617,7 @@ token 按会话存储(由 `mcp-session-id` 请求头标识),并在同一
613
617
 
614
618
  - 远程授权**仅适用于 Streamable HTTP 传输**
615
619
  - 每个会话相互隔离。一个会话的 token 不能访问另一个会话的数据。会话关闭后 token 会自动清理。
616
- - **会话超时:** 认证 token 在 `SESSION_TIMEOUT_SECONDS`(默认 1 小时)无活动后过期。超时后,客户端必须再次发送认证请求头。传输会话仍保持活动。
620
+ - **会话超时:** 认证 token 在 `SESSION_TIMEOUT_SECONDS`(默认 1 小时)无活动后过期。超时后会话被关闭,之后的请求返回 `404`,客户端需带上认证请求头重新 initialize。
617
621
  - 每个请求都会重置该会话的超时计时器。
618
622
  - **Rate limiting:** `/mcp` 请求按客户端 IP 限制为每分钟 `MAX_REQUESTS_PER_MINUTE` 次;使用 OAuth 或远程授权时还按 MCP 会话限制(默认 60)。按 IP 的限制使用固定 60 秒窗口,按服务器进程分别计数,并同样覆盖 `GET /mcp`;stateless 模式会跳过按会话的限制。详见 [environment-variables.md](docs/configuration/environment-variables.md#max_requests_per_minute)。
619
623
  - **Capacity limit:** 服务器最多接受 `MAX_SESSIONS` 个并发会话(默认 1000)。
package/build/index.js CHANGED
@@ -12133,6 +12133,9 @@ async function startStreamableHTTPServer() {
12133
12133
  // names such as "constructor" from masquerading as live transports.
12134
12134
  const streamableTransports = Object.create(null);
12135
12135
  const authTimeouts = {};
12136
+ // Sessions with an open GET /mcp stream. The SDK allows one stream per session and
12137
+ // rejects a second GET with 409; that request must not touch the session's timer.
12138
+ const openGetStreams = new Set();
12136
12139
  // Configuration and limits
12137
12140
  const MAX_SESSIONS = Number.parseInt(process.env.MAX_SESSIONS || "1000", 10);
12138
12141
  const MAX_REQUESTS_PER_MINUTE = Number.parseInt(process.env.MAX_REQUESTS_PER_MINUTE || "60", 10);
@@ -12385,7 +12388,9 @@ async function startStreamableHTTPServer() {
12385
12388
  if (authData || transport) {
12386
12389
  logger.info(authData
12387
12390
  ? `Session ${redactSessionIdForLog(sessionId)}: auth token expired after ${SESSION_TIMEOUT_SECONDS}s of inactivity`
12388
- : `Session ${redactSessionIdForLog(sessionId)}: unauthenticated discovery expired after ${SESSION_TIMEOUT_SECONDS}s`);
12391
+ : REMOTE_AUTHORIZATION || GITLAB_MCP_OAUTH
12392
+ ? `Session ${redactSessionIdForLog(sessionId)}: unauthenticated discovery expired after ${SESSION_TIMEOUT_SECONDS}s`
12393
+ : `Session ${redactSessionIdForLog(sessionId)}: closed after ${SESSION_TIMEOUT_SECONDS}s of inactivity`);
12389
12394
  delete authBySession[sessionId];
12390
12395
  delete authTimeouts[sessionId];
12391
12396
  metrics.expiredSessions++;
@@ -13146,6 +13151,15 @@ async function startStreamableHTTPServer() {
13146
13151
  }
13147
13152
  }
13148
13153
  }
13154
+ // Server-side token mode (no per-session auth): every POST to a live session is
13155
+ // activity, so reset its inactivity timer. Without this, clients that disconnect
13156
+ // without DELETE /mcp hold their slot until MAX_SESSIONS is exhausted.
13157
+ if (!REMOTE_AUTHORIZATION &&
13158
+ !GITLAB_MCP_OAUTH &&
13159
+ sessionId &&
13160
+ streamableTransports[sessionId]) {
13161
+ setAuthTimeout(sessionId);
13162
+ }
13149
13163
  // Handle request with proper AsyncLocalStorage context
13150
13164
  const handleRequest = async () => {
13151
13165
  try {
@@ -13164,6 +13178,11 @@ async function startStreamableHTTPServer() {
13164
13178
  metrics.totalSessions++;
13165
13179
  metrics.activeSessions++;
13166
13180
  logger.warn(`Streamable HTTP session initialized: ${redactSessionIdForLog(newSessionId)}`);
13181
+ // Server-side token mode: no per-session auth, but the session still
13182
+ // expires after SESSION_TIMEOUT_SECONDS without activity.
13183
+ if (!REMOTE_AUTHORIZATION && !GITLAB_MCP_OAUTH) {
13184
+ setAuthTimeout(newSessionId);
13185
+ }
13167
13186
  // Store auth for newly created session in remote mode
13168
13187
  if (REMOTE_AUTHORIZATION && !authBySession[newSessionId]) {
13169
13188
  const authData = parseAuthHeaders(req);
@@ -13214,6 +13233,8 @@ async function startStreamableHTTPServer() {
13214
13233
  logger.warn(`Streamable HTTP transport closed for session ${redactSessionIdForLog(sid)}, cleaning up`);
13215
13234
  delete streamableTransports[sid];
13216
13235
  metrics.activeSessions--;
13236
+ openGetStreams.delete(sid);
13237
+ clearAuthTimeout(sid);
13217
13238
  if (REMOTE_AUTHORIZATION || GITLAB_MCP_OAUTH) {
13218
13239
  cleanupSessionAuth(sid);
13219
13240
  delete sessionRequestCounts[sid];
@@ -13295,13 +13316,16 @@ async function startStreamableHTTPServer() {
13295
13316
  return;
13296
13317
  }
13297
13318
  metrics.requestsProcessed++;
13298
- const usesSessionTimeouts = REMOTE_AUTHORIZATION || GITLAB_MCP_OAUTH;
13299
- if (usesSessionTimeouts) {
13300
- if (authBySession[sessionId]) {
13301
- authBySession[sessionId].lastUsed = Date.now();
13302
- }
13303
- // Listening on GET /mcp is session activity. Pause inactivity expiry for
13304
- // the life of the SSE stream so list_changed can still be pushed.
13319
+ const usesPerSessionAuth = REMOTE_AUTHORIZATION || GITLAB_MCP_OAUTH;
13320
+ if (usesPerSessionAuth && authBySession[sessionId]) {
13321
+ authBySession[sessionId].lastUsed = Date.now();
13322
+ }
13323
+ // Listening on GET /mcp is session activity. Pause inactivity expiry for
13324
+ // the life of the SSE stream so list_changed can still be pushed. A second GET
13325
+ // while a stream is open is rejected by the SDK and leaves the timer alone.
13326
+ const ownsStream = !openGetStreams.has(sessionId);
13327
+ if (ownsStream) {
13328
+ openGetStreams.add(sessionId);
13305
13329
  clearAuthTimeout(sessionId);
13306
13330
  }
13307
13331
  const handleGetRequest = async () => {
@@ -13319,7 +13343,7 @@ async function startStreamableHTTPServer() {
13319
13343
  }
13320
13344
  };
13321
13345
  try {
13322
- if (usesSessionTimeouts && authBySession[sessionId]) {
13346
+ if (usesPerSessionAuth && authBySession[sessionId]) {
13323
13347
  const authData = authBySession[sessionId];
13324
13348
  const ctx = {
13325
13349
  sessionId,
@@ -13337,8 +13361,11 @@ async function startStreamableHTTPServer() {
13337
13361
  }
13338
13362
  }
13339
13363
  finally {
13340
- if (usesSessionTimeouts && streamableTransports[sessionId]) {
13341
- setAuthTimeout(sessionId);
13364
+ if (ownsStream) {
13365
+ openGetStreams.delete(sessionId);
13366
+ if (streamableTransports[sessionId]) {
13367
+ setAuthTimeout(sessionId);
13368
+ }
13342
13369
  }
13343
13370
  }
13344
13371
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zereight/mcp-gitlab",
3
- "version": "2.3.19",
3
+ "version": "2.3.20-next.197",
4
4
  "mcpName": "io.github.zereight/gitlab-mcp",
5
5
  "description": "GitLab MCP server for projects, merge requests, issues, pipelines, wiki, releases, and more",
6
6
  "keywords": [