Skip to content

feat: add CI/CD variable tools for project and group scope#479

Open
babyhuey wants to merge 3 commits into
zereight:mainfrom
babyhuey:feat/ci-cd-variables
Open

feat: add CI/CD variable tools for project and group scope#479
babyhuey wants to merge 3 commits into
zereight:mainfrom
babyhuey:feat/ci-cd-variables

Conversation

@babyhuey
Copy link
Copy Markdown

Closes #478

Summary

  • Adds 10 new MCP tools for full CRUD on CI/CD variables at project and group scope
  • New non-default variables toolset, activated via discover_tools
  • filter[environment_scope] on project endpoints to disambiguate variables sharing a key across environments
  • Pagination (page/per_page) on list endpoints, consistent with list_labels
  • Read-only tools registered in readOnlyTools; delete tools in destructiveTools

New tools

Tool Endpoint Read-only
list_project_variables GET /projects/:id/variables
get_project_variable GET /projects/:id/variables/:key
create_project_variable POST /projects/:id/variables
update_project_variable PUT /projects/:id/variables/:key
delete_project_variable DELETE /projects/:id/variables/:key
list_group_variables GET /groups/:id/variables
get_group_variable GET /groups/:id/variables/:key
create_group_variable POST /groups/:id/variables
update_group_variable PUT /groups/:id/variables/:key
delete_group_variable DELETE /groups/:id/variables/:key

GitLab API reference

Test plan

  • 12 mock tests in test/test-ci-variables.ts covering all 10 tools
  • variables toolset absent from default tools/list response
  • Write tools absent in read-only mode; read tools present
  • TOOLSET_TOOL_COUNTS and NON_DEFAULT_TOOLSETS updated in test-toolset-filtering.ts
  • All 277 mock tests pass (npm run test:mock)
  • npx tsc --noEmit clean

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b4a8592569

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread schemas.ts
Copy link
Copy Markdown
Owner

@zereight zereight left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the CI/CD variables toolset — the project-side API wiring, opt-in variables toolset, read-only/destructive registration, and test/test-ci-variables.ts in test:mock look solid.

I'm requesting changes before merge:

