Skip to content

feat: add support for creating inline/line-level comments on merge request diffs using GitLab's Discussions API.#6

Open
kishan0725 wants to merge 8 commits into
rifqi96:mainfrom
kishan0725:main
Open

feat: add support for creating inline/line-level comments on merge request diffs using GitLab's Discussions API.#6
kishan0725 wants to merge 8 commits into
rifqi96:mainfrom
kishan0725:main

Conversation

@kishan0725
Copy link
Copy Markdown

What's Added

New Tools

  • gitlab_create_merge_request_discussion: Full-featured tool for creating inline comments with manual commit SHA specification
  • gitlab_create_merge_request_discussion_simple: Simplified tool that automatically fetches commit SHAs from the merge request
  • gitlab_reply_to_discussion: Reply to existing discussion threads in merge requests to continue conversations on inline comments

Implementation Details

  • Created src/types/repository.types.ts with proper TypeScript interfaces for discussion positions and diff references
  • Added handlers in src/handlers/repository-handlers.ts using GitLab's Discussions API endpoint
  • Registered tools in tool registry
  • Fixed documentation generator to properly categorize discussion-related tools
  • Auto-generated documentation in TOOLS.md

Usage Example

Creating an inline comment

The simplified version makes it easy to add inline comments:

{
  "project_id": "my-project",
  "merge_request_iid": 42,
  "body": "Consider using async/await here for better readability",
  "file_path": "src/server.ts",
  "line_number": 45,
  "line_type": "new"
}

Replying to a discussion thread

Continue conversations on existing inline comments:

{
  "project_id": "my-project",
  "merge_request_iid": 42,
  "discussion_id": "abc123def456",
  "body": "Good point! I've refactored this in the latest commit."
}

Technical Notes

  • Uses GitLab Discussions API: POST /projects/:id/merge_requests/:iid/discussions
  • Replies use: POST /projects/:id/merge_requests/:iid/discussions/:discussion_id/notes
  • Position object requires base_sha, start_sha, head_sha for proper diff positioning
  • Simplified version auto-fetches SHAs from merge request's diff_refs
  • Maintains full type safety with proper TypeScript interfaces

Complete Workflow

  1. Create inline comment: Use gitlab_create_merge_request_discussion_simple
  2. Get discussion ID: From the response of step 1
  3. Reply to thread: Use gitlab_reply_to_discussion with the discussion_id
  4. Continue conversation: Keep replying to build threaded discussions

This enables full conversational code review capabilities for AI assistants!

Add new functionality to reply to existing discussion threads in GitLab merge requests. This includes handler implementation, tool registration, documentation updates, and categorization updates.
@kishan0725 kishan0725 changed the title Add support for creating inline/line-level comments on merge request diffs using GitLab's Discussions API. This enables AI assistants to provide precise, line-specific code review feedback similar to human reviewers, including threaded conversations. Add support for creating inline/line-level comments on merge request diffs using GitLab's Discussions API. Dec 30, 2025
@kishan0725 kishan0725 changed the title Add support for creating inline/line-level comments on merge request diffs using GitLab's Discussions API. feat: add support for creating inline/line-level comments on merge request diffs using GitLab's Discussions API. Dec 30, 2025
- Add express.js and cors middleware for HTTP server implementation
- Implement StreamableHTTPServerTransport with session management
- Add health check endpoint and support for SSE connections
- Update dependencies to include required packages
…service

Add Dockerfile, docker-compose.yml, containers.json, and .dockerignore for container setup
Include lightsail-deploy.sh script for AWS deployment automation
Add DEPLOYMENT.md with comprehensive deployment guide
- Add helper functions to extract gitlab credentials and create axios instances
- Implement session management with handler contexts for each session
- Update cors to allow gitlab-specific headers
- Improve error handling for gitlab authentication failures
Only require GITLAB_API_TOKEN for stdio transport mode since HTTP mode uses headers
Add two new GitLab tool handlers to list merge request notes and discussions. This provides better visibility into merge request conversations and comments.

Update tool registry, documentation, and tool definitions to include the new functionality. Adjust tool category slices to accommodate the new tools.
Add new handler and documentation for resolving/unresolving GitLab merge request discussions. Includes updates to tool registry and tool definitions.
@rifqi96
Copy link
Copy Markdown
Owner

rifqi96 commented Jan 23, 2026

Hi there! This is nice. However, there's some minor conflict due to new commits from #4.

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