GitLab Tool Node
Agent tool for interacting with the GitLab API using per-user configured credentials.

This node dispatches a single "gitlab" tool to multiple action-specific handlers and performs authenticated requests to the GitLab REST API using the calling user's stored GitLab credentials.
Actions
- Retrieves per-user GitLab config (url, token, repository, branch, base_branch) from stored API keys and validates presence; errors if missing.
- Constructs project identifiers, URL-encodes string project paths, and accepts numeric project IDs.
- Performs HTTP requests to GitLab API endpoints with a shared async HTTP client (per-event-loop) and default headers including the user's PRIVATE-TOKEN.
- Handles network errors and non-expected HTTP status codes by logging and raising descriptive runtime errors.
- Parses JSON responses and returns text fallback when JSON parsing fails.
- Supports the following actions (action-specific params described briefly below):
- create_issue create an issue (title required; optional description, labels, assignee_ids, milestone_id, confidential). Joins label lists to comma-separated string.
- list_issues list project issues (state, labels, per_page, page).
- create_merge_request create MR (source_branch required; target_branch defaulting to configured branches; title, description, remove_source_branch, allow_collaboration, squash).
- list_merge_requests list MRs (state, labels, per_page, page).
- get_file get file content metadata from repository (file_path, ref).
- create_commit create commit with actions (branch, commit_message, actions).
- create_branch create branch from ref (branch, ref).
- protect_branch protect branch with access levels (branch, push_access_level, merge_access_level, allow_force_push).
- add_member add project member (user_id, access_level; default 30 Developer).
- remove_member remove project member (user_id).
- run_pipeline trigger pipeline (ref defaulting to branch/base_branch/main; optional variables).
- list_pipelines list pipelines with optional status filtering (validates statuses), ref, pagination.
- create_release create release (name, tag_name, description).
- list_projects list visible projects (membership, owned, starred, search, namespace_id, pagination).
- get_project get project metadata.
- delete_project delete project.
- add_comment add note to issue or MR (iid required, body required, for_merge_request flag).
- create_tag create repository tag (tag_name, ref, message).
- list_tags list repository tags (pagination).
- create_label create label (name, color, description).
- list_labels list labels (pagination).
Inputs (fields)
- action: one of the enumerated GitLabAction values (required).
- params: object/dict with action-specific parameters (optional depending on action).
Outputs
- Returns the parsed GitLab API response (JSON-decoded) or raw text if JSON decoding fails.
- Errors surface as raised exceptions with logged context (network errors, validation errors, unexpected HTTP status codes).
Behavior and Constraints
- Uses per-user stored API keys; no global token is used.
- Reuses an async httpx client per asyncio event loop to limit connection overhead.
- Default HTTP timeout is 15 seconds and max connections limited to 20.
- Expected success status codes default to [200, 201, 202, 204] unless overridden.
- Project identification accepts numeric IDs or URL-encoded string paths.
- Pipeline status filtering validates against a known whitelist and normalizes list inputs to comma-separated values.
- Label lists are converted to comma-separated strings where required by the API.
Error Handling
- Missing user GitLab config raises a runtime error indicating the missing key.
- Network/request errors raise runtime errors with logged exception details.
- Non-success HTTP responses raise runtime errors including status and body.
- Action-specific parameter validation errors raise ValidationError or ValueError as appropriate.