Code Review Workflow Examples
Step-by-step examples for merge request review workflows. Each example shows the natural language prompt and the meta-tool actions the server performs.
MR review workflow
Section titled “MR review workflow”sequenceDiagram
participant U as User
participant AI as AI Assistant
participant MCP as MCP Server
participant GL as GitLab API
U->>AI: "Review MR !42"
AI->>MCP: gitlab_merge_request (action: list)
MCP->>GL: GET /projects/:id/merge_requests
GL-->>MCP: MR list
MCP-->>AI: Open MRs
AI->>MCP: gitlab_merge_request (action: changes)
MCP->>GL: GET /projects/:id/merge_requests/:iid/changes
GL-->>MCP: Diff data
MCP-->>AI: File changes
AI->>MCP: gitlab_analyze_mr_changes (sampling)
MCP-->>AI: Review findings
AI->>MCP: gitlab_merge_request (action: note_create)
MCP->>GL: POST /projects/:id/merge_requests/:iid/notes
AI->>MCP: gitlab_merge_request (action: approve)
MCP->>GL: POST /projects/:id/merge_requests/:iid/approve
AI->>U: "Review complete, MR approved"
List MRs awaiting review
Section titled “List MRs awaiting review”Prompt: “Show me all merge requests assigned to me for review in the backend project”
gitlab_merge_request → action: list, project_id: "my-group/backend", reviewer_username: "johndoe", state: "opened"Returns: MR titles, authors, branches, labels, and review status.
Read MR changes
Section titled “Read MR changes”Prompt: “Show me the file changes in MR !42”
gitlab_merge_request → action: changes, project_id: "my-group/backend", merge_request_iid: 42Returns: list of changed files with additions, deletions, and full diffs.
Check MR approval status
Section titled “Check MR approval status”Prompt: “Who has approved MR !42 and who still needs to approve?”
gitlab_merge_request → action: approval_state, project_id: "my-group/backend", merge_request_iid: 42Returns: approval rules, required approvals, current approvals, and eligible approvers.
Approve an MR
Section titled “Approve an MR”Prompt: “Approve merge request !42 in the backend project”
gitlab_merge_request → action: approve, project_id: "my-group/backend", merge_request_iid: 42AI-powered code review
Section titled “AI-powered code review”Full code review
Section titled “Full code review”Prompt: “Review the code changes in MR !42 for bugs, security issues, and best practices”
gitlab_analyze_mr_changes (sampling) → fetches diff, sends to LLM for comprehensive reviewReturns: structured findings organized by severity (critical, warning, suggestion) with file locations and recommended fixes.
Security-focused review
Section titled “Security-focused review”Prompt: “Do a security review of MR !78 in the backend project”
gitlab_review_mr_security (sampling) → examines diff for security vulnerabilitiesChecks for: SQL injection, XSS, hardcoded secrets, authentication bypasses, insecure deserialization, and OWASP Top 10 issues.
Review summary
Section titled “Review summary”Prompt: “Summarize all review comments on MR !42”
gitlab_summarize_mr_review (sampling) → consolidates review threads into summaryReturns: key discussion points, unresolved threads, action items, and overall review sentiment.
MR discussions and notes
Section titled “MR discussions and notes”Add a review comment
Section titled “Add a review comment”Prompt: “Add a comment to MR !42 saying ‘The error handling in auth.go needs a retry mechanism‘“
gitlab_merge_request → action: note_create, project_id: "my-group/backend", merge_request_iid: 42, body: "The error handling in auth.go needs a retry mechanism"Create a discussion thread
Section titled “Create a discussion thread”Prompt: “Start a discussion on MR !42 about the database migration strategy”
gitlab_merge_request → action: discussion_create, project_id: "my-group/backend", merge_request_iid: 42, body: "Let's discuss the database migration strategy..."List unresolved threads
Section titled “List unresolved threads”Prompt: “Show me all unresolved discussion threads in MR !42”
gitlab_merge_request → action: discussion_list, project_id: "my-group/backend", merge_request_iid: 42Filter the results for threads where resolved: false to find outstanding review items.
Use draft notes
Section titled “Use draft notes”Prompt: “Create a draft review note on MR !42 — I’ll publish all my comments together”
gitlab_merge_request → action: draft_note_create, project_id: "my-group/backend", merge_request_iid: 42, note: "Consider using a context timeout here..."Draft notes are only visible to you until you publish them all at once with action: draft_note_publish_all.
MR lifecycle
Section titled “MR lifecycle”Create an MR
Section titled “Create an MR”Prompt: “Create a merge request from branch feature/auth-refactor to main in the backend project”
gitlab_merge_request → action: create, project_id: "my-group/backend", source_branch: "feature/auth-refactor", target_branch: "main", title: "Refactor authentication module"Merge after approval
Section titled “Merge after approval”Prompt: “Merge MR !42 using squash commit”
gitlab_merge_request → action: merge, project_id: "my-group/backend", merge_request_iid: 42, squash: trueRebase before merge
Section titled “Rebase before merge”Prompt: “Rebase MR !42 against the latest main branch”
gitlab_merge_request → action: rebase, project_id: "my-group/backend", merge_request_iid: 42Close without merging
Section titled “Close without merging”Prompt: “Close MR !99 — the approach was superseded by MR !105”
gitlab_merge_request → action: update, project_id: "my-group/backend", merge_request_iid: 99, state_event: "close"Compare branches
Section titled “Compare branches”Diff between branches
Section titled “Diff between branches”Prompt: “Compare the develop branch with main in the backend project”
gitlab_repository → action: compare, project_id: "my-group/backend", from: "main", to: "develop"Returns: list of commits, changed files, and diff statistics between the two branches.