GitLab Merge Request Integration
Manage GitLab Merge Requests using bash scripts. List MRs, read comments, post feedback, and resolve discussions.
How to Use
Call bash scripts directly via the Bash tool. No MCP server required.
Scripts location: ~/.claude/plugins/cache/awesome-agent-toolkit/gitlab-mr/1.2.1/core/scripts/
IMPORTANT: Environment variables must be set. Check with:
echo $GITLAB_HOST_URL $GITLAB_TOKEN $GITLAB_PROJECT_ID
If empty, add them to ~/.claude/settings.json under env:
{
"env": {
"GITLAB_HOST_URL": "https://gitlab.com",
"GITLAB_TOKEN": "glpat-xxxxxxxxxxxx",
"GITLAB_PROJECT_ID": "12345678"
}
}
Available Commands
Set PLUGIN_DIR=~/.claude/plugins/cache/awesome-agent-toolkit/gitlab-mr/1.2.1
List Merge Requests
# List open MRs (default) bash $PLUGIN_DIR/core/scripts/list-mrs.sh # List merged MRs bash $PLUGIN_DIR/core/scripts/list-mrs.sh merged # List closed MRs bash $PLUGIN_DIR/core/scripts/list-mrs.sh closed # List all MRs bash $PLUGIN_DIR/core/scripts/list-mrs.sh all
Get MR Details
bash $PLUGIN_DIR/core/scripts/get-mr-details.sh 123
Returns full MR details including description, source/target branches, author.
Get MR Comments
bash $PLUGIN_DIR/core/scripts/get-mr-comments.sh 123
Get MR Discussions (Threaded)
bash $PLUGIN_DIR/core/scripts/get-mr-discussions.sh 123
Returns threaded discussions with code context. Includes discussion IDs for replies.
Post Comment on MR
bash $PLUGIN_DIR/core/scripts/post-mr-comment.sh 123 "Your comment here"
Reply to Discussion
bash $PLUGIN_DIR/core/scripts/reply-to-discussion.sh 123 "discussion_id_abc123" "Your reply"
Resolve Discussion
bash $PLUGIN_DIR/core/scripts/resolve-discussion.sh 123 "discussion_id_abc123"
Get MR Diff Versions
bash $PLUGIN_DIR/core/scripts/get-mr-diff-versions.sh 123
Returns diff version SHAs (base_commit_sha, head_commit_sha, start_commit_sha) needed for posting inline comments.
Post Inline Diff Comment
bash $PLUGIN_DIR/core/scripts/post-mr-diff-comment.sh 123 '{"body":"Consider using a constant here","position":{"position_type":"text","base_sha":"abc123","head_sha":"def456","start_sha":"ghi789","new_path":"src/app.js","old_path":"src/app.js","new_line":42}}'
Posts a comment on a specific line of a file in the MR diff. Requires SHAs from get-mr-diff-versions.sh.
Workflows
1. Review MR Comments
When user asks about MR comments or code review:
- •Run:
bash $PLUGIN_DIR/core/scripts/get-mr-details.sh <iid>for context - •Run:
bash $PLUGIN_DIR/core/scripts/get-mr-discussions.sh <iid>for threaded comments - •Group by: Unresolved (action needed) vs Resolved
- •Show code context for inline comments
2. Reply to Review Feedback
When user has fixed something and wants to reply:
- •Get discussion ID from the discussions list
- •Run:
bash $PLUGIN_DIR/core/scripts/reply-to-discussion.sh <mr_iid> "<discussion_id>" "Fixed in commit abc123..." - •Optionally resolve:
bash $PLUGIN_DIR/core/scripts/resolve-discussion.sh <mr_iid> "<discussion_id>"
3. Post Inline Code Review Comment
When posting a comment on a specific line in the MR diff:
- •Get diff versions:
bash $PLUGIN_DIR/core/scripts/get-mr-diff-versions.sh <mr_iid> - •Use the first (latest) version's SHAs (
base_commit_sha,head_commit_sha,start_commit_sha) - •Post the inline comment:
bash $PLUGIN_DIR/core/scripts/post-mr-diff-comment.sh <mr_iid> '{"body":"Your comment","position":{"position_type":"text","base_sha":"<base_commit_sha>","head_sha":"<head_commit_sha>","start_sha":"<start_commit_sha>","new_path":"path/to/file.js","old_path":"path/to/file.js","new_line":42}}'
- •Use
new_linefor commenting on added or unchanged lines (new side of the diff) - •Use
old_linefor commenting on removed lines (old side of the diff) - •For unchanged lines, you can provide both
new_lineandold_line
4. Post Fix Explanation
Template for fix comments:
Fixed in commit `abc1234`. **Changes made:** - Replaced MD5 with bcrypt for password hashing - Added salt rounds configuration **Files changed:** - `src/auth.js` - Implemented bcrypt hashing - `tests/auth.test.js` - Added security tests
Output Format
Present MRs as a table:
| IID | Title | State | Author | Source → Target |
|---|---|---|---|---|
| !123 | Add login feature | opened | @developer | feature/login → main |
| !124 | Fix parser bug | merged | @coder | fix/parser → main |
Unresolved Discussions Format
- •@reviewer on
src/auth.js:45:Consider using bcrypt instead of md5
- •Discussion ID:
abc123def
- •Discussion ID: