fix: write tools honor GITLAB_TOKEN fallback (1.15.1)#33
Merged
Conversation
Write tool handlers had an early-exit guard that required per-call userCredentials, contradicting the documented design that GITLAB_TOKEN is a full-access fallback usable for both reads and writes. The guard fired before getClient() could resolve the env token, so stdio / no-Authorization-header callers saw "User authentication is required..." even with GITLAB_TOKEN configured. Reads were unaffected because read handlers don't have the guard. Removes the guard from create_issue, create_merge_request, update_issue, delete_issue, update_merge_request, manage_pipeline, create_note, delete_note, update_note, create_broadcast_message, update_broadcast_message, delete_broadcast_message, and the requiresWrite branch of execute_custom_query. getClient() already throws an actionable error if no token at all is configured. Fixes #32.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
if (!credentials) throwguard from every write tool handler. The guard short-circuitedgetClient()'s documented four-step token resolution, so writes failed withUser authentication is required...whenever the caller relied on theGITLAB_TOKENenv fallback (stdio, or HTTP withoutAuthorization: Bearer). Reads were unaffected.create_issue,create_merge_request,update_issue,delete_issue,update_merge_request,manage_pipeline,create_note,delete_note,update_note,create_broadcast_message,update_broadcast_message,delete_broadcast_message, and therequiresWritebranch ofexecute_custom_query.getClient()still throws an actionable error if no token at all is configured.package.json,.claude-plugin/plugin.json, lockfile synced) and CHANGELOG entry. Fixes GitLab MCP: create_merge_request reports missing auth while identical PAT succeeds via REST API #32.Test plan
npm run buildsucceeds locally (verified)GITLAB_TOKEN=glpat-...set, no per-calluserCredentials—create_merge_requestsucceeds (curl-equivalent behavior)Authorization: Bearer <PAT>—create_merge_requeststill succeeds (regression check for the per-session path)create_merge_requestreturnsgetClient()'s actionable error mentioningGITLAB_TOKENGITLAB_READ_TOKEN-only setups still reject writes (path unchanged ingetClient())