@zereight/mcp-gitlab 2.3.9-next.153 → 2.3.10-next.156
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 +7 -7
- package/README.md +8 -8
- package/README.pt-BR.md +7 -7
- package/README.zh-CN.md +7 -7
- package/build/downloads/proxy.js +28 -6
- package/build/index.js +106 -38
- package/build/schemas.js +1 -1
- package/build/server/request-helpers.js +22 -0
- package/build/tools/registry.js +1 -1
- package/build/tools/tool-descriptions.js +1 -1
- package/package.json +1 -1
package/README.ko.md
CHANGED
|
@@ -157,15 +157,15 @@ PAT, OAuth, 읽기 전용 모드, 동적 API URL, 원격 인증을 지원하며
|
|
|
157
157
|
| **Node.js** | >=18.17 | 보통 >=24 | stdio는 `mcp-remote`, Node.js 20+ |
|
|
158
158
|
| **라이선스** | MIT | 서버마다 다름 | GitLab의 일부 |
|
|
159
159
|
|
|
160
|
-
### tools/list 크기 (2026-10-
|
|
160
|
+
### tools/list 크기 (2026-10-24 실측)
|
|
161
161
|
|
|
162
162
|
클라이언트는 세션 시작 때 `tools/list` 전체를 모델에 보냅니다. 토큰 추정은 UTF-8 바이트 / 4입니다.
|
|
163
163
|
|
|
164
164
|
| 프로필 | 도구 수 | JSON 바이트 | 추정 토큰 |
|
|
165
165
|
| ------ | ------: | ----------: | --------: |
|
|
166
|
-
| 기본값 (`core` + `discover_tools`) |
|
|
167
|
-
| `GITLAB_TOOL_PROFILE=slim` |
|
|
168
|
-
| `GITLAB_TOOLSETS=all` |
|
|
166
|
+
| 기본값 (`core` + `discover_tools` + `help`) | 40 | 50,682 | 12,671 |
|
|
167
|
+
| `GITLAB_TOOL_PROFILE=slim` | 39 | 49,646 | 12,412 |
|
|
168
|
+
| `GITLAB_TOOLSETS=all` | 276 | 285,677 | 71,420 |
|
|
169
169
|
|
|
170
170
|
설명이나 스키마를 바꾼 뒤에는 `npm run test:mock` (`test/tools-list-budget.test.ts`)으로 다시 측정하세요.
|
|
171
171
|
|
|
@@ -252,7 +252,7 @@ command = lib.getExe inputs.gitlab-mcp.packages.${system}.default;
|
|
|
252
252
|
|
|
253
253
|
예시는 기존 `mcp-gitlab`보다 충돌 가능성이 낮은 `zereight-mcp-gitlab` 별칭을 사용합니다. MCP 클라이언트가 찾지 못하면 `which zereight-mcp-gitlab`의 절대 경로를 사용하세요.
|
|
254
254
|
|
|
255
|
-
전역 설치를 쓰지 않으려면 `npx -y @zereight/mcp-gitlab@2.3.
|
|
255
|
+
전역 설치를 쓰지 않으려면 `npx -y @zereight/mcp-gitlab@2.3.8`처럼 직전 안정 버전(문서가 권장하는 버전)으로 고정하세요. 항상 최신 버전을 원하면 `npx -y @zereight/mcp-gitlab@latest`를 사용하세요. `main`에 머지된 수정을 다음 안정 버전 전에 확인하려면 프리릴리스 빌드인 `npx -y @zereight/mcp-gitlab@next`를 사용하세요(운영 환경용이 아닙니다). 새 버전이 나오면 서버가 시작 시 stderr로 알려줍니다(`GITLAB_DISABLE_VERSION_CHECK=true`로 비활성화 가능).
|
|
256
256
|
|
|
257
257
|
#### Claude Desktop 원클릭 설치(MCP Bundle)
|
|
258
258
|
|
|
@@ -292,7 +292,7 @@ v2.3.1 이후의 GitHub 릴리스마다 `gitlab-mcp.mcpb` [MCP Bundle](https://g
|
|
|
292
292
|
- `--masking-config` - 마스킹 설정 파일 경로 (`GITLAB_MASKING_CONFIG` 대체)
|
|
293
293
|
- `--masking-policy-file` - 보호된 관리형 정책 파일 경로 (`GITLAB_MASKING_POLICY_FILE` 대체)
|
|
294
294
|
- `--masking-workspace-dir` - 마스킹 파일 경로를 해석하는 기준 디렉터리 (`GITLAB_MASKING_WORKSPACE_DIR` 대체)
|
|
295
|
-
- `--download-dir` - `download_attachment`가 파일을 저장하는 디렉터리 (`GITLAB_DOWNLOAD_DIR` 대체, 기본값 `.gitlab-mcp-downloads`)
|
|
295
|
+
- `--download-dir` - `download_attachment`와 `download_job_artifacts`가 파일을 저장하는 디렉터리 (`GITLAB_DOWNLOAD_DIR` 대체, 기본값 `.gitlab-mcp-downloads`)
|
|
296
296
|
- `--compact-results=true` - 큰 MCP 도구 응답을 미리보기와 CLI 명령으로 바꿈 (`GITLAB_MCP_COMPACT_RESULTS` 대체, 기본 꺼짐)
|
|
297
297
|
- `--compact-result-chars` - compact 임계값 문자 수 (`GITLAB_MCP_COMPACT_RESULT_CHARS` 대체, 기본 `4000`)
|
|
298
298
|
- `--compact-tools` - 전역 compact를 켜지 않고, 응답이 클 때 compact할 도구 이름을 쉼표로 지정 (`GITLAB_MCP_COMPACT_TOOLS` 대체)
|
|
@@ -592,7 +592,7 @@ Authorization: Bearer glpat-xxxxxxxxxxxxxxxxxxxx
|
|
|
592
592
|
Private-Token: glpat-xxxxxxxxxxxxxxxxxxxx
|
|
593
593
|
```
|
|
594
594
|
|
|
595
|
-
토큰은 세션별로 저장됩니다(`mcp-session-id` 헤더로 식별). 같은 세션의 후속 요청에서 재사용됩니다.
|
|
595
|
+
토큰은 세션별로 저장됩니다(`mcp-session-id` 헤더로 식별). 같은 세션의 후속 요청에서 재사용됩니다. 세션은 그 토큰의 GitLab 사용자에게 속합니다. 다른 사용자의 토큰을 보낸 요청은 `404 Session not found`, 토큰 없는 `GET` / `DELETE /mcp`는 `401`을 받습니다.
|
|
596
596
|
|
|
597
597
|
#### Cursor 원격 인증 클라이언트 설정 예시
|
|
598
598
|
|
package/README.md
CHANGED
|
@@ -163,15 +163,15 @@ Supports PAT, OAuth, read-only mode, dynamic API URLs, and remote authorization
|
|
|
163
163
|
| **Node.js** | >=18.17 | Often >=24 | Node.js 20+ for stdio via `mcp-remote` |
|
|
164
164
|
| **License** | MIT | Varies | Part of GitLab |
|
|
165
165
|
|
|
166
|
-
### tools/list size (measured 2026-10-
|
|
166
|
+
### tools/list size (measured 2026-10-24)
|
|
167
167
|
|
|
168
168
|
A client sends the whole `tools/list` result to the model at session start. Token estimate is UTF-8 bytes / 4.
|
|
169
169
|
|
|
170
170
|
| Profile | Tools | JSON bytes | Est. tokens |
|
|
171
171
|
| ------- | ----: | ---------: | ----------: |
|
|
172
|
-
| Default (`core` + `discover_tools`) |
|
|
173
|
-
| `GITLAB_TOOL_PROFILE=slim` |
|
|
174
|
-
| `GITLAB_TOOLSETS=all` |
|
|
172
|
+
| Default (`core` + `discover_tools` + `help`) | 40 | 50,682 | 12,671 |
|
|
173
|
+
| `GITLAB_TOOL_PROFILE=slim` | 39 | 49,646 | 12,412 |
|
|
174
|
+
| `GITLAB_TOOLSETS=all` | 276 | 285,677 | 71,420 |
|
|
175
175
|
|
|
176
176
|
Re-measure with `npm run test:mock` (`test/tools-list-budget.test.ts`) after description or schema changes.
|
|
177
177
|
|
|
@@ -258,7 +258,7 @@ The store path is pinned by your lock file; update it with `nix flake update git
|
|
|
258
258
|
|
|
259
259
|
The examples use `zereight-mcp-gitlab`, a less collision-prone alias for the legacy `mcp-gitlab` binary. If your MCP client cannot find it, use the absolute path from `which zereight-mcp-gitlab`.
|
|
260
260
|
|
|
261
|
-
No global install? Pin `npx` to the previous stable release (the version these docs recommend), for example `npx -y @zereight/mcp-gitlab@2.3.
|
|
261
|
+
No global install? Pin `npx` to the previous stable release (the version these docs recommend), for example `npx -y @zereight/mcp-gitlab@2.3.8`. If you always want the newest release, use `npx -y @zereight/mcp-gitlab@latest` instead. To try a fix merged to `main` before the next stable release, use `npx -y @zereight/mcp-gitlab@next`, a pre-release build that is not meant for production. The server prints a notice to stderr on startup when a newer version is available (disable with `GITLAB_DISABLE_VERSION_CHECK=true`).
|
|
262
262
|
|
|
263
263
|
#### Claude Desktop one-click install (MCP Bundle)
|
|
264
264
|
|
|
@@ -298,7 +298,7 @@ Some MCP clients (like GitHub Copilot CLI) have issues with environment variable
|
|
|
298
298
|
- `--masking-config` - Path to a masking configuration file (replaces `GITLAB_MASKING_CONFIG`)
|
|
299
299
|
- `--masking-policy-file` - Path to a protected managed-policy file (replaces `GITLAB_MASKING_POLICY_FILE`)
|
|
300
300
|
- `--masking-workspace-dir` - Directory used to resolve masking files (replaces `GITLAB_MASKING_WORKSPACE_DIR`)
|
|
301
|
-
- `--download-dir` - Directory `download_attachment`
|
|
301
|
+
- `--download-dir` - Directory `download_attachment` and `download_job_artifacts` save files under (replaces `GITLAB_DOWNLOAD_DIR`; default `.gitlab-mcp-downloads`)
|
|
302
302
|
- `--compact-results=true` - Truncate oversized MCP tool replies and attach a CLI command for the full payload (replaces `GITLAB_MCP_COMPACT_RESULTS`; default off)
|
|
303
303
|
- `--compact-result-chars` - Character threshold for compacting (replaces `GITLAB_MCP_COMPACT_RESULT_CHARS`; default `4000`)
|
|
304
304
|
- `--compact-tools` - Comma-separated tool names to compact when oversized, without turning global compact on (replaces `GITLAB_MCP_COMPACT_TOOLS`)
|
|
@@ -630,7 +630,7 @@ or
|
|
|
630
630
|
Private-Token: glpat-xxxxxxxxxxxxxxxxxxxx
|
|
631
631
|
```
|
|
632
632
|
|
|
633
|
-
The token is stored per session (identified by `mcp-session-id` header) and reused for subsequent requests in the same session.
|
|
633
|
+
The token is stored per session (identified by `mcp-session-id` header) and reused for subsequent requests in the same session. The session belongs to the GitLab user of that token: a request with another user's token gets `404 Session not found`, and `GET` / `DELETE /mcp` without a token get `401`.
|
|
634
634
|
|
|
635
635
|
#### Remote Authorization Client Configuration Example with Cursor
|
|
636
636
|
|
|
@@ -942,7 +942,7 @@ Register the skill directory in your AI client to get optimal tool usage guidanc
|
|
|
942
942
|
164. `wait_for_pipeline` - Wait for a pipeline to reach a terminal status
|
|
943
943
|
165. `wait_for_job` - Wait for a job to reach a terminal status
|
|
944
944
|
166. `list_job_artifacts` - List artifact files in a job's archive
|
|
945
|
-
167. `download_job_artifacts` - Download job artifact archive (zip) and save
|
|
945
|
+
167. `download_job_artifacts` - Download job artifact archive (zip) and save it under the download directory
|
|
946
946
|
168. `get_job_artifact_file` - Get content of a single file from a job's artifacts
|
|
947
947
|
169. `list_merge_requests` - List merge requests (without project_id: user's MRs; with project_id: project MRs)
|
|
948
948
|
170. `list_group_merge_requests` - List merge requests across all projects of a group and its subgroups
|
package/README.pt-BR.md
CHANGED
|
@@ -157,15 +157,15 @@ Suporta PAT, OAuth, modo somente leitura, URLs de API dinâmicas e autorização
|
|
|
157
157
|
| **Node.js** | >=18.17 | Frequentemente >=24 | Node.js 20+ para stdio via `mcp-remote` |
|
|
158
158
|
| **Licença** | MIT | Varia | Parte do GitLab |
|
|
159
159
|
|
|
160
|
-
### Tamanho do tools/list (medido em 2026-10-
|
|
160
|
+
### Tamanho do tools/list (medido em 2026-10-24)
|
|
161
161
|
|
|
162
162
|
O cliente envia o `tools/list` inteiro ao modelo no início da sessão. A estimativa de tokens é bytes UTF-8 / 4.
|
|
163
163
|
|
|
164
164
|
| Perfil | Ferramentas | Bytes JSON | Tokens estimados |
|
|
165
165
|
| ------ | ----------: | ---------: | ---------------: |
|
|
166
|
-
| Padrão (`core` + `discover_tools`) |
|
|
167
|
-
| `GITLAB_TOOL_PROFILE=slim` |
|
|
168
|
-
| `GITLAB_TOOLSETS=all` |
|
|
166
|
+
| Padrão (`core` + `discover_tools` + `help`) | 40 | 50,682 | 12,671 |
|
|
167
|
+
| `GITLAB_TOOL_PROFILE=slim` | 39 | 49,646 | 12,412 |
|
|
168
|
+
| `GITLAB_TOOLSETS=all` | 276 | 285,677 | 71,420 |
|
|
169
169
|
|
|
170
170
|
Após alterar descrições ou schemas, meça de novo com `npm run test:mock` (`test/tools-list-budget.test.ts`).
|
|
171
171
|
|
|
@@ -252,7 +252,7 @@ O caminho no store é fixado pelo seu lock file; atualize-o com `nix flake updat
|
|
|
252
252
|
|
|
253
253
|
Os exemplos usam `zereight-mcp-gitlab`, um alias com menor chance de conflito que o binário legado `mcp-gitlab`. Se o seu cliente MCP não o encontrar, use o caminho absoluto retornado por `which zereight-mcp-gitlab`.
|
|
254
254
|
|
|
255
|
-
Não quer instalar globalmente? Fixe o `npx` na versão estável anterior (a versão recomendada por esta documentação), por exemplo `npx -y @zereight/mcp-gitlab@2.3.
|
|
255
|
+
Não quer instalar globalmente? Fixe o `npx` na versão estável anterior (a versão recomendada por esta documentação), por exemplo `npx -y @zereight/mcp-gitlab@2.3.8`. Se quiser sempre a versão mais recente, use `npx -y @zereight/mcp-gitlab@latest`. Para testar uma correção já mesclada na `main` antes da próxima versão estável, use `npx -y @zereight/mcp-gitlab@next`, um build de pré-lançamento que não é indicado para produção. O servidor exibe um aviso no stderr durante a inicialização quando existe uma versão mais nova disponível (desative com `GITLAB_DISABLE_VERSION_CHECK=true`).
|
|
256
256
|
|
|
257
257
|
#### Instalação com um clique no Claude Desktop (MCP Bundle)
|
|
258
258
|
|
|
@@ -292,7 +292,7 @@ Alguns clientes MCP, como o GitHub Copilot CLI, têm problemas com variáveis de
|
|
|
292
292
|
- `--masking-config` - caminho para um arquivo de configuração de mascaramento (substitui `GITLAB_MASKING_CONFIG`)
|
|
293
293
|
- `--masking-policy-file` - caminho para um arquivo protegido de política gerenciada (substitui `GITLAB_MASKING_POLICY_FILE`)
|
|
294
294
|
- `--masking-workspace-dir` - diretório usado para resolver arquivos de mascaramento (substitui `GITLAB_MASKING_WORKSPACE_DIR`)
|
|
295
|
-
- `--download-dir` - diretório onde `download_attachment`
|
|
295
|
+
- `--download-dir` - diretório onde `download_attachment` e `download_job_artifacts` salvam arquivos (substitui `GITLAB_DOWNLOAD_DIR`; padrão `.gitlab-mcp-downloads`)
|
|
296
296
|
- `--compact-results=true` - trunca respostas muito grandes de ferramentas MCP e anexa um comando CLI para a carga completa (substitui `GITLAB_MCP_COMPACT_RESULTS`; desativado por padrão)
|
|
297
297
|
- `--compact-result-chars` - limite de caracteres para compactação (substitui `GITLAB_MCP_COMPACT_RESULT_CHARS`; padrão `4000`)
|
|
298
298
|
- `--compact-tools` - nomes de ferramentas separados por vírgula para compactar quando a resposta for grande, sem ativar o compact global (substitui `GITLAB_MCP_COMPACT_TOOLS`)
|
|
@@ -592,7 +592,7 @@ ou
|
|
|
592
592
|
Private-Token: glpat-xxxxxxxxxxxxxxxxxxxx
|
|
593
593
|
```
|
|
594
594
|
|
|
595
|
-
O token é armazenado por sessão (identificada pelo header `mcp-session-id`) e reutilizado nas requisições seguintes da mesma sessão.
|
|
595
|
+
O token é armazenado por sessão (identificada pelo header `mcp-session-id`) e reutilizado nas requisições seguintes da mesma sessão. A sessão pertence ao usuário GitLab desse token: uma requisição com o token de outro usuário recebe `404 Session not found`, e `GET` / `DELETE /mcp` sem token recebem `401`.
|
|
596
596
|
|
|
597
597
|
#### Exemplo de configuração de autorização remota no Cursor
|
|
598
598
|
|
package/README.zh-CN.md
CHANGED
|
@@ -157,15 +157,15 @@ GitLab 合并请求、议题和流水线走此 MCP(@zereight/mcp-gitlab)。
|
|
|
157
157
|
| **Node.js** | >=18.17 | 通常 >=24 | stdio 经 `mcp-remote`,需要 Node.js 20+ |
|
|
158
158
|
| **许可证** | MIT | 因服务器而异 | GitLab 的一部分 |
|
|
159
159
|
|
|
160
|
-
### tools/list 体积(2026-10-
|
|
160
|
+
### tools/list 体积(2026-10-24 实测)
|
|
161
161
|
|
|
162
162
|
客户端会在会话开始时把整份 `tools/list` 发给模型。Token 估算为 UTF-8 字节 / 4。
|
|
163
163
|
|
|
164
164
|
| 配置 | 工具数 | JSON 字节 | 估算 token |
|
|
165
165
|
| ---- | -----: | --------: | ---------: |
|
|
166
|
-
| 默认(`core` + `discover_tools`) |
|
|
167
|
-
| `GITLAB_TOOL_PROFILE=slim` |
|
|
168
|
-
| `GITLAB_TOOLSETS=all` |
|
|
166
|
+
| 默认(`core` + `discover_tools` + `help`) | 40 | 50,682 | 12,671 |
|
|
167
|
+
| `GITLAB_TOOL_PROFILE=slim` | 39 | 49,646 | 12,412 |
|
|
168
|
+
| `GITLAB_TOOLSETS=all` | 276 | 285,677 | 71,420 |
|
|
169
169
|
|
|
170
170
|
更改描述或 schema 后,用 `npm run test:mock`(`test/tools-list-budget.test.ts`)重新测量。
|
|
171
171
|
|
|
@@ -252,7 +252,7 @@ command = lib.getExe inputs.gitlab-mcp.packages.${system}.default;
|
|
|
252
252
|
|
|
253
253
|
示例使用 `zereight-mcp-gitlab`,这是比旧的 `mcp-gitlab` 更不容易冲突的别名。如果 MCP 客户端找不到它,请使用 `which zereight-mcp-gitlab` 输出的绝对路径。
|
|
254
254
|
|
|
255
|
-
如果不想全局安装,请将 `npx` 固定到上一个稳定版本(即文档推荐的版本),例如 `npx -y @zereight/mcp-gitlab@2.3.
|
|
255
|
+
如果不想全局安装,请将 `npx` 固定到上一个稳定版本(即文档推荐的版本),例如 `npx -y @zereight/mcp-gitlab@2.3.8`。如果始终想使用最新版本,请改用 `npx -y @zereight/mcp-gitlab@latest`。如需在下一个稳定版本发布前试用已合并到 `main` 的修复,请使用 `npx -y @zereight/mcp-gitlab@next`(预发布版本,不适用于生产环境)。有新版本发布时,服务器会在启动时通过 stderr 提示(可用 `GITLAB_DISABLE_VERSION_CHECK=true` 关闭)。
|
|
256
256
|
|
|
257
257
|
#### Claude Desktop 一键安装(MCP Bundle)
|
|
258
258
|
|
|
@@ -292,7 +292,7 @@ v2.3.1 之后的每个 GitHub Release 都附带 `gitlab-mcp.mcpb` [MCP Bundle](h
|
|
|
292
292
|
- `--masking-config` - 掩码配置文件路径(替代 `GITLAB_MASKING_CONFIG`)
|
|
293
293
|
- `--masking-policy-file` - 受保护的托管策略文件路径(替代 `GITLAB_MASKING_POLICY_FILE`)
|
|
294
294
|
- `--masking-workspace-dir` - 用于解析掩码文件的目录(替代 `GITLAB_MASKING_WORKSPACE_DIR`)
|
|
295
|
-
- `--download-dir` - `download_attachment` 保存文件的目录(替代 `GITLAB_DOWNLOAD_DIR`,默认 `.gitlab-mcp-downloads`)
|
|
295
|
+
- `--download-dir` - `download_attachment` 和 `download_job_artifacts` 保存文件的目录(替代 `GITLAB_DOWNLOAD_DIR`,默认 `.gitlab-mcp-downloads`)
|
|
296
296
|
- `--compact-results=true` - 将过大的 MCP 工具回复截断为预览并附带 CLI 命令(替代 `GITLAB_MCP_COMPACT_RESULTS`,默认关闭)
|
|
297
297
|
- `--compact-result-chars` - compact 字符阈值(替代 `GITLAB_MCP_COMPACT_RESULT_CHARS`,默认 `4000`)
|
|
298
298
|
- `--compact-tools` - 以逗号分隔的工具名,仅在回复过大时对这些工具进行 compact,而不开启全局 compact(替代 `GITLAB_MCP_COMPACT_TOOLS`)
|
|
@@ -591,7 +591,7 @@ Authorization: Bearer glpat-xxxxxxxxxxxxxxxxxxxx
|
|
|
591
591
|
Private-Token: glpat-xxxxxxxxxxxxxxxxxxxx
|
|
592
592
|
```
|
|
593
593
|
|
|
594
|
-
token 按会话存储(由 `mcp-session-id`
|
|
594
|
+
token 按会话存储(由 `mcp-session-id` 请求头标识),并在同一会话的后续请求中复用。会话属于该 token 对应的 GitLab 用户:携带其他用户 token 的请求返回 `404 Session not found`,不带 token 的 `GET` / `DELETE /mcp` 返回 `401`。
|
|
595
595
|
|
|
596
596
|
#### Cursor 远程授权客户端配置示例
|
|
597
597
|
|
package/build/downloads/proxy.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Readable } from "node:stream";
|
|
2
2
|
import { pipeline } from "node:stream/promises";
|
|
3
|
+
import { parseProjectScopeHeader } from "../server/request-helpers.js";
|
|
3
4
|
import { decryptDownloadToken } from "../utils/download-token.js";
|
|
4
5
|
import { fetchWithValidatedRedirects, UnsafeRedirectError } from "../utils/safe-redirect-fetch.js";
|
|
5
6
|
const DEFAULT_DOWNLOAD_TIMEOUT_MS = 120_000;
|
|
@@ -12,15 +13,30 @@ function canonicalizeQueryParams(params) {
|
|
|
12
13
|
return JSON.stringify(normalized);
|
|
13
14
|
}
|
|
14
15
|
/**
|
|
15
|
-
*
|
|
16
|
+
* The project scope the request names in X-GitLab-Allowed-Project-Ids, parsed like
|
|
17
|
+
* the /mcp endpoint does. An empty list means the header does not apply.
|
|
18
|
+
*/
|
|
19
|
+
function readRequestProjectScope(req, deps) {
|
|
20
|
+
const value = req.get("X-GitLab-Allowed-Project-Ids");
|
|
21
|
+
if (!deps.enableDynamicProjectScope || value === undefined) {
|
|
22
|
+
return { projectIds: [] };
|
|
23
|
+
}
|
|
24
|
+
return parseProjectScopeHeader(value, deps.defaultAllowedProjectIds);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Check the requested project against the env allowlist (getEffectiveProjectId),
|
|
16
28
|
* against the allowlist sealed into the download token, since the proxy runs
|
|
17
|
-
* outside the session that issued it.
|
|
29
|
+
* outside the session that issued it, and against the request's own project scope.
|
|
30
|
+
* An empty list does not restrict.
|
|
18
31
|
*/
|
|
19
|
-
function resolveDownloadProjectId(deps, projectId, sealedProjectIds) {
|
|
32
|
+
function resolveDownloadProjectId(deps, projectId, sealedProjectIds, requestProjectIds) {
|
|
20
33
|
const effectiveProjectId = deps.getEffectiveProjectId(decodeURIComponent(projectId));
|
|
21
34
|
if (sealedProjectIds.length > 0 && !sealedProjectIds.includes(effectiveProjectId)) {
|
|
22
35
|
throw new Error(`Access denied: Project ${effectiveProjectId} is outside the project scope of this download token`);
|
|
23
36
|
}
|
|
37
|
+
if (requestProjectIds.length > 0 && !requestProjectIds.includes(effectiveProjectId)) {
|
|
38
|
+
throw new Error(`Access denied: Project ${effectiveProjectId} is outside the X-GitLab-Allowed-Project-Ids scope of this request`);
|
|
39
|
+
}
|
|
24
40
|
return effectiveProjectId;
|
|
25
41
|
}
|
|
26
42
|
/**
|
|
@@ -106,6 +122,12 @@ export function registerDownloadProxy(app, deps) {
|
|
|
106
122
|
return;
|
|
107
123
|
}
|
|
108
124
|
}
|
|
125
|
+
// Applies on both auth paths; a download token keeps its sealed scope as well
|
|
126
|
+
const requestScope = readRequestProjectScope(req, deps);
|
|
127
|
+
if ("error" in requestScope) {
|
|
128
|
+
res.status(401).json({ error: requestScope.error });
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
109
131
|
if (!checkDownloadRateLimit(rateLimitKey)) {
|
|
110
132
|
res.status(429).json({ error: "Rate limit exceeded" });
|
|
111
133
|
return;
|
|
@@ -133,7 +155,7 @@ export function registerDownloadProxy(app, deps) {
|
|
|
133
155
|
res.status(400).json({ error: "project_id and job_id are required" });
|
|
134
156
|
return;
|
|
135
157
|
}
|
|
136
|
-
const effectiveProjectId = resolveDownloadProjectId(deps, project_id, sealedProjectIds);
|
|
158
|
+
const effectiveProjectId = resolveDownloadProjectId(deps, project_id, sealedProjectIds, requestScope.projectIds);
|
|
137
159
|
gitlabUrl = `${apiUrl}/projects/${deps.encodeGitLabPathSegment(effectiveProjectId)}/jobs/${deps.encodeGitLabPathSegment(job_id)}/artifacts`;
|
|
138
160
|
break;
|
|
139
161
|
}
|
|
@@ -143,7 +165,7 @@ export function registerDownloadProxy(app, deps) {
|
|
|
143
165
|
res.status(400).json({ error: "project_id, secret, and filename are required" });
|
|
144
166
|
return;
|
|
145
167
|
}
|
|
146
|
-
const effectiveProjectId = resolveDownloadProjectId(deps, project_id, sealedProjectIds);
|
|
168
|
+
const effectiveProjectId = resolveDownloadProjectId(deps, project_id, sealedProjectIds, requestScope.projectIds);
|
|
147
169
|
// The uploads route takes one filename segment; a slash inside the name must
|
|
148
170
|
// stay inside that segment instead of turning into another route level.
|
|
149
171
|
gitlabUrl = `${apiUrl}/projects/${deps.encodeGitLabPathSegment(effectiveProjectId)}/uploads/${deps.encodeGitLabPathSegment(secret)}/${deps.encodeGitLabPathSegment(filename)}`;
|
|
@@ -157,7 +179,7 @@ export function registerDownloadProxy(app, deps) {
|
|
|
157
179
|
.json({ error: "project_id, tag_name, and direct_asset_path are required" });
|
|
158
180
|
return;
|
|
159
181
|
}
|
|
160
|
-
const effectiveProjectId = resolveDownloadProjectId(deps, project_id, sealedProjectIds);
|
|
182
|
+
const effectiveProjectId = resolveDownloadProjectId(deps, project_id, sealedProjectIds, requestScope.projectIds);
|
|
161
183
|
gitlabUrl = `${apiUrl}/projects/${deps.encodeGitLabPathSegment(effectiveProjectId)}/releases/${deps.encodeGitLabPathSegment(tag_name)}/downloads/${deps.encodeGitLabPath(direct_asset_path)}`;
|
|
162
184
|
break;
|
|
163
185
|
}
|
package/build/index.js
CHANGED
|
@@ -102,7 +102,7 @@ import { listMcpResources, listMcpResourceTemplates, readMcpResource, } from "./
|
|
|
102
102
|
import { getMcpPrompt, listMcpPrompts } from "./server/mcp-prompts.js";
|
|
103
103
|
import { MCP_INSTRUCTIONS } from "./server/mcp-instructions.js";
|
|
104
104
|
import { formatUnknownHelpTopic, getWorkflowGuide, readHelpTopic, } from "./server/mcp-help.js";
|
|
105
|
-
import { isInitializationRequestBody, isUnauthenticatedDiscoveryRequestBody, readAcceptHeader, readMcpSessionIdHeader, redactSessionIdForLog, } from "./server/request-helpers.js";
|
|
105
|
+
import { isInitializationRequestBody, isUnauthenticatedDiscoveryRequestBody, parseProjectScopeHeader, readAcceptHeader, readMcpSessionIdHeader, redactSessionIdForLog, } from "./server/request-helpers.js";
|
|
106
106
|
export { readMcpSessionIdHeader } from "./server/request-helpers.js";
|
|
107
107
|
import { authBySession, BASE_HEADERS, bindSessionProjectScope, buildAuthHeaders, configureGitLabRequestContext, getEffectiveAllowedProjectIds, getEffectiveApiUrl, getFetchConfig, SESSION_PROJECT_SCOPE_MISMATCH, sessionAuthStore, updateSessionPublicBaseUrl, usesJobTokenHeader, withPublicBaseUrl, } from "./server/gitlab-request-context.js";
|
|
108
108
|
import { apiUrlUserinfoWarning, commaSplitHint, configuredApiUrlErrors, encodeGitLabPath, encodeGitLabPathSegment, invalidListEntryError, isCleartextRemoteUrl, normalizeGitLabApiUrl, parseConfiguredGitLabApiUrls, } from "./utils/url.js";
|
|
@@ -5764,7 +5764,7 @@ async function listJobArtifacts(projectId, jobId, options = {}) {
|
|
|
5764
5764
|
*
|
|
5765
5765
|
* @param {string} projectId - The ID or URL-encoded path of the project
|
|
5766
5766
|
* @param {string} jobId - The ID of the job
|
|
5767
|
-
* @param {string} localPath - Optional
|
|
5767
|
+
* @param {string} localPath - Optional subdirectory of the download directory to save the archive in
|
|
5768
5768
|
* @returns {Promise<string>} The path where the artifact archive was saved
|
|
5769
5769
|
*/
|
|
5770
5770
|
async function downloadJobArtifacts(projectId, jobId, localPath) {
|
|
@@ -5780,9 +5780,16 @@ async function downloadJobArtifacts(projectId, jobId, localPath) {
|
|
|
5780
5780
|
if (!response.body) {
|
|
5781
5781
|
throw new Error("No response body from GitLab");
|
|
5782
5782
|
}
|
|
5783
|
-
//
|
|
5784
|
-
|
|
5785
|
-
|
|
5783
|
+
// local_path comes from the model, so the archive is confined to the download
|
|
5784
|
+
// directory like attachments, and an existing file is never replaced.
|
|
5785
|
+
const { stream: saveStream, path: savePath } = openSafeOutputWriteStream(filename, localPath, "local_path", resolveDownloadRoot(GITLAB_DOWNLOAD_DIR), { exclusive: true, rejectDotNames: true });
|
|
5786
|
+
try {
|
|
5787
|
+
await streamPipeline(response.body, saveStream);
|
|
5788
|
+
}
|
|
5789
|
+
catch (error) {
|
|
5790
|
+
fs.rmSync(savePath, { force: true });
|
|
5791
|
+
throw error;
|
|
5792
|
+
}
|
|
5786
5793
|
return savePath;
|
|
5787
5794
|
}
|
|
5788
5795
|
/**
|
|
@@ -11327,6 +11334,8 @@ function buildDownloadProxyDeps() {
|
|
|
11327
11334
|
encodeGitLabPathSegment,
|
|
11328
11335
|
encodeGitLabPath,
|
|
11329
11336
|
getEffectiveProjectId,
|
|
11337
|
+
enableDynamicProjectScope: ENABLE_DYNAMIC_PROJECT_SCOPE,
|
|
11338
|
+
defaultAllowedProjectIds: GITLAB_ALLOWED_PROJECT_IDS,
|
|
11330
11339
|
getDispatcherForUrl: clientPool.getDispatcherForUrl.bind(clientPool),
|
|
11331
11340
|
fetch: undiciFetch,
|
|
11332
11341
|
logger,
|
|
@@ -11587,7 +11596,8 @@ async function startStreamableHTTPServer() {
|
|
|
11587
11596
|
};
|
|
11588
11597
|
// Rate limiting per session
|
|
11589
11598
|
const sessionRequestCounts = {};
|
|
11590
|
-
// MCP OAuth
|
|
11599
|
+
// MCP OAuth and REMOTE_AUTHORIZATION modes: the GitLab user each stateful
|
|
11600
|
+
// session belongs to. Once set, it only changes when the session is cleaned up.
|
|
11591
11601
|
const sessionOwners = Object.create(null);
|
|
11592
11602
|
/**
|
|
11593
11603
|
* Validate token format and length
|
|
@@ -11640,22 +11650,12 @@ async function startStreamableHTTPServer() {
|
|
|
11640
11650
|
let allowedProjectIds;
|
|
11641
11651
|
// Only process the requested project scope if the feature is enabled
|
|
11642
11652
|
if (ENABLE_DYNAMIC_PROJECT_SCOPE && requestedProjectScope !== undefined) {
|
|
11643
|
-
const
|
|
11644
|
-
|
|
11645
|
-
.
|
|
11646
|
-
|
|
11647
|
-
if (requested.length === 0) {
|
|
11648
|
-
logger.warn("Empty X-GitLab-Allowed-Project-Ids provided");
|
|
11649
|
-
return null;
|
|
11650
|
-
}
|
|
11651
|
-
if (GITLAB_ALLOWED_PROJECT_IDS.length > 0) {
|
|
11652
|
-
const outOfScope = requested.filter(id => !GITLAB_ALLOWED_PROJECT_IDS.includes(id));
|
|
11653
|
-
if (outOfScope.length > 0) {
|
|
11654
|
-
logger.warn(`X-GitLab-Allowed-Project-Ids requested projects outside GITLAB_ALLOWED_PROJECT_IDS: ${outOfScope.join(", ")}`);
|
|
11655
|
-
return null; // Reject if the header tries to widen the configured allowlist
|
|
11656
|
-
}
|
|
11653
|
+
const scope = parseProjectScopeHeader(requestedProjectScope, GITLAB_ALLOWED_PROJECT_IDS);
|
|
11654
|
+
if ("error" in scope) {
|
|
11655
|
+
logger.warn(scope.error);
|
|
11656
|
+
return null; // Reject an empty header, or one that tries to widen the configured allowlist
|
|
11657
11657
|
}
|
|
11658
|
-
allowedProjectIds =
|
|
11658
|
+
allowedProjectIds = scope.projectIds;
|
|
11659
11659
|
}
|
|
11660
11660
|
// Only process dynamic URL if the feature is enabled
|
|
11661
11661
|
if (ENABLE_DYNAMIC_API_URL && dynamicApiUrl) {
|
|
@@ -11785,6 +11785,11 @@ async function startStreamableHTTPServer() {
|
|
|
11785
11785
|
};
|
|
11786
11786
|
};
|
|
11787
11787
|
const sessionAuthTokensMatch = (left, right) => left.header === right.header && left.token === right.token && left.apiUrl === right.apiUrl;
|
|
11788
|
+
/**
|
|
11789
|
+
* Store a session's credential and bind the session to the credential's owner
|
|
11790
|
+
* (`options.owner` when the caller already resolved it). A credential of another
|
|
11791
|
+
* user than the bound owner is refused as "foreign".
|
|
11792
|
+
*/
|
|
11788
11793
|
const storeValidatedSessionAuth = async (targetSessionId, authData, publicBaseUrl, existing, options) => {
|
|
11789
11794
|
const current = authBySession[targetSessionId];
|
|
11790
11795
|
if (options?.skipIfUnchanged && current && sessionAuthTokensMatch(current, authData)) {
|
|
@@ -11793,9 +11798,16 @@ async function startStreamableHTTPServer() {
|
|
|
11793
11798
|
setAuthTimeout(targetSessionId);
|
|
11794
11799
|
return "unchanged";
|
|
11795
11800
|
}
|
|
11796
|
-
|
|
11801
|
+
const owner = options?.owner ?? (await resolveAuthOwnerUpstream(authData));
|
|
11802
|
+
if (owner === null) {
|
|
11797
11803
|
return "invalid";
|
|
11798
11804
|
}
|
|
11805
|
+
// Read after the GitLab lookup: a concurrent request may have bound the session meanwhile.
|
|
11806
|
+
const boundOwner = sessionOwners[targetSessionId];
|
|
11807
|
+
if (boundOwner !== undefined && boundOwner !== owner) {
|
|
11808
|
+
return "foreign";
|
|
11809
|
+
}
|
|
11810
|
+
sessionOwners[targetSessionId] = owner;
|
|
11799
11811
|
authBySession[targetSessionId] = withPublicBaseUrl(authData, publicBaseUrl, existing ?? current);
|
|
11800
11812
|
setAuthTimeout(targetSessionId);
|
|
11801
11813
|
return "stored";
|
|
@@ -12328,7 +12340,7 @@ async function startStreamableHTTPServer() {
|
|
|
12328
12340
|
// A credential for another user gets the same 404 as an unknown session, so it
|
|
12329
12341
|
// can neither use, stream from, nor close the session. A refreshed token for the
|
|
12330
12342
|
// same user still matches.
|
|
12331
|
-
const
|
|
12343
|
+
const rejectForeignOAuthSession = (req, res, next) => {
|
|
12332
12344
|
const sessionId = readMcpSessionIdHeader(req);
|
|
12333
12345
|
const owner = sessionId ? sessionOwners[sessionId] : undefined;
|
|
12334
12346
|
if (owner !== undefined && readRequestOwner(req, res) !== owner) {
|
|
@@ -12338,6 +12350,53 @@ async function startStreamableHTTPServer() {
|
|
|
12338
12350
|
}
|
|
12339
12351
|
next();
|
|
12340
12352
|
};
|
|
12353
|
+
// Same rule with REMOTE_AUTHORIZATION, where clients may leave out the headers:
|
|
12354
|
+
// a POST without credentials runs with the token stored for the session, while
|
|
12355
|
+
// GET and DELETE must carry a credential of the owner. Only a token that differs
|
|
12356
|
+
// from the stored one is looked up at GitLab.
|
|
12357
|
+
const rejectForeignRemoteSession = async (req, res, next) => {
|
|
12358
|
+
const sessionId = readMcpSessionIdHeader(req);
|
|
12359
|
+
const owner = sessionId ? sessionOwners[sessionId] : undefined;
|
|
12360
|
+
if (!sessionId || owner === undefined) {
|
|
12361
|
+
next();
|
|
12362
|
+
return;
|
|
12363
|
+
}
|
|
12364
|
+
const authData = parseAuthHeaders(req);
|
|
12365
|
+
if (!authData) {
|
|
12366
|
+
if (req.method === "POST") {
|
|
12367
|
+
next();
|
|
12368
|
+
return;
|
|
12369
|
+
}
|
|
12370
|
+
metrics.authFailures++;
|
|
12371
|
+
res.status(401).json({
|
|
12372
|
+
error: "Missing Private-Token, JOB-TOKEN, or Authorization header",
|
|
12373
|
+
message: "Remote authorization is enabled. Please provide Private-Token, JOB-TOKEN, or Authorization header.",
|
|
12374
|
+
});
|
|
12375
|
+
return;
|
|
12376
|
+
}
|
|
12377
|
+
const stored = authBySession[sessionId];
|
|
12378
|
+
const requestOwner = stored && sessionAuthTokensMatch(stored, authData)
|
|
12379
|
+
? owner
|
|
12380
|
+
: await resolveAuthOwnerUpstream(authData);
|
|
12381
|
+
if (requestOwner === null) {
|
|
12382
|
+
metrics.authFailures++;
|
|
12383
|
+
res.status(401).json({
|
|
12384
|
+
error: "Invalid GitLab authentication header",
|
|
12385
|
+
message: "The provided GitLab token was rejected by the configured GitLab API.",
|
|
12386
|
+
});
|
|
12387
|
+
return;
|
|
12388
|
+
}
|
|
12389
|
+
if (requestOwner !== owner) {
|
|
12390
|
+
metrics.authFailures++;
|
|
12391
|
+
res.status(404).json({ error: "Session not found" });
|
|
12392
|
+
return;
|
|
12393
|
+
}
|
|
12394
|
+
res.locals.sessionOwner = requestOwner;
|
|
12395
|
+
next();
|
|
12396
|
+
};
|
|
12397
|
+
const rejectForeignSession = GITLAB_MCP_OAUTH
|
|
12398
|
+
? rejectForeignOAuthSession
|
|
12399
|
+
: rejectForeignRemoteSession;
|
|
12341
12400
|
// Streamable HTTP endpoint - handles both session creation and message handling
|
|
12342
12401
|
app.post("/mcp", rejectUnknownStatefulSession, mcpRequestRateLimit, mcpBearerAuth, rejectForeignSession, mcpJsonBodyParser, async (req, res) => {
|
|
12343
12402
|
const sessionId = readMcpSessionIdHeader(req);
|
|
@@ -12355,8 +12414,8 @@ async function startStreamableHTTPServer() {
|
|
|
12355
12414
|
return;
|
|
12356
12415
|
}
|
|
12357
12416
|
const newRemoteAuthData = !sessionId && REMOTE_AUTHORIZATION ? parseAuthHeaders(req) : null;
|
|
12417
|
+
let newRemoteAuthOwner = null;
|
|
12358
12418
|
let unauthenticatedDiscoveryRequested = false;
|
|
12359
|
-
let remoteAuthValidatedForInit = false;
|
|
12360
12419
|
if (!sessionId && REMOTE_AUTHORIZATION) {
|
|
12361
12420
|
const allowUnauthenticatedDiscovery = GITLAB_ALLOW_UNAUTHENTICATED_TOOL_DISCOVERY &&
|
|
12362
12421
|
isUnauthenticatedDiscoveryRequestBody(req.body);
|
|
@@ -12369,16 +12428,16 @@ async function startStreamableHTTPServer() {
|
|
|
12369
12428
|
});
|
|
12370
12429
|
return;
|
|
12371
12430
|
}
|
|
12372
|
-
if (newRemoteAuthData && !(await validateAuthDataUpstream(newRemoteAuthData))) {
|
|
12373
|
-
metrics.authFailures++;
|
|
12374
|
-
res.status(401).json({
|
|
12375
|
-
error: "Invalid GitLab authentication header",
|
|
12376
|
-
message: "The provided GitLab token was rejected by the configured GitLab API.",
|
|
12377
|
-
});
|
|
12378
|
-
return;
|
|
12379
|
-
}
|
|
12380
12431
|
if (newRemoteAuthData) {
|
|
12381
|
-
|
|
12432
|
+
newRemoteAuthOwner = await resolveAuthOwnerUpstream(newRemoteAuthData);
|
|
12433
|
+
if (newRemoteAuthOwner === null) {
|
|
12434
|
+
metrics.authFailures++;
|
|
12435
|
+
res.status(401).json({
|
|
12436
|
+
error: "Invalid GitLab authentication header",
|
|
12437
|
+
message: "The provided GitLab token was rejected by the configured GitLab API.",
|
|
12438
|
+
});
|
|
12439
|
+
return;
|
|
12440
|
+
}
|
|
12382
12441
|
}
|
|
12383
12442
|
}
|
|
12384
12443
|
// Rate limiting check for existing sessions
|
|
@@ -12416,7 +12475,7 @@ async function startStreamableHTTPServer() {
|
|
|
12416
12475
|
}
|
|
12417
12476
|
// Store auth only when provided. Public discovery intentionally leaves the session unauthenticated.
|
|
12418
12477
|
if (authData) {
|
|
12419
|
-
const result = await storeValidatedSessionAuth(sessionId, authData, publicBaseUrl);
|
|
12478
|
+
const result = await storeValidatedSessionAuth(sessionId, authData, publicBaseUrl, undefined, { owner: res.locals.sessionOwner });
|
|
12420
12479
|
if (result === "invalid") {
|
|
12421
12480
|
metrics.authFailures++;
|
|
12422
12481
|
res.status(401).json({
|
|
@@ -12425,7 +12484,11 @@ async function startStreamableHTTPServer() {
|
|
|
12425
12484
|
});
|
|
12426
12485
|
return;
|
|
12427
12486
|
}
|
|
12428
|
-
|
|
12487
|
+
if (result === "foreign") {
|
|
12488
|
+
metrics.authFailures++;
|
|
12489
|
+
res.status(404).json({ error: "Session not found" });
|
|
12490
|
+
return;
|
|
12491
|
+
}
|
|
12429
12492
|
if (result === "stored") {
|
|
12430
12493
|
logger.info(`Session ${redactSessionIdForLog(sessionId)}: stored ${authData.header} header`);
|
|
12431
12494
|
}
|
|
@@ -12442,7 +12505,7 @@ async function startStreamableHTTPServer() {
|
|
|
12442
12505
|
res.status(401).json(SESSION_PROJECT_SCOPE_MISMATCH);
|
|
12443
12506
|
return;
|
|
12444
12507
|
}
|
|
12445
|
-
const result = await storeValidatedSessionAuth(sessionId, { ...authData, allowedProjectIds }, publicBaseUrl, authBySession[sessionId], { skipIfUnchanged: true });
|
|
12508
|
+
const result = await storeValidatedSessionAuth(sessionId, { ...authData, allowedProjectIds }, publicBaseUrl, authBySession[sessionId], { skipIfUnchanged: true, owner: res.locals.sessionOwner });
|
|
12446
12509
|
if (result === "invalid") {
|
|
12447
12510
|
metrics.authFailures++;
|
|
12448
12511
|
res.status(401).json({
|
|
@@ -12451,7 +12514,11 @@ async function startStreamableHTTPServer() {
|
|
|
12451
12514
|
});
|
|
12452
12515
|
return;
|
|
12453
12516
|
}
|
|
12454
|
-
|
|
12517
|
+
if (result === "foreign") {
|
|
12518
|
+
metrics.authFailures++;
|
|
12519
|
+
res.status(404).json({ error: "Session not found" });
|
|
12520
|
+
return;
|
|
12521
|
+
}
|
|
12455
12522
|
if (result === "stored") {
|
|
12456
12523
|
logger.debug(`Session ${redactSessionIdForLog(sessionId)}: updated ${authData.header} header`);
|
|
12457
12524
|
}
|
|
@@ -12542,7 +12609,8 @@ async function startStreamableHTTPServer() {
|
|
|
12542
12609
|
// Store auth for newly created session in remote mode
|
|
12543
12610
|
if (REMOTE_AUTHORIZATION && !authBySession[newSessionId]) {
|
|
12544
12611
|
const authData = parseAuthHeaders(req);
|
|
12545
|
-
if (authData &&
|
|
12612
|
+
if (authData && newRemoteAuthOwner !== null) {
|
|
12613
|
+
sessionOwners[newSessionId] = newRemoteAuthOwner;
|
|
12546
12614
|
authBySession[newSessionId] = withPublicBaseUrl(authData, publicBaseUrl);
|
|
12547
12615
|
logger.info(`Session ${redactSessionIdForLog(newSessionId)}: stored ${authData.header} header`);
|
|
12548
12616
|
setAuthTimeout(newSessionId);
|
package/build/schemas.js
CHANGED
|
@@ -3870,7 +3870,7 @@ export const DownloadJobArtifactsSchema = z.object({
|
|
|
3870
3870
|
local_path: z
|
|
3871
3871
|
.string()
|
|
3872
3872
|
.optional()
|
|
3873
|
-
.describe("
|
|
3873
|
+
.describe("Subdirectory of the download directory to save the archive in (optional, defaults to the download directory itself). Names starting with a dot are rejected"),
|
|
3874
3874
|
});
|
|
3875
3875
|
export const DownloadJobArtifactsRemoteSchema = z.object({
|
|
3876
3876
|
project_id: z.coerce.string().describe("Project ID or URL-encoded path"),
|
|
@@ -43,6 +43,28 @@ export function isUnauthenticatedDiscoveryRequestBody(body) {
|
|
|
43
43
|
return body.every(isDiscoveryMethod);
|
|
44
44
|
return isDiscoveryMethod(body);
|
|
45
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Parse an `X-GitLab-Allowed-Project-Ids` value: comma-separated project ids or
|
|
48
|
+
* paths, compared verbatim. The header may only narrow GITLAB_ALLOWED_PROJECT_IDS,
|
|
49
|
+
* so a value naming no project, or one outside a non-empty `configuredProjectIds`,
|
|
50
|
+
* is an error.
|
|
51
|
+
*/
|
|
52
|
+
export function parseProjectScopeHeader(value, configuredProjectIds) {
|
|
53
|
+
const projectIds = value
|
|
54
|
+
.split(",")
|
|
55
|
+
.map(id => id.trim())
|
|
56
|
+
.filter(Boolean);
|
|
57
|
+
if (projectIds.length === 0) {
|
|
58
|
+
return { error: "Empty X-GitLab-Allowed-Project-Ids provided" };
|
|
59
|
+
}
|
|
60
|
+
const outOfScope = projectIds.filter(id => !configuredProjectIds.includes(id));
|
|
61
|
+
if (configuredProjectIds.length > 0 && outOfScope.length > 0) {
|
|
62
|
+
return {
|
|
63
|
+
error: `X-GitLab-Allowed-Project-Ids requested projects outside GITLAB_ALLOWED_PROJECT_IDS: ${outOfScope.join(", ")}`,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
return { projectIds };
|
|
67
|
+
}
|
|
46
68
|
/**
|
|
47
69
|
* Normalize an `Mcp-Session-Id` header value.
|
|
48
70
|
*
|
package/build/tools/registry.js
CHANGED
|
@@ -845,7 +845,7 @@ export const allTools = [
|
|
|
845
845
|
name: "download_job_artifacts",
|
|
846
846
|
description: IS_REMOTE
|
|
847
847
|
? "Get a download URL for a job's artifact archive (zip)"
|
|
848
|
-
: "Download job artifact archive (zip) and save
|
|
848
|
+
: "Download job artifact archive (zip) and save it under the download directory",
|
|
849
849
|
inputSchema: IS_REMOTE
|
|
850
850
|
? toJSONSchema(DownloadJobArtifactsRemoteSchema)
|
|
851
851
|
: toJSONSchema(DownloadJobArtifactsSchema),
|
|
@@ -35,7 +35,7 @@ const TOOL_GUIDANCE = {
|
|
|
35
35
|
update_issue: "Change fields on an existing issue. Use `update_issue_description_patch` for a targeted description edit and `create_issue_note` for discussion.",
|
|
36
36
|
delete_issue: "Permanently delete an issue. Use `update_issue` to close or edit without deleting.",
|
|
37
37
|
delete_issue_link: "Remove a relationship between two issues. Verify first with `list_issue_links` or `get_issue_link`.",
|
|
38
|
-
download_job_artifacts: "Retrieve a job artifact archive. Remote HTTP returns a download URL; local stdio saves
|
|
38
|
+
download_job_artifacts: "Retrieve a job artifact archive. Remote HTTP returns a download URL; local stdio saves under GITLAB_DOWNLOAD_DIR, never overwrites, and is rejected in readonly mode.",
|
|
39
39
|
download_attachment: "Retrieve a project attachment. Remote HTTP returns inline base64 or a URL; local stdio saves under GITLAB_DOWNLOAD_DIR and never overwrites.",
|
|
40
40
|
gitlab_api_request: "Send one GitLab REST call under /api/v4. Readonly allows GET only; modify rejects DELETE. Enable only by listing api in GITLAB_TOOLSETS; all, discover_tools, and GITLAB_TOOLS do not. Prompt injection can drive this tool, so operators who rely on group, project, or tool restrictions must not enable it. With GITLAB_ALLOWED_PROJECT_IDS or a session project scope, only /projects/:id paths for an allowed project are accepted; body and query parameters that name another project are not checked.",
|
|
41
41
|
execute_graphql: "Use only when no typed REST tool covers the operation. The query is sent directly and may include mutations.",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zereight/mcp-gitlab",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.10-next.156",
|
|
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": [
|