Feature Request: Add tools to create commits and merge requests
Summary
Add new MCP tools to enable creating commits and merge requests, allowing the MCP server to programmatically contribute code changes to GitLab projects.
Proposed Tools
1. create_commit
Creates a new commit using GitLab's Commits API.
Arguments:
-
project_id(required): GitLab project ID (numeric or path format) -
branch(required): Branch name (must not be a protected branch) -
commit_message(required): Commit message -
path(required): File path relative to repository root -
contents(optional): File contents (required forcreate/updateactions, optional formoveto overwrite content, not used fordelete) -
action(required): File action - one of:create,delete,move,update -
previous_path(optional): Required whenaction=move- the previous file path -
amend(optional): If true, modify the latest commit instead of creating new commit
Behavior:
- Uses a builder pattern approach to allow incremental commit building
- If
amend=falseand branch doesn't exist, creates the branch based on the repository's default branch - Supports create, delete, move, and update file operations
- For
action=move, bothpath(new location) andprevious_path(old location) are required - For
action=move, omittingcontentspreserves existing file content; providingcontentsoverwrites it - Returns API errors directly to the user (e.g., protected branch, permission issues)
2. create_merge_request
Creates a new merge request using GitLab's Merge Requests API.
Arguments:
-
project_id(required): GitLab project ID -
source_branch(required): Source branch name -
title(required): Merge request title -
description(optional): Merge request description -
target_branch(optional): Target branch name (defaults to project's default branch) -
labels(optional): Comma-separated list of labels -
assignee_ids(optional): Comma-separated list of user IDs to assign the merge request to -
reviewer_ids(optional): Comma-separated list of user IDs to set as reviewers -
milestone_id(optional): Milestone ID to assign the merge request to -
remove_source_branch(optional): Whether to remove source branch after merge -
squash(optional): Whether to squash commits when merging
Note: Cross-repository merge request options (target_project_id, allow_collaboration) are omitted from the initial version to reduce complexity.
Technical Notes
- The
create_committool will use GitLab's Commits API rather than the Repository Files API for greater flexibility - The commit amending feature may not be supported by GitLab's API and might need to be omitted
- File operations will map to GitLab's commit actions (create, delete, move, update)
Open Questions
- Should we combine
createandupdateactions into a singleupsertoperation, or keep them separate to match GitLab's API more closely?