Skip to content

Conversation

@g-tiwari
Copy link
Contributor

Overview

This PR adds complete support for GitLab's Draft Notes API, enabling users to create, manage, and publish draft comments on merge requests
before making them visible to other collaborators.

What are Draft Notes?

Draft Notes are a GitLab feature that allows users to:
• Write comments on merge requests that are only visible to the author
• Review and edit comments before publishing
• Publish individual draft notes or all drafts at once
• Add comments to specific lines in diffs (with position support)

Features Added

🛠️ New Tools (6 total)

  1. list_draft_notes - List all draft notes for a merge request
  2. create_draft_note - Create a new draft note with optional diff positioning
  3. update_draft_note - Update existing draft note content or position
  4. delete_draft_note - Delete a draft note
  5. publish_draft_note - Publish a single draft note to make it visible
  6. bulk_publish_draft_notes - Publish all draft notes for a merge request at once

🔧 Technical Improvements

Flexible Schema Validation: Enhanced schemas to handle GitLab API inconsistencies
Position Support: Full support for diff positioning in draft comments
Error Handling: Robust handling of empty responses from GitLab API
Parameter Normalization: Handles both body and note field variations
Type Safety: Complete TypeScript definitions for all draft note operations

Implementation Details

Core Functions (index.ts)

• Added 6 new API functions with comprehensive error handling
• Implemented proper URL encoding and parameter validation
• Added support for diff positioning and discussion resolution
• Enhanced response parsing to handle GitLab's variable response formats

Schema Definitions (schemas.ts)

• Created flexible GitLabDraftNoteSchema with field normalization
• Added separate schemas for each operation (CRUD + publish operations)
• Split position schemas into flexible (responses) and strict (creation) variants
• Made user schema fields optional for better API compatibility

Documentation Updates

• Updated README.md with new tool descriptions
• Added comprehensive inline documentation for all functions
• Included parameter descriptions and usage examples

API Endpoints Covered

GET /projects/:id/merge_requests/:merge_request_iid/draft_notes
POST /projects/:id/merge_requests/:merge_request_iid/draft_notes
PUT /projects/:id/merge_requests/:merge_request_iid/draft_notes/:draft_note_id
DELETE /projects/:id/merge_requests/:merge_request_iid/draft_notes/:draft_note_id
PUT /projects/:id/merge_requests/:merge_request_iid/draft_notes/:draft_note_id/publish
POST /projects/:id/merge_requests/:merge_request_iid/draft_notes/bulk_publish

Breaking Changes

None - this is a purely additive feature that doesn't modify existing functionality.

Usage Example

typescript
// Create a draft note
await createDraftNote("project-id", "123", "This needs improvement", {
position_type: "text",
base_sha: "abc123",
head_sha: "def456",
start_sha: "ghi789",
new_path: "src/file.js",
new_line: 42
});

// Publish all drafts when ready
await bulkPublishDraftNotes("project-id", "123");

Benefits

Improved Code Review Workflow: Users can draft and refine comments before publishing
Better Collaboration: Reduces noise in merge request discussions
Enhanced Productivity: Bulk operations save time when reviewing large changes
Complete API Coverage: Full parity with GitLab's native draft notes functionality

@g-tiwari
Copy link
Contributor Author

thanks for creating this MCP.
@zereight @iwakitakuma33 Can you guys review this pull request for draft_note API. ?

@iwakitakuma33 iwakitakuma33 self-requested a review August 3, 2025 09:29
@iwakitakuma33 iwakitakuma33 merged commit 15d330c into zereight:main Aug 3, 2025
7 checks passed
@iwakitakuma33
Copy link
Collaborator

@g-tiwari thanks!!

related #197

@zereight zereight mentioned this pull request Aug 13, 2025
iwakitakuma33 added a commit that referenced this pull request Aug 20, 2025
feat: Add createDraftNote api support, useful for bulk code review
iwakitakuma33 added a commit that referenced this pull request Aug 20, 2025
feat: Add createDraftNote api support, useful for bulk code review
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants