@zereight/mcp-gitlab 2.3.28-next.243 → 2.3.28-next.245

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
@@ -16,7 +16,7 @@
16
16
 
17
17
  **기본 노출: 40개 도구** (`core` 38개 + `discover_tools` + `help`). 전체는 288개(toolset 285개 + `execute_graphql` + `discover_tools` + `help`). 작게 시작하고, 세션에서 `discover_tools`로 확장하세요.
18
18
 
19
- > **토큰 예산:** MCP 클라이언트는 세션 시작 때 `tools/list` 전체를 모델에 보냅니다. 기본값(~40개 도구, 스키마 ~12k 토큰)을 유지하세요. 확장은 `discover_tools`로 이 세션에만 카테고리를 켜거나(`OAUTH_STATELESS_MODE=true`면 `GITLAB_TOOLSETS`로 남기세요), [Skill + CLI](./docs/getting-started/cli-without-mcp.md)로 MCP 스키마를 건너뛰세요. **`GITLAB_TOOLSETS=all`은 쓰지 마세요** — 거의 모든 도구를 올려 스키마만 ~73k 토큰입니다. [tools/list 크기](#toolslist-크기-2026-11-05-실측)와 [비교](./docs/comparison/index.md)를 보세요.
19
+ > **토큰 예산:** MCP 클라이언트는 세션 시작 때 `tools/list` 전체를 모델에 보냅니다. 기본값(~40개 도구, 스키마 ~12k 토큰)을 유지하세요. 확장은 `discover_tools`로 이 세션에만 카테고리를 켜거나(`OAUTH_STATELESS_MODE=true`면 `GITLAB_TOOLSETS`로 남기세요), [Skill + CLI](./docs/getting-started/cli-without-mcp.md)로 MCP 스키마를 건너뛰세요. **`GITLAB_TOOLSETS=all`은 쓰지 마세요** — 거의 모든 도구를 올려 스키마만 ~73k 토큰입니다. [tools/list 크기](#toolslist-크기-2026-11-14-실측)와 [비교](./docs/comparison/index.md)를 보세요.
20
20
 
21
21
  `zereight-mcp-gitlab` 바이너리를 먼저 설치하세요. `npm install -g @zereight/mcp-gitlab`, 또는 Homebrew `brew tap zereight/gitlab-mcp https://github.com/zereight/gitlab-mcp` 다음 `brew install zereight/gitlab-mcp/zereight-mcp-gitlab`. 공식 MCP Registry 항목: [`io.github.zereight/gitlab-mcp`](https://registry.modelcontextprotocol.io/?q=io.github.zereight%2Fgitlab-mcp). 한 줄 설치: `npx -y @zereight/mcp-gitlab@latest`.
22
22
 
@@ -167,15 +167,15 @@ PAT, OAuth, 읽기 전용 모드, 동적 API URL, 원격 인증을 지원하며
167
167
  | **Node.js** | >=20.0.0 | 보통 >=24 | stdio는 `mcp-remote`, Node.js 20+ |
168
168
  | **라이선스** | MIT | 서버마다 다름 | GitLab의 일부 |
169
169
 
170
- ### tools/list 크기 (2026-11-05 실측)
170
+ ### tools/list 크기 (2026-11-14 실측)
171
171
 
172
172
  클라이언트는 세션 시작 때 `tools/list` 전체를 모델에 보냅니다. 토큰 추정은 UTF-8 바이트 / 4입니다.
173
173
 
174
174
  | 프로필 | 도구 수 | JSON 바이트 | 추정 토큰 |
175
175
  | ------ | ------: | ----------: | --------: |
176
- | 기본값 (`core` + `discover_tools` + `help`) | 40 | 46,943 | 11,736 |
177
- | `GITLAB_TOOL_PROFILE=slim` | 39 | 45,935 | 11,484 |
178
- | `GITLAB_TOOLSETS=all` | 286 | 293,906 | 73,477 |
176
+ | 기본값 (`core` + `discover_tools` + `help`) | 40 | 47,822 | 11,956 |
177
+ | `GITLAB_TOOL_PROFILE=slim` | 39 | 46,814 | 11,704 |
178
+ | `GITLAB_TOOLSETS=all` | 286 | 295,933 | 73,984 |
179
179
 
180
180
  설명이나 스키마를 바꾼 뒤에는 `npm run build && npm run test:mock` (`test/tools-list-budget.test.ts`)으로 다시 측정하세요.
181
181
 
package/README.md CHANGED
@@ -21,7 +21,7 @@
21
21
 
22
22
  **Default: 40 tools** (38 `core` + `discover_tools` + `help`). 288 tools exist in total (285 in toolsets + `execute_graphql` + `discover_tools` + `help`). Start lean; call `discover_tools` to activate more for this session.
23
23
 
24
- > **Token budget:** MCP clients send the whole `tools/list` to the model at session start. Keep the default (~40 tools, ~12k schema tokens). Call `discover_tools` to activate a category for this session (session-only; with `OAUTH_STATELESS_MODE=true` persist a named `GITLAB_TOOLSETS` list), or use [Skill + CLI](./docs/getting-started/cli-without-mcp.md) and skip MCP schemas. **Do not set `GITLAB_TOOLSETS=all`** — it loads ~all tools and costs ~73k schema tokens. See [tools/list size](#toolslist-size-measured-2026-11-05) and [comparison](./docs/comparison/index.md).
24
+ > **Token budget:** MCP clients send the whole `tools/list` to the model at session start. Keep the default (~40 tools, ~12k schema tokens). Call `discover_tools` to activate a category for this session (session-only; with `OAUTH_STATELESS_MODE=true` persist a named `GITLAB_TOOLSETS` list), or use [Skill + CLI](./docs/getting-started/cli-without-mcp.md) and skip MCP schemas. **Do not set `GITLAB_TOOLSETS=all`** — it loads ~all tools and costs ~73k schema tokens. See [tools/list size](#toolslist-size-measured-2026-11-14) and [comparison](./docs/comparison/index.md).
25
25
 
26
26
  Install the `zereight-mcp-gitlab` binary first with `npm install -g @zereight/mcp-gitlab`, or Homebrew `brew tap zereight/gitlab-mcp https://github.com/zereight/gitlab-mcp` and `brew install zereight/gitlab-mcp/zereight-mcp-gitlab`. Official MCP Registry listing: [`io.github.zereight/gitlab-mcp`](https://registry.modelcontextprotocol.io/?q=io.github.zereight%2Fgitlab-mcp). One-liner: `npx -y @zereight/mcp-gitlab@latest`.
27
27
 
@@ -172,15 +172,15 @@ Supports PAT, OAuth, read-only mode, dynamic API URLs, and remote authorization
172
172
  | **Node.js** | >=20.0.0 | Often >=24 | Node.js 20+ for stdio via `mcp-remote` |
173
173
  | **License** | MIT | Varies | Part of GitLab |
174
174
 
175
- ### tools/list size (measured 2026-11-05)
175
+ ### tools/list size (measured 2026-11-14)
176
176
 
177
177
  A client sends the whole `tools/list` result to the model at session start. Token estimate is UTF-8 bytes / 4.
178
178
 
179
179
  | Profile | Tools | JSON bytes | Est. tokens |
180
180
  | ------- | ----: | ---------: | ----------: |
181
- | Default (`core` + `discover_tools` + `help`) | 40 | 46,943 | 11,736 |
182
- | `GITLAB_TOOL_PROFILE=slim` | 39 | 45,935 | 11,484 |
183
- | `GITLAB_TOOLSETS=all` | 286 | 293,906 | 73,477 |
181
+ | Default (`core` + `discover_tools` + `help`) | 40 | 47,822 | 11,956 |
182
+ | `GITLAB_TOOL_PROFILE=slim` | 39 | 46,814 | 11,704 |
183
+ | `GITLAB_TOOLSETS=all` | 286 | 295,933 | 73,984 |
184
184
 
185
185
  Re-measure with `npm run build && npm run test:mock` (`test/tools-list-budget.test.ts`) after description or schema changes.
186
186
 
@@ -804,7 +804,7 @@ Register the skill directory in your AI client to get optimal tool usage guidanc
804
804
  9. `search_repositories` - Search for GitLab projects
805
805
  10. `create_repository` - Create a new GitLab project
806
806
  11. `create_group` - Create new group or subgroup
807
- 12. `get_file_contents` - Get contents of a file or directory from a GitLab project
807
+ 12. `get_file_contents` - Get the contents of one file from a GitLab project
808
808
  13. `push_files` - Push multiple files in a single commit
809
809
  14. `create_issue` - Create a new issue
810
810
  15. `create_merge_request` - Create a new merge request
package/README.pt-BR.md CHANGED
@@ -16,7 +16,7 @@
16
16
 
17
17
  **Padrão: 40 ferramentas** (38 `core` + `discover_tools` + `help`). Existem 288 no total (285 em toolsets + `execute_graphql` + `discover_tools` + `help`). Comece enxuto; chame `discover_tools` para ativar mais nesta sessão.
18
18
 
19
- > **Orçamento de tokens:** clientes MCP enviam o `tools/list` inteiro ao modelo no início da sessão. Mantenha o padrão (~40 ferramentas, ~12k tokens de schema). Chame `discover_tools` para ativar uma categoria nesta sessão (somente nesta sessão; com `OAUTH_STATELESS_MODE=true` persista uma lista `GITLAB_TOOLSETS`), ou use [Skill + CLI](./docs/getting-started/cli-without-mcp.md) e pule os schemas MCP. **Não defina `GITLAB_TOOLSETS=all`** — carrega quase todas as ferramentas e custa ~73k tokens de schema. Veja [tamanho do tools/list](#tamanho-do-toolslist-medido-em-2026-11-05) e [comparação](./docs/comparison/index.md).
19
+ > **Orçamento de tokens:** clientes MCP enviam o `tools/list` inteiro ao modelo no início da sessão. Mantenha o padrão (~40 ferramentas, ~12k tokens de schema). Chame `discover_tools` para ativar uma categoria nesta sessão (somente nesta sessão; com `OAUTH_STATELESS_MODE=true` persista uma lista `GITLAB_TOOLSETS`), ou use [Skill + CLI](./docs/getting-started/cli-without-mcp.md) e pule os schemas MCP. **Não defina `GITLAB_TOOLSETS=all`** — carrega quase todas as ferramentas e custa ~73k tokens de schema. Veja [tamanho do tools/list](#tamanho-do-toolslist-medido-em-2026-11-14) e [comparação](./docs/comparison/index.md).
20
20
 
21
21
  Instale o binário `zereight-mcp-gitlab` antes. `npm install -g @zereight/mcp-gitlab`, ou Homebrew `brew tap zereight/gitlab-mcp https://github.com/zereight/gitlab-mcp` e `brew install zereight/gitlab-mcp/zereight-mcp-gitlab`. Listagem oficial no MCP Registry: [`io.github.zereight/gitlab-mcp`](https://registry.modelcontextprotocol.io/?q=io.github.zereight%2Fgitlab-mcp). Instalação em uma linha: `npx -y @zereight/mcp-gitlab@latest`.
22
22
 
@@ -167,15 +167,15 @@ Suporta PAT, OAuth, modo somente leitura, URLs de API dinâmicas e autorização
167
167
  | **Node.js** | >=20.0.0 | Frequentemente >=24 | Node.js 20+ para stdio via `mcp-remote` |
168
168
  | **Licença** | MIT | Varia | Parte do GitLab |
169
169
 
170
- ### Tamanho do tools/list (medido em 2026-11-05)
170
+ ### Tamanho do tools/list (medido em 2026-11-14)
171
171
 
172
172
  O cliente envia o `tools/list` inteiro ao modelo no início da sessão. A estimativa de tokens é bytes UTF-8 / 4.
173
173
 
174
174
  | Perfil | Ferramentas | Bytes JSON | Tokens estimados |
175
175
  | ------ | ----------: | ---------: | ---------------: |
176
- | Padrão (`core` + `discover_tools` + `help`) | 40 | 46.943 | 11.736 |
177
- | `GITLAB_TOOL_PROFILE=slim` | 39 | 45.935 | 11.484 |
178
- | `GITLAB_TOOLSETS=all` | 286 | 293.906 | 73.477 |
176
+ | Padrão (`core` + `discover_tools` + `help`) | 40 | 47.822 | 11.956 |
177
+ | `GITLAB_TOOL_PROFILE=slim` | 39 | 46.814 | 11.704 |
178
+ | `GITLAB_TOOLSETS=all` | 286 | 295.933 | 73.984 |
179
179
 
180
180
  Após alterar descrições ou schemas, meça de novo com `npm run build && npm run test:mock` (`test/tools-list-budget.test.ts`).
181
181
 
package/README.zh-CN.md CHANGED
@@ -16,7 +16,7 @@
16
16
 
17
17
  **默认暴露 40 个工具**(38 个 `core` + `discover_tools` + `help`)。总共 288 个(toolset 中 285 个 + `execute_graphql` + `discover_tools` + `help`)。先用精简集,再在本会话中用 `discover_tools` 扩展。
18
18
 
19
- > **Token 预算:** MCP 客户端会在会话开始时把整份 `tools/list` 发给模型。请保持默认(约 40 个工具,约 12k schema token)。用 `discover_tools` 为本会话激活类别(仅限本会话;`OAUTH_STATELESS_MODE=true` 时请改用命名的 `GITLAB_TOOLSETS`),或走 [Skill + CLI](./docs/getting-started/cli-without-mcp.md) 以跳过 MCP schema。**不要设置 `GITLAB_TOOLSETS=all`** — 它会加载几乎全部工具,schema 约 73k token。见 [tools/list 体积](#toolslist-体积2026-11-05-实测) 和 [对比](./docs/comparison/index.md)。
19
+ > **Token 预算:** MCP 客户端会在会话开始时把整份 `tools/list` 发给模型。请保持默认(约 40 个工具,约 12k schema token)。用 `discover_tools` 为本会话激活类别(仅限本会话;`OAUTH_STATELESS_MODE=true` 时请改用命名的 `GITLAB_TOOLSETS`),或走 [Skill + CLI](./docs/getting-started/cli-without-mcp.md) 以跳过 MCP schema。**不要设置 `GITLAB_TOOLSETS=all`** — 它会加载几乎全部工具,schema 约 73k token。见 [tools/list 体积](#toolslist-体积2026-11-14-实测) 和 [对比](./docs/comparison/index.md)。
20
20
 
21
21
  先安装 `zereight-mcp-gitlab` 二进制。`npm install -g @zereight/mcp-gitlab`,或 Homebrew `brew tap zereight/gitlab-mcp https://github.com/zereight/gitlab-mcp` 然后 `brew install zereight/gitlab-mcp/zereight-mcp-gitlab`。官方 MCP Registry 条目:[`io.github.zereight/gitlab-mcp`](https://registry.modelcontextprotocol.io/?q=io.github.zereight%2Fgitlab-mcp)。一键安装:`npx -y @zereight/mcp-gitlab@latest`。
22
22
 
@@ -167,15 +167,15 @@ GitLab 合并请求、议题和流水线走此 MCP(@zereight/mcp-gitlab)。
167
167
  | **Node.js** | >=20.0.0 | 通常 >=24 | stdio 经 `mcp-remote`,需要 Node.js 20+ |
168
168
  | **许可证** | MIT | 因服务器而异 | GitLab 的一部分 |
169
169
 
170
- ### tools/list 体积(2026-11-05 实测)
170
+ ### tools/list 体积(2026-11-14 实测)
171
171
 
172
172
  客户端会在会话开始时把整份 `tools/list` 发给模型。Token 估算为 UTF-8 字节 / 4。
173
173
 
174
174
  | 配置 | 工具数 | JSON 字节 | 估算 token |
175
175
  | ---- | -----: | --------: | ---------: |
176
- | 默认(`core` + `discover_tools` + `help`) | 40 | 46,943 | 11,736 |
177
- | `GITLAB_TOOL_PROFILE=slim` | 39 | 45,935 | 11,484 |
178
- | `GITLAB_TOOLSETS=all` | 286 | 293,906 | 73,477 |
176
+ | 默认(`core` + `discover_tools` + `help`) | 40 | 47,822 | 11,956 |
177
+ | `GITLAB_TOOL_PROFILE=slim` | 39 | 46,814 | 11,704 |
178
+ | `GITLAB_TOOLSETS=all` | 286 | 295,933 | 73,984 |
179
179
 
180
180
  更改描述或 schema 后,用 `npm run build && npm run test:mock`(`test/tools-list-budget.test.ts`)重新测量。
181
181
 
package/build/index.js CHANGED
@@ -123,7 +123,7 @@ import { fetchStatusBeforeDeadline } from "./utils/poll-deadline.js";
123
123
  import { getUniqueApprovalUsers, inferMergeRequestApproved, MERGE_REQUEST_DEPLOYMENT_SUMMARY_LIMIT, parseApprovalsResponse, sortDeploymentsByCreatedAtDesc, toMergeRequestDeploymentSummaryRecord, } from "./utils/merge-request-summary.js";
124
124
  import { parseGitLabVersionApiResponse, } from "./utils/gitlab-instance-version.js";
125
125
  import { buildBulkPublishDraftNotesBody, needsGitLab19_2BulkPublish, } from "./utils/bulk-publish-options.js";
126
- import { appendFilterParam, appendFilterParams, cleanMutuallyExclusiveIdUsernameOptions, dropBlankArrayEntries, isBlankFilterValue, LIST_MERGE_REQUESTS_ID_USERNAME_PAIRS, sanitizeToolArguments, } from "./utils/tool-args.js";
126
+ import { appendFilterParams, cleanMutuallyExclusiveIdUsernameOptions, dropBlankArrayEntries, isBlankFilterValue, LIST_MERGE_REQUESTS_ID_USERNAME_PAIRS, sanitizeToolArguments, } from "./utils/tool-args.js";
127
127
  import { applyJmespathToToolResult, getJmespathSyntaxError, JMESPATH_TOOL_ARGUMENT, JMESPATH_TOOL_ARGUMENT_DESCRIPTION, omitJmespathArgument, readJmespathExpression, } from "./utils/jmespath-tool-result.js";
128
128
  import { appendRecoveryHint, withRecoveryHint } from "./utils/error-hints.js";
129
129
  import { applyListSummaryToToolResult, omitListSummaryArgument, readListSummaryRequested, toolAcceptsDecoratedSummary, toolUsesListSummaryDefault, } from "./utils/list-summary.js";
@@ -136,6 +136,7 @@ import { configureWikiTools, handleWikiToolCall } from "./tools/wiki.js";
136
136
  import { configureMilestoneTools, handleMilestoneToolCall } from "./tools/milestones.js";
137
137
  import { configureLabelTools, handleLabelToolCall } from "./tools/labels.js";
138
138
  import { configureTagTools, handleTagToolCall } from "./tools/tags.js";
139
+ import { configureVariableTools, handleVariableToolCall } from "./tools/variables.js";
139
140
  import { buildUnavailableToolMessage, isSkippedByDiscoverActivation, } from "./tools/discover-activation.js";
140
141
  import { selectCallableHiddenToolNames, selectExposedTools } from "./tools/exposed-tools.js";
141
142
  import { createListedToolsCache, decorateToolsForList, } from "./tools/listed-tools.js";
@@ -146,7 +147,7 @@ import { BulkPublishDraftNotesSchema, CancelPipelineJobSchema, ErasePipelineJobS
146
147
  GitLabDiscussionNoteSchema, // Added
147
148
  GitLabDiscussionSchema,
148
149
  // Draft Notes Schemas
149
- GitLabDraftNoteSchema, GitLabForkSchema, GitLabBranchSchema, GitLabProtectedBranchSchema, GitLabGroupSchema, GitLabIssueLinkSchema, GitLabIssueSchema, GitLabIssueWithLinkDetailsSchema, GitLabMarkdownUploadSchema, GitLabMergeRequestPipelineSchema, GitLabMergeRequestSchema, GitLabNamespaceExistsResponseSchema, GitLabNamespaceSchema, GitLabPipelineJobSchema, GitLabDeploymentSchema, GitLabEnvironmentSchema, GitLabPipelineSchema, GitLabPipelineScheduleSchema, GitLabPipelineScheduleVariableSchema, GitLabPipelineSchedulePlayResultSchema, ListPipelineSchedulesSchema, GetPipelineScheduleSchema, ListPipelineSchedulePipelinesSchema, CreatePipelineScheduleSchema, UpdatePipelineScheduleSchema, DeletePipelineScheduleSchema, PlayPipelineScheduleSchema, TakeOwnershipPipelineScheduleSchema, GetPipelineScheduleVariableSchema, CreatePipelineScheduleVariableSchema, UpdatePipelineScheduleVariableSchema, DeletePipelineScheduleVariableSchema, GitLabPipelineTriggerJobSchema, GitLabProjectMemberSchema, GitLabProjectSchema, GitLabTodoSchema, GitLabReferenceSchema, GitLabRepositorySchema, GitLabSearchBlobResultSchema, GitLabSearchResponseSchema, GitLabTreeItemSchema, GitLabUserSchema, GitLabUsersResponseSchema, GroupIteration, ListCommitStatusesSchema, ListBranchesSchema, ListCommitsSchema, ListDraftNotesSchema, ListGroupIterationsSchema, GetGroupIterationSchema, UpdateGroupIterationSchema, CreateGroupIterationSchema, GroupIterationCadence, ListGroupIterationCadencesSchema, DeleteGroupIterationSchema, ListProjectIterationsSchema, CreateGroupIterationCadenceSchema, UpdateGroupIterationCadenceSchema, DeleteGroupIterationCadenceSchema, ListGroupProjectsSchema, GitLabCiVariableSchema, ListProjectVariablesSchema, GetProjectVariableSchema, CreateProjectVariableSchema, UpdateProjectVariableSchema, DeleteProjectVariableSchema, ListGroupVariablesSchema, GetGroupVariableSchema, CreateGroupVariableSchema, UpdateGroupVariableSchema, DeleteGroupVariableSchema, GitLabDependencyProxySchema, GitLabDependencyProxyBlobSchema, GetDependencyProxySettingsSchema, UpdateDependencyProxySettingsSchema, ListDependencyProxyBlobsSchema, PurgeDependencyProxyCacheSchema, ListProjectVulnerabilitiesSchema, GetVulnerabilitySchema, DismissVulnerabilitySchema, ConfirmVulnerabilitySchema, ListIssueDiscussionsSchema, ListIssueLinksSchema, ListIssuesSchema, ListTodosSchema, ListMergeRequestDiffsSchema, // Added
150
+ GitLabDraftNoteSchema, GitLabForkSchema, GitLabBranchSchema, GitLabProtectedBranchSchema, GitLabGroupSchema, GitLabIssueLinkSchema, GitLabIssueSchema, GitLabIssueWithLinkDetailsSchema, GitLabMarkdownUploadSchema, GitLabMergeRequestPipelineSchema, GitLabMergeRequestSchema, GitLabNamespaceExistsResponseSchema, GitLabNamespaceSchema, GitLabPipelineJobSchema, GitLabDeploymentSchema, GitLabEnvironmentSchema, GitLabPipelineSchema, GitLabPipelineScheduleSchema, GitLabPipelineScheduleVariableSchema, GitLabPipelineSchedulePlayResultSchema, ListPipelineSchedulesSchema, GetPipelineScheduleSchema, ListPipelineSchedulePipelinesSchema, CreatePipelineScheduleSchema, UpdatePipelineScheduleSchema, DeletePipelineScheduleSchema, PlayPipelineScheduleSchema, TakeOwnershipPipelineScheduleSchema, GetPipelineScheduleVariableSchema, CreatePipelineScheduleVariableSchema, UpdatePipelineScheduleVariableSchema, DeletePipelineScheduleVariableSchema, GitLabPipelineTriggerJobSchema, GitLabProjectMemberSchema, GitLabProjectSchema, GitLabTodoSchema, GitLabReferenceSchema, GitLabRepositorySchema, GitLabSearchBlobResultSchema, GitLabSearchResponseSchema, GitLabTreeItemSchema, GitLabUserSchema, GitLabUsersResponseSchema, GroupIteration, ListCommitStatusesSchema, ListBranchesSchema, ListCommitsSchema, ListDraftNotesSchema, ListGroupIterationsSchema, GetGroupIterationSchema, UpdateGroupIterationSchema, CreateGroupIterationSchema, GroupIterationCadence, ListGroupIterationCadencesSchema, DeleteGroupIterationSchema, ListProjectIterationsSchema, CreateGroupIterationCadenceSchema, UpdateGroupIterationCadenceSchema, DeleteGroupIterationCadenceSchema, ListGroupProjectsSchema, GitLabDependencyProxySchema, GitLabDependencyProxyBlobSchema, GetDependencyProxySettingsSchema, UpdateDependencyProxySettingsSchema, ListDependencyProxyBlobsSchema, PurgeDependencyProxyCacheSchema, ListProjectVulnerabilitiesSchema, GetVulnerabilitySchema, DismissVulnerabilitySchema, ConfirmVulnerabilitySchema, ListIssueDiscussionsSchema, ListIssueLinksSchema, ListIssuesSchema, ListTodosSchema, ListMergeRequestDiffsSchema, // Added
150
151
  GetMergeRequestFileDiffSchema, ListMergeRequestChangedFilesSchema, ListMergeRequestDiscussionsSchema, ListMergeRequestPipelinesSchema, ListMergeRequestsSchema, ListGroupMergeRequestsSchema, ListMergeRequestVersionsSchema, GetMergeRequestVersionSchema, GitLabMergeRequestVersionSchema, GitLabMergeRequestVersionDetailSchema, ListNamespacesSchema, ListPipelineJobsSchema, ListPipelinesSchema, ListDeploymentsSchema, ListEnvironmentsSchema, ListProjectRunnersSchema, GetRunnerSchema, ListPipelineTriggerJobsSchema, ValidateCiLintSchema, ValidateProjectCiLintSchema, ListCiCatalogResourcesSchema, GetCiCatalogResourceSchema, ListProjectMembersSchema, ListGroupMembersSchema, ListProjectsSchema, MarkdownUploadSchema, MarkdownUploadRemoteSchema, DownloadAttachmentSchema, DownloadJobArtifactsSchema, GetJobArtifactFileSchema, GitLabArtifactEntrySchema, ListJobArtifactsSchema, MergeMergeRequestSchema, ApproveMergeRequestSchema, UnapproveMergeRequestSchema, RebaseMergeRequestSchema, GetMergeRequestApprovalStateSchema, GetMergeRequestConflictsSchema, GitLabMergeRequestApprovalStateSchema, MyIssuesSchema, OrbitQuerySchema, OrbitSchemaSchema, OrbitStatusSchema, OrbitToolsSchema, MarkAllTodosDoneSchema, MarkTodoDoneSchema, PaginatedDiscussionsResponseSchema, PublishDraftNoteSchema, PlayPipelineJobSchema, PushFilesSchema, RetryPipelineJobSchema, RetryPipelineSchema, SearchCodeSchema, SearchGroupCodeSchema, SearchProjectCodeSchema, SearchRepositoriesSchema, UpdateDraftNoteSchema, UpdateIssueNoteSchema, UpdateIssueSchema, UpdateIssueDescriptionPatchSchema, ReorderIssueSchema, UpdateProjectSchema, UpdateMergeRequestNoteSchema, UpdateMergeRequestDiscussionNoteSchema, UpdateMergeRequestSchema, VerifyNamespaceSchema, GitLabEventSchema, ListEventsSchema, GetProjectEventsSchema, ExecuteGraphQLSchema, GitLabReleaseSchema, ListReleasesSchema, GetReleaseSchema, CreateReleaseSchema, UpdateReleaseSchema, DeleteReleaseSchema, CreateReleaseEvidenceSchema, DownloadReleaseAssetSchema, ListSnippetsSchema, GetSnippetSchema, CreateSnippetSchema, UpdateSnippetSchema, DeleteSnippetSchema, GitLabSnippetSchema, GetMergeRequestNotesSchema, GetMergeRequestNoteSchema, GetMergeRequestDiscussionSchema, DeleteMergeRequestDiscussionNoteSchema, ResolveMergeRequestThreadSchema, GetWorkItemSchema, ListWorkItemsSchema, CreateWorkItemSchema, UpdateWorkItemSchema, ConvertWorkItemTypeSchema, ListWorkItemStatusesSchema, ListWorkItemNotesSchema, CreateWorkItemNoteSchema, CreateWorkItemEmojiReactionSchema, CreateWorkItemNoteEmojiReactionSchema, ListWorkItemEmojiReactionsSchema, ListWorkItemNoteEmojiReactionsSchema, DeleteWorkItemEmojiReactionSchema, DeleteWorkItemNoteEmojiReactionSchema, MoveWorkItemSchema, ListCustomFieldDefinitionsSchema, GetTimelineEventsSchema, CreateTimelineEventSchema, ListWebhooksSchema, CreateWebhookSchema, UpdateWebhookSchema, DeleteWebhookSchema, ListWebhookEventsSchema, GetWebhookEventSchema, HealthCheckSchema, } from "./schemas.js";
151
152
  import { createHash, randomUUID, timingSafeEqual } from "node:crypto";
152
153
  import { createGraphQLAuditFailure, createToolCallAuditor, graphqlPayloadHasErrors, markToolResultAsAuditFailure, readKnownGitLabUserId, readKnownGitLabUsername, } from "./utils/audit-log.js";
@@ -1004,8 +1005,9 @@ configureGitLabRequestContext({
1004
1005
  getDispatcherForUrl: apiUrl => clientPool.getDispatcherForUrl(apiUrl),
1005
1006
  getOAuthAccessToken: () => OAUTH_ACCESS_TOKEN,
1006
1007
  });
1007
- // The wiki, milestone, label, and tag handlers call back into the fetch, error handling, and
1008
- // project scope helpers below; fetch is read at call time because the cookie reload replaces it.
1008
+ // The wiki, milestone, label, tag, and variable handlers call back into the fetch, error
1009
+ // handling, and project scope helpers below; fetch is read at call time because the cookie
1010
+ // reload replaces it.
1009
1011
  configureWikiTools({
1010
1012
  getFetch: () => fetch,
1011
1013
  handleGitLabError,
@@ -1028,6 +1030,12 @@ configureTagTools({
1028
1030
  handleGitLabError,
1029
1031
  getEffectiveProjectId,
1030
1032
  });
1033
+ configureVariableTools({
1034
+ getFetch: () => fetch,
1035
+ handleGitLabError,
1036
+ getEffectiveProjectId,
1037
+ rejectIfProjectScopedDeployment,
1038
+ });
1031
1039
  // Create cookie jar with clean Netscape file parsing
1032
1040
  // Resolve cookie path once using os.homedir() for cross-platform support
1033
1041
  const resolvedCookiePath = GITLAB_AUTH_COOKIE_PATH
@@ -1588,9 +1596,9 @@ async function getFileContents(projectId, filePath, ref) {
1588
1596
  const response = await fetch(url.toString(), {
1589
1597
  ...getFetchConfig(),
1590
1598
  });
1591
- // Handle file not found
1599
+ // Handle file not found (the Files API also answers 404 for a directory or an unknown ref)
1592
1600
  if (response.status === 404) {
1593
- throw new GitLabApiError(`File not found: ${filePath}`, response);
1601
+ throw new GitLabApiError(withRecoveryHint(`File not found: ${filePath}`, "check file_path and ref; to list a directory, use get_repository_tree."), response);
1594
1602
  }
1595
1603
  await handleGitLabError(response);
1596
1604
  const data = await response.json();
@@ -6960,131 +6968,6 @@ async function deleteGroupIterationCadence(cadenceId) {
6960
6968
  throw new Error(`Failed to delete iteration cadence: ${data.iterationCadenceDestroy.errors.join(", ")}`);
6961
6969
  }
6962
6970
  }
6963
- // --- CI/CD Variables ---
6964
- async function listProjectVariables(projectId, options = {}) {
6965
- projectId = decodeURIComponent(projectId);
6966
- const url = new URL(`${getEffectiveApiUrl()}/projects/${encodeGitLabPathSegment(getEffectiveProjectId(projectId))}/variables`);
6967
- Object.entries(options).forEach(([key, value]) => {
6968
- if (key === "filter" && typeof value === "object" && value !== null) {
6969
- Object.entries(value).forEach(([filterKey, filterValue]) => {
6970
- appendFilterParam(url.searchParams, `filter[${filterKey}]`, filterValue);
6971
- });
6972
- return;
6973
- }
6974
- appendFilterParam(url.searchParams, key, value);
6975
- });
6976
- const response = await fetch(url.toString(), getFetchConfig());
6977
- await handleGitLabError(response);
6978
- const data = await response.json();
6979
- return z.array(GitLabCiVariableSchema).parse(data);
6980
- }
6981
- async function getProjectVariable(projectId, key, filter) {
6982
- projectId = decodeURIComponent(projectId);
6983
- const url = new URL(`${getEffectiveApiUrl()}/projects/${encodeGitLabPathSegment(getEffectiveProjectId(projectId))}/variables/${encodeGitLabPathSegment(key)}`);
6984
- if (filter?.environment_scope) {
6985
- url.searchParams.append("filter[environment_scope]", filter.environment_scope);
6986
- }
6987
- const response = await fetch(url.toString(), getFetchConfig());
6988
- await handleGitLabError(response);
6989
- const data = await response.json();
6990
- return GitLabCiVariableSchema.parse(data);
6991
- }
6992
- async function createProjectVariable(projectId, options) {
6993
- projectId = decodeURIComponent(projectId);
6994
- const response = await fetch(`${getEffectiveApiUrl()}/projects/${encodeGitLabPathSegment(getEffectiveProjectId(projectId))}/variables`, { ...getFetchConfig(), method: "POST", body: JSON.stringify(options) });
6995
- await handleGitLabError(response);
6996
- const data = await response.json();
6997
- return GitLabCiVariableSchema.parse(data);
6998
- }
6999
- async function updateProjectVariable(projectId, key, options) {
7000
- projectId = decodeURIComponent(projectId);
7001
- const { filter, ...body } = options;
7002
- const url = new URL(`${getEffectiveApiUrl()}/projects/${encodeGitLabPathSegment(getEffectiveProjectId(projectId))}/variables/${encodeGitLabPathSegment(key)}`);
7003
- if (filter?.environment_scope) {
7004
- url.searchParams.append("filter[environment_scope]", filter.environment_scope);
7005
- }
7006
- const response = await fetch(url.toString(), {
7007
- ...getFetchConfig(),
7008
- method: "PUT",
7009
- body: JSON.stringify(body),
7010
- });
7011
- await handleGitLabError(response);
7012
- const data = await response.json();
7013
- return GitLabCiVariableSchema.parse(data);
7014
- }
7015
- async function deleteProjectVariable(projectId, key, filter) {
7016
- projectId = decodeURIComponent(projectId);
7017
- const url = new URL(`${getEffectiveApiUrl()}/projects/${encodeGitLabPathSegment(getEffectiveProjectId(projectId))}/variables/${encodeGitLabPathSegment(key)}`);
7018
- if (filter?.environment_scope) {
7019
- url.searchParams.append("filter[environment_scope]", filter.environment_scope);
7020
- }
7021
- const response = await fetch(url.toString(), { ...getFetchConfig(), method: "DELETE" });
7022
- await handleGitLabError(response);
7023
- }
7024
- async function listGroupVariables(groupId, options = {}) {
7025
- const encoded = encodeGitLabPathSegment(groupId);
7026
- const url = new URL(`${getEffectiveApiUrl()}/groups/${encoded}/variables`);
7027
- Object.entries(options).forEach(([key, value]) => {
7028
- if (key === "filter" && typeof value === "object" && value !== null) {
7029
- Object.entries(value).forEach(([filterKey, filterValue]) => {
7030
- appendFilterParam(url.searchParams, `filter[${filterKey}]`, filterValue);
7031
- });
7032
- return;
7033
- }
7034
- appendFilterParam(url.searchParams, key, value);
7035
- });
7036
- const response = await fetch(url.toString(), getFetchConfig());
7037
- await handleGitLabError(response);
7038
- const data = await response.json();
7039
- return z.array(GitLabCiVariableSchema).parse(data);
7040
- }
7041
- async function getGroupVariable(groupId, key, filter) {
7042
- const encoded = encodeGitLabPathSegment(groupId);
7043
- const url = new URL(`${getEffectiveApiUrl()}/groups/${encoded}/variables/${encodeGitLabPathSegment(key)}`);
7044
- if (filter?.environment_scope) {
7045
- url.searchParams.append("filter[environment_scope]", filter.environment_scope);
7046
- }
7047
- const response = await fetch(url.toString(), getFetchConfig());
7048
- await handleGitLabError(response);
7049
- const data = await response.json();
7050
- return GitLabCiVariableSchema.parse(data);
7051
- }
7052
- async function createGroupVariable(groupId, options) {
7053
- const encoded = encodeGitLabPathSegment(groupId);
7054
- const response = await fetch(`${getEffectiveApiUrl()}/groups/${encoded}/variables`, {
7055
- ...getFetchConfig(),
7056
- method: "POST",
7057
- body: JSON.stringify(options),
7058
- });
7059
- await handleGitLabError(response);
7060
- const data = await response.json();
7061
- return GitLabCiVariableSchema.parse(data);
7062
- }
7063
- async function updateGroupVariable(groupId, key, options) {
7064
- const encoded = encodeGitLabPathSegment(groupId);
7065
- const { filter, ...body } = options;
7066
- const url = new URL(`${getEffectiveApiUrl()}/groups/${encoded}/variables/${encodeGitLabPathSegment(key)}`);
7067
- if (filter?.environment_scope) {
7068
- url.searchParams.append("filter[environment_scope]", filter.environment_scope);
7069
- }
7070
- const response = await fetch(url.toString(), {
7071
- ...getFetchConfig(),
7072
- method: "PUT",
7073
- body: JSON.stringify(body),
7074
- });
7075
- await handleGitLabError(response);
7076
- const data = await response.json();
7077
- return GitLabCiVariableSchema.parse(data);
7078
- }
7079
- async function deleteGroupVariable(groupId, key, filter) {
7080
- const encoded = encodeGitLabPathSegment(groupId);
7081
- const url = new URL(`${getEffectiveApiUrl()}/groups/${encoded}/variables/${encodeGitLabPathSegment(key)}`);
7082
- if (filter?.environment_scope) {
7083
- url.searchParams.append("filter[environment_scope]", filter.environment_scope);
7084
- }
7085
- const response = await fetch(url.toString(), { ...getFetchConfig(), method: "DELETE" });
7086
- await handleGitLabError(response);
7087
- }
7088
6971
  // --- Dependency Proxy ---
7089
6972
  async function resolveGroupFullPath(groupId) {
7090
6973
  const decoded = decodeURIComponent(groupId);
@@ -10161,88 +10044,17 @@ async function handleToolCall(params) {
10161
10044
  ],
10162
10045
  };
10163
10046
  }
10164
- // --- CI/CD Variables ---
10165
- case "list_project_variables": {
10166
- const args = ListProjectVariablesSchema.parse(params.arguments);
10167
- const { project_id, ...options } = args;
10168
- const variables = await listProjectVariables(project_id, options);
10169
- return { content: [{ type: "text", text: JSON.stringify(variables) }] };
10170
- }
10171
- case "get_project_variable": {
10172
- const args = GetProjectVariableSchema.parse(params.arguments);
10173
- const variable = await getProjectVariable(args.project_id, args.key, args.filter);
10174
- return { content: [{ type: "text", text: JSON.stringify(variable) }] };
10175
- }
10176
- case "create_project_variable": {
10177
- const args = CreateProjectVariableSchema.parse(params.arguments);
10178
- const { project_id, ...options } = args;
10179
- const variable = await createProjectVariable(project_id, options);
10180
- return { content: [{ type: "text", text: JSON.stringify(variable) }] };
10181
- }
10182
- case "update_project_variable": {
10183
- const args = UpdateProjectVariableSchema.parse(params.arguments);
10184
- const { project_id, key, ...options } = args;
10185
- const variable = await updateProjectVariable(project_id, key, options);
10186
- return { content: [{ type: "text", text: JSON.stringify(variable) }] };
10187
- }
10188
- case "delete_project_variable": {
10189
- const args = DeleteProjectVariableSchema.parse(params.arguments);
10190
- await deleteProjectVariable(args.project_id, args.key, args.filter);
10191
- return {
10192
- content: [
10193
- {
10194
- type: "text",
10195
- text: JSON.stringify({
10196
- status: "success",
10197
- message: `Variable '${args.key}' deleted from project`,
10198
- }),
10199
- },
10200
- ],
10201
- };
10202
- }
10203
- case "list_group_variables": {
10204
- rejectIfProjectScopedDeployment("list_group_variables");
10205
- const args = ListGroupVariablesSchema.parse(params.arguments);
10206
- const { group_id, ...options } = args;
10207
- const variables = await listGroupVariables(group_id, options);
10208
- return { content: [{ type: "text", text: JSON.stringify(variables) }] };
10209
- }
10210
- case "get_group_variable": {
10211
- rejectIfProjectScopedDeployment("get_group_variable");
10212
- const args = GetGroupVariableSchema.parse(params.arguments);
10213
- const variable = await getGroupVariable(args.group_id, args.key, args.filter);
10214
- return { content: [{ type: "text", text: JSON.stringify(variable) }] };
10215
- }
10216
- case "create_group_variable": {
10217
- rejectIfProjectScopedDeployment("create_group_variable");
10218
- const args = CreateGroupVariableSchema.parse(params.arguments);
10219
- const { group_id, ...options } = args;
10220
- const variable = await createGroupVariable(group_id, options);
10221
- return { content: [{ type: "text", text: JSON.stringify(variable) }] };
10222
- }
10223
- case "update_group_variable": {
10224
- rejectIfProjectScopedDeployment("update_group_variable");
10225
- const args = UpdateGroupVariableSchema.parse(params.arguments);
10226
- const { group_id, key, ...options } = args;
10227
- const variable = await updateGroupVariable(group_id, key, options);
10228
- return { content: [{ type: "text", text: JSON.stringify(variable) }] };
10229
- }
10230
- case "delete_group_variable": {
10231
- rejectIfProjectScopedDeployment("delete_group_variable");
10232
- const args = DeleteGroupVariableSchema.parse(params.arguments);
10233
- await deleteGroupVariable(args.group_id, args.key, args.filter);
10234
- return {
10235
- content: [
10236
- {
10237
- type: "text",
10238
- text: JSON.stringify({
10239
- status: "success",
10240
- message: `Variable '${args.key}' deleted from group`,
10241
- }),
10242
- },
10243
- ],
10244
- };
10245
- }
10047
+ case "list_project_variables":
10048
+ case "get_project_variable":
10049
+ case "create_project_variable":
10050
+ case "update_project_variable":
10051
+ case "delete_project_variable":
10052
+ case "list_group_variables":
10053
+ case "get_group_variable":
10054
+ case "create_group_variable":
10055
+ case "update_group_variable":
10056
+ case "delete_group_variable":
10057
+ return await handleVariableToolCall(params);
10246
10058
  case "get_dependency_proxy_settings": {
10247
10059
  rejectIfProjectScopedDeployment("get_dependency_proxy_settings");
10248
10060
  const args = GetDependencyProxySettingsSchema.parse(params.arguments);
package/build/schemas.js CHANGED
@@ -1904,7 +1904,7 @@ export const GetFileContentsSchema = z
1904
1904
  file_path: z
1905
1905
  .string()
1906
1906
  .optional()
1907
- .describe("Path to the file or directory. Takes precedence over 'path' when both are provided"),
1907
+ .describe("Path to the file (not a directory). Takes precedence over 'path' when both are provided"),
1908
1908
  path: z.string().optional().describe("Alias of file_path"),
1909
1909
  ref: z.string().optional().describe("Branch/tag/commit to get contents from"),
1910
1910
  })
@@ -64,7 +64,7 @@ export const allTools = withLazyInputSchemas([
64
64
  },
65
65
  {
66
66
  name: "get_file_contents",
67
- description: "Get contents of a file or directory from a GitLab project",
67
+ description: "Get the contents of one file from a GitLab project",
68
68
  inputSchema: lazyJSONSchema(GetFileContentsSchema),
69
69
  },
70
70
  {
@@ -6,6 +6,8 @@ const TOOL_GUIDANCE = {
6
6
  get_merge_request_approval_state: "Inspect approval rules and approvers before merging. Use `approve_merge_request` to change approval state.",
7
7
  get_merge_request_conflicts: "Inspect merge conflicts before `merge_merge_request`. It reports conflicts and does not resolve them.",
8
8
  list_merge_request_pipelines: "List pipelines for one merge request. Use `list_pipelines` for project-wide filtering.",
9
+ get_file_contents: "`ref` defaults to the default branch. `encoding` is `utf8` when a UTF-8 round-trip test passes, else `base64`; binaries with valid UTF-8 bytes (e.g. 0x00) also pass. Read `encoding`, don't infer it. Directories are not supported: use `get_repository_tree`.",
10
+ get_repository_tree: "One level under `path` unless `recursive` is true. Use `get_file_contents` to read a file.",
9
11
  create_or_update_file: "Create or update one repository file. Use `push_files` for a multi-file commit. Optional `encoding` (`text` or `base64`) defaults to `GITLAB_REPO_FILE_ENCODING`.",
10
12
  push_files: "Commit several file changes atomically. Each file defaults to action `create`; optional per-file `action` (create/update/delete/move) and `encoding` (text/base64) are additive. `GITLAB_PERMISSION_MODE=modify` rejects `delete` and `move`.",
11
13
  create_issue: "Open a new issue. Use `update_issue` for an existing issue and `create_issue_note` for discussion.",
@@ -0,0 +1,237 @@
1
+ import { z } from "zod";
2
+ import { CreateGroupVariableSchema, CreateProjectVariableSchema, DeleteGroupVariableSchema, DeleteProjectVariableSchema, GetGroupVariableSchema, GetProjectVariableSchema, GitLabCiVariableSchema, ListGroupVariablesSchema, ListProjectVariablesSchema, UpdateGroupVariableSchema, UpdateProjectVariableSchema, } from "../schemas.js";
3
+ import { getEffectiveApiUrl, getFetchConfig } from "../server/gitlab-request-context.js";
4
+ import { appendFilterParam } from "../utils/tool-args.js";
5
+ import { encodeGitLabPathSegment } from "../utils/url.js";
6
+ let deps;
7
+ export function configureVariableTools(next) {
8
+ deps = next;
9
+ }
10
+ function requireDeps() {
11
+ if (!deps) {
12
+ throw new Error("Variable tools used before configureVariableTools()");
13
+ }
14
+ return deps;
15
+ }
16
+ const fetch = (input, init) => requireDeps().getFetch()(input, init);
17
+ function handleGitLabError(response) {
18
+ return requireDeps().handleGitLabError(response);
19
+ }
20
+ function getEffectiveProjectId(projectId) {
21
+ return requireDeps().getEffectiveProjectId(projectId);
22
+ }
23
+ function rejectIfProjectScopedDeployment(toolName) {
24
+ requireDeps().rejectIfProjectScopedDeployment(toolName);
25
+ }
26
+ // --- CI/CD Variables ---
27
+ async function listProjectVariables(projectId, options = {}) {
28
+ projectId = decodeURIComponent(projectId);
29
+ const url = new URL(`${getEffectiveApiUrl()}/projects/${encodeGitLabPathSegment(getEffectiveProjectId(projectId))}/variables`);
30
+ Object.entries(options).forEach(([key, value]) => {
31
+ if (key === "filter" && typeof value === "object" && value !== null) {
32
+ Object.entries(value).forEach(([filterKey, filterValue]) => {
33
+ appendFilterParam(url.searchParams, `filter[${filterKey}]`, filterValue);
34
+ });
35
+ return;
36
+ }
37
+ appendFilterParam(url.searchParams, key, value);
38
+ });
39
+ const response = await fetch(url.toString(), getFetchConfig());
40
+ await handleGitLabError(response);
41
+ const data = await response.json();
42
+ return z.array(GitLabCiVariableSchema).parse(data);
43
+ }
44
+ async function getProjectVariable(projectId, key, filter) {
45
+ projectId = decodeURIComponent(projectId);
46
+ const url = new URL(`${getEffectiveApiUrl()}/projects/${encodeGitLabPathSegment(getEffectiveProjectId(projectId))}/variables/${encodeGitLabPathSegment(key)}`);
47
+ if (filter?.environment_scope) {
48
+ url.searchParams.append("filter[environment_scope]", filter.environment_scope);
49
+ }
50
+ const response = await fetch(url.toString(), getFetchConfig());
51
+ await handleGitLabError(response);
52
+ const data = await response.json();
53
+ return GitLabCiVariableSchema.parse(data);
54
+ }
55
+ async function createProjectVariable(projectId, options) {
56
+ projectId = decodeURIComponent(projectId);
57
+ const response = await fetch(`${getEffectiveApiUrl()}/projects/${encodeGitLabPathSegment(getEffectiveProjectId(projectId))}/variables`, { ...getFetchConfig(), method: "POST", body: JSON.stringify(options) });
58
+ await handleGitLabError(response);
59
+ const data = await response.json();
60
+ return GitLabCiVariableSchema.parse(data);
61
+ }
62
+ async function updateProjectVariable(projectId, key, options) {
63
+ projectId = decodeURIComponent(projectId);
64
+ const { filter, ...body } = options;
65
+ const url = new URL(`${getEffectiveApiUrl()}/projects/${encodeGitLabPathSegment(getEffectiveProjectId(projectId))}/variables/${encodeGitLabPathSegment(key)}`);
66
+ if (filter?.environment_scope) {
67
+ url.searchParams.append("filter[environment_scope]", filter.environment_scope);
68
+ }
69
+ const response = await fetch(url.toString(), {
70
+ ...getFetchConfig(),
71
+ method: "PUT",
72
+ body: JSON.stringify(body),
73
+ });
74
+ await handleGitLabError(response);
75
+ const data = await response.json();
76
+ return GitLabCiVariableSchema.parse(data);
77
+ }
78
+ async function deleteProjectVariable(projectId, key, filter) {
79
+ projectId = decodeURIComponent(projectId);
80
+ const url = new URL(`${getEffectiveApiUrl()}/projects/${encodeGitLabPathSegment(getEffectiveProjectId(projectId))}/variables/${encodeGitLabPathSegment(key)}`);
81
+ if (filter?.environment_scope) {
82
+ url.searchParams.append("filter[environment_scope]", filter.environment_scope);
83
+ }
84
+ const response = await fetch(url.toString(), { ...getFetchConfig(), method: "DELETE" });
85
+ await handleGitLabError(response);
86
+ }
87
+ async function listGroupVariables(groupId, options = {}) {
88
+ const encoded = encodeGitLabPathSegment(groupId);
89
+ const url = new URL(`${getEffectiveApiUrl()}/groups/${encoded}/variables`);
90
+ Object.entries(options).forEach(([key, value]) => {
91
+ if (key === "filter" && typeof value === "object" && value !== null) {
92
+ Object.entries(value).forEach(([filterKey, filterValue]) => {
93
+ appendFilterParam(url.searchParams, `filter[${filterKey}]`, filterValue);
94
+ });
95
+ return;
96
+ }
97
+ appendFilterParam(url.searchParams, key, value);
98
+ });
99
+ const response = await fetch(url.toString(), getFetchConfig());
100
+ await handleGitLabError(response);
101
+ const data = await response.json();
102
+ return z.array(GitLabCiVariableSchema).parse(data);
103
+ }
104
+ async function getGroupVariable(groupId, key, filter) {
105
+ const encoded = encodeGitLabPathSegment(groupId);
106
+ const url = new URL(`${getEffectiveApiUrl()}/groups/${encoded}/variables/${encodeGitLabPathSegment(key)}`);
107
+ if (filter?.environment_scope) {
108
+ url.searchParams.append("filter[environment_scope]", filter.environment_scope);
109
+ }
110
+ const response = await fetch(url.toString(), getFetchConfig());
111
+ await handleGitLabError(response);
112
+ const data = await response.json();
113
+ return GitLabCiVariableSchema.parse(data);
114
+ }
115
+ async function createGroupVariable(groupId, options) {
116
+ const encoded = encodeGitLabPathSegment(groupId);
117
+ const response = await fetch(`${getEffectiveApiUrl()}/groups/${encoded}/variables`, {
118
+ ...getFetchConfig(),
119
+ method: "POST",
120
+ body: JSON.stringify(options),
121
+ });
122
+ await handleGitLabError(response);
123
+ const data = await response.json();
124
+ return GitLabCiVariableSchema.parse(data);
125
+ }
126
+ async function updateGroupVariable(groupId, key, options) {
127
+ const encoded = encodeGitLabPathSegment(groupId);
128
+ const { filter, ...body } = options;
129
+ const url = new URL(`${getEffectiveApiUrl()}/groups/${encoded}/variables/${encodeGitLabPathSegment(key)}`);
130
+ if (filter?.environment_scope) {
131
+ url.searchParams.append("filter[environment_scope]", filter.environment_scope);
132
+ }
133
+ const response = await fetch(url.toString(), {
134
+ ...getFetchConfig(),
135
+ method: "PUT",
136
+ body: JSON.stringify(body),
137
+ });
138
+ await handleGitLabError(response);
139
+ const data = await response.json();
140
+ return GitLabCiVariableSchema.parse(data);
141
+ }
142
+ async function deleteGroupVariable(groupId, key, filter) {
143
+ const encoded = encodeGitLabPathSegment(groupId);
144
+ const url = new URL(`${getEffectiveApiUrl()}/groups/${encoded}/variables/${encodeGitLabPathSegment(key)}`);
145
+ if (filter?.environment_scope) {
146
+ url.searchParams.append("filter[environment_scope]", filter.environment_scope);
147
+ }
148
+ const response = await fetch(url.toString(), { ...getFetchConfig(), method: "DELETE" });
149
+ await handleGitLabError(response);
150
+ }
151
+ export async function handleVariableToolCall(params) {
152
+ switch (params.name) {
153
+ case "list_project_variables": {
154
+ const args = ListProjectVariablesSchema.parse(params.arguments);
155
+ const { project_id, ...options } = args;
156
+ const variables = await listProjectVariables(project_id, options);
157
+ return { content: [{ type: "text", text: JSON.stringify(variables) }] };
158
+ }
159
+ case "get_project_variable": {
160
+ const args = GetProjectVariableSchema.parse(params.arguments);
161
+ const variable = await getProjectVariable(args.project_id, args.key, args.filter);
162
+ return { content: [{ type: "text", text: JSON.stringify(variable) }] };
163
+ }
164
+ case "create_project_variable": {
165
+ const args = CreateProjectVariableSchema.parse(params.arguments);
166
+ const { project_id, ...options } = args;
167
+ const variable = await createProjectVariable(project_id, options);
168
+ return { content: [{ type: "text", text: JSON.stringify(variable) }] };
169
+ }
170
+ case "update_project_variable": {
171
+ const args = UpdateProjectVariableSchema.parse(params.arguments);
172
+ const { project_id, key, ...options } = args;
173
+ const variable = await updateProjectVariable(project_id, key, options);
174
+ return { content: [{ type: "text", text: JSON.stringify(variable) }] };
175
+ }
176
+ case "delete_project_variable": {
177
+ const args = DeleteProjectVariableSchema.parse(params.arguments);
178
+ await deleteProjectVariable(args.project_id, args.key, args.filter);
179
+ return {
180
+ content: [
181
+ {
182
+ type: "text",
183
+ text: JSON.stringify({
184
+ status: "success",
185
+ message: `Variable '${args.key}' deleted from project`,
186
+ }),
187
+ },
188
+ ],
189
+ };
190
+ }
191
+ case "list_group_variables": {
192
+ rejectIfProjectScopedDeployment("list_group_variables");
193
+ const args = ListGroupVariablesSchema.parse(params.arguments);
194
+ const { group_id, ...options } = args;
195
+ const variables = await listGroupVariables(group_id, options);
196
+ return { content: [{ type: "text", text: JSON.stringify(variables) }] };
197
+ }
198
+ case "get_group_variable": {
199
+ rejectIfProjectScopedDeployment("get_group_variable");
200
+ const args = GetGroupVariableSchema.parse(params.arguments);
201
+ const variable = await getGroupVariable(args.group_id, args.key, args.filter);
202
+ return { content: [{ type: "text", text: JSON.stringify(variable) }] };
203
+ }
204
+ case "create_group_variable": {
205
+ rejectIfProjectScopedDeployment("create_group_variable");
206
+ const args = CreateGroupVariableSchema.parse(params.arguments);
207
+ const { group_id, ...options } = args;
208
+ const variable = await createGroupVariable(group_id, options);
209
+ return { content: [{ type: "text", text: JSON.stringify(variable) }] };
210
+ }
211
+ case "update_group_variable": {
212
+ rejectIfProjectScopedDeployment("update_group_variable");
213
+ const args = UpdateGroupVariableSchema.parse(params.arguments);
214
+ const { group_id, key, ...options } = args;
215
+ const variable = await updateGroupVariable(group_id, key, options);
216
+ return { content: [{ type: "text", text: JSON.stringify(variable) }] };
217
+ }
218
+ case "delete_group_variable": {
219
+ rejectIfProjectScopedDeployment("delete_group_variable");
220
+ const args = DeleteGroupVariableSchema.parse(params.arguments);
221
+ await deleteGroupVariable(args.group_id, args.key, args.filter);
222
+ return {
223
+ content: [
224
+ {
225
+ type: "text",
226
+ text: JSON.stringify({
227
+ status: "success",
228
+ message: `Variable '${args.key}' deleted from group`,
229
+ }),
230
+ },
231
+ ],
232
+ };
233
+ }
234
+ default:
235
+ throw new Error(`Unknown tool: ${params.name}`);
236
+ }
237
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zereight/mcp-gitlab",
3
- "version": "2.3.28-next.243",
3
+ "version": "2.3.28-next.245",
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": [