1. Rebase onto current main (blocking)
This PR branch is stacked on the dependency-proxy work (#474) and is CONFLICTING with main (which now includes #466). The diff bundles dependency-proxy files, design spec, and resolveGroupFullPath — not just the 7 files from b4a8592. Please rebase onto current main and submit a PR that contains only the CI variables changes (or land #474 first, then rebase).

2. npm run build fails on current head (blocking)
Head b4a8592 fails with TS18046: 'data' is of type 'unknown' in resolveGroupFullPath (from bundled #474 code). CI is also action_required (fork PR). Please ensure npm run build passes after rebase.

3. Group variables: missing filter[environment_scope] (P1)
Project endpoints support filter.environment_scope for get/update/delete/list — good. Group endpoints do not (GetGroupVariableSchema, UpdateGroupVariableSchema, DeleteGroupVariableSchema, ListGroupVariablesSchema). GitLab group variables can share the same key across scopes; without the filter, get/update/delete can hit the wrong variable or fail ambiguously. Please mirror the project-side filter pattern for group tools.

Non-blocking follow-ups:

  • Add the 10 new tools to the README <!-- TOOLS-START --> list.
  • Consider guarding create_group_variable / update_group_variable / delete_group_variable when GITLAB_PROJECT_ID or GITLAB_ALLOWED_PROJECT_IDS is set (same boundary as create_group on main).
  • Add a mock test for filter[environment_scope] on project get/update/delete (called out as not tested in the commit message).

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6fb8ee19cf

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread schemas.ts
Comment on lines +3949 to +3953
protected: z.boolean().optional(),
masked: z.boolean().optional(),
raw: z.boolean().optional(),
environment_scope: z.string().optional(),
description: z.string().nullable().optional(),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Support hidden variable attributes

For GitLab 17.4+ project and group CI/CD variables, hidden is returned by list/get responses and masked_and_hidden is a create-time option. Because the shared variable schema omits these fields, get_*_variable/create responses strip the hidden state and callers cannot create variables with the non-revealable masked_and_hidden setting through these new tools, which is a security-relevant part of the variables API.

Useful? React with 👍 / 👎.

@babyhuey babyhuey force-pushed the feat/ci-cd-variables branch 2 times, most recently from 936e5ca to 6fb8ee1 Compare May 19, 2026 14:38
@babyhuey
Copy link
Copy Markdown
Author

All feedback addressed in this update:

Rebased — PR now contains only CI/CD variable changes (dep proxy code was never part of this PR; just an artifact of the branch being cut before #474 landed). Build passes cleanly.

filter[environment_scope] on group endpointsget, update, delete, and list group variable schemas now include the filter field, wired through as filter[environment_scope] query param, matching the project-side pattern.

filter[environment_scope] mock tests — added tests for get_project_variable, update_project_variable, and delete_project_variable with filter; the mock handler captures the received query param and the test asserts it was forwarded correctly (visible in test output as filter%5Benvironment_scope%5D=production).

README — tools 157–166 added to the <!-- TOOLS-START --> list.

Project-scoped deployment guardcreate_group_variable, update_group_variable, and delete_group_variable now call rejectIfProjectScopedDeployment, consistent with create_group and fork_repository.

All 15 CI variable tests pass.

@babyhuey babyhuey force-pushed the feat/ci-cd-variables branch from 6fb8ee1 to 9f08121 Compare May 19, 2026 14:42
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9f081210f2

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread index.ts
Comment thread schemas.ts
Comment on lines +3971 to +3974
filter: z
.object({ environment_scope: z.string() })
.optional()
.describe("Filter by environment scope (e.g. '*', 'production')"),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Do not advertise unsupported list filters

GitLab's list variable endpoints document only the group/project id plus pagination parameters; filter[environment_scope] is documented for retrieve/update/delete when duplicate keys need disambiguation, not for listing (see the official project/group variable API docs). With this schema, callers can request filter.environment_scope on list_project_variables and receive an unfiltered page while believing only that scope was returned, which can drive follow-up automation against the wrong variables. Remove this input or implement explicit client-side filtering on environment_scope.

Useful? React with 👍 / 👎.

@babyhuey babyhuey force-pushed the feat/ci-cd-variables branch from 81ae2dc to 8c149c2 Compare May 20, 2026 23:27
@zereight
Copy link
Copy Markdown
Owner

Thanks for addressing the earlier feedback on group filter[environment_scope], mock tests, README, and the project-scoped deployment guard.

The PR is still merge-conflicting with main. Could you please rebase onto the latest main and resolve the conflicts (e.g. index.ts, schemas.ts, package.json, tools/registry.ts as applicable), then push the updated branch?

Once that's done, I'll re-review the updated head. No need to change anything else for the conflict fix unless CI fails after the rebase.

@babyhuey
Copy link
Copy Markdown
Author

Rebased onto current main (v2.1.15, picks up the markdown upload, approved_by_usernames, label schema, and deps bump).

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2b1de3ef75

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread schemas.ts
Comment on lines +4100 to +4103
filter: z
.object({ environment_scope: z.string() })
.optional()
.describe("Filter by environment scope (e.g. '*', 'production')"),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Remove unsupported filter from list_group_variables

list_group_variables advertises a filter.environment_scope input, but GitLab’s group-variable list endpoint only supports id, page, and per_page; filter is only defined for get/update/delete by key. In practice this means callers can pass a scope filter, receive an unfiltered list, and then run follow-up automation against the wrong variables while assuming the filter was enforced.

Useful? React with 👍 / 👎.

@babyhuey
Copy link
Copy Markdown
Author

Verified locally against the same steps CI runs:

  • npm run build — clean (no errors)
  • npm run test:remote-auth — passed
  • npm run test:mock — all tests passed (including the CI/CD variables suite)
  • npx tsc --noEmit — clean

Copy link
Copy Markdown
Owner

@zereight zereight left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

conflict!

@babyhuey babyhuey force-pushed the feat/ci-cd-variables branch from 2b1de3e to e099a51 Compare May 25, 2026 15:26
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@babyhuey
Copy link
Copy Markdown
Author

Rebased again. Fourth time now.

The conflict is the same every single time: a new test file lands on main while this PR waits for review. At this point keeping up with the rebase requests is its own full time job. Would be great to actually get a review before the next commit drops.

Hannah Lyons added 3 commits May 26, 2026 00:11
Adds 10 new MCP tools covering full CRUD for CI/CD variables at both
project and group level, packaged as a new non-default `variables`
toolset activated via discover_tools.

New tools: list_project_variables, get_project_variable,
create_project_variable, update_project_variable, delete_project_variable,
list_group_variables, get_group_variable, create_group_variable,
update_group_variable, delete_group_variable.

Supports filter[environment_scope] on project endpoints to disambiguate
variables that share the same key across environments. List endpoints
include pagination (page/per_page) consistent with other list tools.

Confidence: high
Scope-risk: narrow
Not-tested: filter[environment_scope] interaction with pagination on large variable sets
…pe guards

- Tests verify filter[environment_scope] query param is forwarded for
  get/update/delete project variable endpoints
- Adds 10 new tools (157-166) to README TOOLS list
- Guards create/update/delete group variable with
  rejectIfProjectScopedDeployment, consistent with create_group
Add rejectIfProjectScopedDeployment to list_group_variables and
get_group_variable so a project-locked server cannot read arbitrary
group secrets. Replace unsafe `data as GitLabCiVariable[]` casts with
z.array(GitLabCiVariableSchema).parse(data) for consistent validation.
@babyhuey babyhuey force-pushed the feat/ci-cd-variables branch from e099a51 to 986dc80 Compare May 26, 2026 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add CI/CD variable tools for project and group scope

2 participants