gitlab_get_merge_request_notes
Retrieve comments and notes from GitLab merge requests to review discussions, track feedback, and analyze code review conversations with pagination and sorting options.
Instructions
List merge request comments Returns: Array of notes/comments with content Use when: Reading MR discussions, reviews Pagination: Yes (default 10 per page) Sorting: By created_at or updated_at
Example response: [{ "id": 789, "body": "Great work! Just one suggestion...", "author": {"username": "reviewer"}, "created_at": "2024-01-15T10:30:00Z", "type": "DiffNote", "resolvable": true, "resolved": false }]
Related tools:
gitlab_get_merge_request_discussions: Threaded discussions
gitlab_add_merge_request_comment: Add comment
gitlab_resolve_discussion: Resolve threads
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | No | Project identifier (auto-detected if not provided) Type: integer OR string Format: numeric ID or 'namespace/project' Optional: Yes - auto-detects from current git repository Examples: - 12345 (numeric ID) - 'gitlab-org/gitlab' (namespace/project path) - 'my-group/my-subgroup/my-project' (nested groups) Note: If in a git repo with GitLab remote, this can be omitted | |
| mr_iid | Yes | Merge request number (IID - Internal ID) Type: integer Format: Project-specific MR number (without !) Required: Yes Examples: - 456 (for MR !456) - 7890 (for MR !7890) How to find: Look at MR URL or title - URL: https://gitlab.com/group/project/-/merge_requests/456 → use 456 - Title: "Add new feature (!456)" → use 456 Note: This is NOT the global MR ID | |
| per_page | No | Number of results per page Type: integer Range: 1-100 Default: 20 Example: 50 (for faster browsing) Tip: Use smaller values (10-20) for detailed operations, larger (50-100) for listing | |
| page | No | Page number for pagination Type: integer Range: ≥1 Default: 1 Example: 3 (to get the third page of results) Note: Use with per_page to navigate large result sets | |
| sort | No | Sort direction Type: string (enum) Options: 'asc' | 'desc' Default: Varies by context (usually 'desc' for time-based) Examples: - 'asc': A→Z, oldest→newest, smallest→largest - 'desc': Z→A, newest→oldest, largest→smallest | asc |
| order_by | No | Field to sort by Type: string (enum) Options vary by endpoint: - Commits: 'created_at', 'title' - Issues: 'created_at', 'updated_at', 'priority', 'due_date' - MRs: 'created_at', 'updated_at', 'title' Default: Usually 'created_at' Example: 'updated_at' to see recently modified items first | created_at |
| max_body_length | No | Maximum length for text content Type: integer Range: 0-10000 (0 = unlimited) Default: 1000 Examples: - 0: Show full content (no truncation) - 500: Limit to 500 characters - 2000: Allow longer descriptions Note: Truncated text ends with '...' |
Implementation Reference
- src/mcp_gitlab/tool_handlers.py:150-162 (handler)Main handler function implementing the tool logic: extracts parameters like project_id, mr_iid, pagination options, and calls GitLabClient.get_merge_request_notes()def handle_get_merge_request_notes(client: GitLabClient, arguments: Optional[Dict[str, Any]]) -> Dict[str, Any]: """Handle getting merge request notes""" project_id = require_project_id(client, arguments) mr_iid = require_argument(arguments, "mr_iid") per_page = get_argument(arguments, "per_page", SMALL_PAGE_SIZE) page = get_argument(arguments, "page", 1) sort = get_argument(arguments, "sort", "asc") order_by = get_argument(arguments, "order_by", "created_at") max_body_length = get_argument(arguments, "max_body_length", DEFAULT_MAX_BODY_LENGTH) return client.get_merge_request_notes( project_id, mr_iid, per_page, page, sort, order_by, max_body_length )
- MCP tool schema definition specifying input parameters, types, defaults, enums, and requirements for validation.types.Tool( name=TOOL_GET_MR_NOTES, description=desc.DESC_GET_MR_NOTES, inputSchema={ "type": "object", "properties": { "project_id": {"type": "string", "description": desc.DESC_PROJECT_ID}, "mr_iid": {"type": "integer", "description": desc.DESC_MR_IID}, "per_page": {"type": "integer", "description": desc.DESC_PER_PAGE, "default": SMALL_PAGE_SIZE, "minimum": 1, "maximum": MAX_PAGE_SIZE}, "page": {"type": "integer", "description": desc.DESC_PAGE_NUMBER, "default": 1, "minimum": 1}, "sort": {"type": "string", "description": desc.DESC_SORT_ORDER, "enum": ["asc", "desc"], "default": "asc"}, "order_by": {"type": "string", "description": desc.DESC_ORDER_BY, "enum": ["created_at", "updated_at"], "default": "created_at"}, "max_body_length": {"type": "integer", "description": desc.DESC_MAX_BODY_LENGTH, "default": DEFAULT_MAX_BODY_LENGTH, "minimum": 0} }, "required": ["mr_iid"] } ),
- src/mcp_gitlab/tool_handlers.py:1025-1025 (registration)Maps the tool name constant to its handler function in the TOOL_HANDLERS dictionary used by server.call_tool()TOOL_GET_MR_NOTES: handle_get_merge_request_notes,
- src/mcp_gitlab/constants.py:186-186 (registration)Constant definition of the canonical tool name string used across the codebase.TOOL_GET_MR_NOTES = "gitlab_get_merge_request_notes"
- src/mcp_gitlab/server.py:318-333 (registration)Tool registration in server.list_tools() which provides the schema to MCP clients at runtime.name=TOOL_GET_MR_NOTES, description=desc.DESC_GET_MR_NOTES, inputSchema={ "type": "object", "properties": { "project_id": {"type": "string", "description": desc.DESC_PROJECT_ID}, "mr_iid": {"type": "integer", "description": desc.DESC_MR_IID}, "per_page": {"type": "integer", "description": desc.DESC_PER_PAGE, "default": SMALL_PAGE_SIZE, "minimum": 1, "maximum": MAX_PAGE_SIZE}, "page": {"type": "integer", "description": desc.DESC_PAGE_NUMBER, "default": 1, "minimum": 1}, "sort": {"type": "string", "description": desc.DESC_SORT_ORDER, "enum": ["asc", "desc"], "default": "asc"}, "order_by": {"type": "string", "description": desc.DESC_ORDER_BY, "enum": ["created_at", "updated_at"], "default": "created_at"}, "max_body_length": {"type": "integer", "description": desc.DESC_MAX_BODY_LENGTH, "default": DEFAULT_MAX_BODY_LENGTH, "minimum": 0} }, "required": ["mr_iid"] } ),