mergerequests

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package mergerequests implements GitLab merge request CRUD operations including create, get, list (project/global/group), update, merge, approve, unapprove, commits, pipelines, delete, rebase, participants, reviewers, create-pipeline, issues-closed-on-merge, and cancel-auto-merge. It exposes typed input/output structs and handler functions registered as MCP tools.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreatePipeline

func CreatePipeline(ctx context.Context, client *gitlabclient.Client, input CreatePipelineInput) (pipelines.Output, error)

CreatePipeline triggers a new pipeline for the specified merge request.

func Delete

func Delete(ctx context.Context, client *gitlabclient.Client, input DeleteInput) error

Delete permanently deletes a merge request.

func DeleteDependency

func DeleteDependency(ctx context.Context, client *gitlabclient.Client, input DeleteDependencyInput) error

DeleteDependency removes a dependency (blocker) from a merge request.

func FormatApproveMarkdown

func FormatApproveMarkdown(a ApproveOutput) string

FormatApproveMarkdown renders the MR approval status as Markdown.

func FormatCommitsMarkdown

func FormatCommitsMarkdown(out CommitsOutput) string

FormatCommitsMarkdown renders a paginated list of MR commits as a Markdown table.

func FormatCreatePipelineMarkdown

func FormatCreatePipelineMarkdown(p pipelines.Output) string

FormatCreatePipelineMarkdown renders a single pipeline (from create-pipeline) as Markdown.

func FormatCreateTodoMarkdown

func FormatCreateTodoMarkdown(t CreateTodoOutput) string

FormatCreateTodoMarkdown renders a created to-do item as markdown.

func FormatDependenciesMarkdown

func FormatDependenciesMarkdown(out DependenciesOutput) string

FormatDependenciesMarkdown renders a list of merge request dependencies as markdown.

func FormatDependencyMarkdown

func FormatDependencyMarkdown(d DependencyOutput) string

FormatDependencyMarkdown renders a single merge request dependency as markdown.

func FormatIssuesClosedMarkdown

func FormatIssuesClosedMarkdown(out IssuesClosedOutput) string

FormatIssuesClosedMarkdown renders the issues-closed-on-merge list as a Markdown table.

func FormatListMarkdown

func FormatListMarkdown(out ListOutput) string

FormatListMarkdown renders a list of merge requests as a Markdown table.

func FormatMarkdown

func FormatMarkdown(mr Output) string

FormatMarkdown renders a single merge request as a Markdown summary.

func FormatParticipantsMarkdown

func FormatParticipantsMarkdown(out ParticipantsOutput) string

FormatParticipantsMarkdown renders MR participants as a Markdown table.

func FormatPipelinesMarkdown

func FormatPipelinesMarkdown(out PipelinesOutput) string

FormatPipelinesMarkdown renders a list of MR pipelines as a Markdown table.

func FormatRebaseMarkdown

func FormatRebaseMarkdown(r RebaseOutput) string

FormatRebaseMarkdown renders a rebase result as a short Markdown message.

func FormatRelatedIssuesMarkdown

func FormatRelatedIssuesMarkdown(out RelatedIssuesOutput) string

FormatRelatedIssuesMarkdown renders related issues as markdown.

func FormatReviewersMarkdown

func FormatReviewersMarkdown(out ReviewersOutput) string

FormatReviewersMarkdown renders MR reviewers as a Markdown table.

func FormatTimeStatsMarkdown

func FormatTimeStatsMarkdown(ts TimeStatsOutput) string

FormatTimeStatsMarkdown renders time tracking statistics as markdown.

func RegisterTools

func RegisterTools(server *mcp.Server, client *gitlabclient.Client)

RegisterTools registers all merge request CRUD tools on the given MCP server.

func Unapprove

func Unapprove(ctx context.Context, client *gitlabclient.Client, input ApproveInput) error

Unapprove removes the current user's approval from the specified merge request. Returns an error if the API call fails.

Types

type AddSpentTimeInput

type AddSpentTimeInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	MRIID     int64                `json:"mr_iid"     jsonschema:"Merge request IID (project-scoped, not 'merge_request_id'),required"`
	Duration  string               `json:"duration"   jsonschema:"Human-readable duration (e.g. 1h, 30m, 1w2d),required"`
	Summary   string               `json:"summary,omitempty" jsonschema:"Optional summary of work done"`
}

AddSpentTimeInput defines parameters for adding spent time to an MR.

type ApproveInput

type ApproveInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	MRIID     int64                `json:"mr_iid"     jsonschema:"Merge request IID (project-scoped, not 'merge_request_id'),required"`
}

ApproveInput defines parameters for approving a merge request.

type ApproveOutput

type ApproveOutput struct {
	toolutil.HintableOutput
	ApprovalsRequired int  `json:"approvals_required"`
	ApprovedBy        int  `json:"approved_by_count"`
	Approved          bool `json:"approved"`
}

ApproveOutput holds the approval state after approve/unapprove.

func Approve

func Approve(ctx context.Context, client *gitlabclient.Client, input ApproveInput) (ApproveOutput, error)

Approve adds an approval to the specified merge request and returns the updated approval state including required count, approved-by count, and overall approved status.

type CommitsInput

type CommitsInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	MRIID     int64                `json:"mr_iid"     jsonschema:"Merge request IID (project-scoped, not 'merge_request_id'),required"`
	toolutil.PaginationInput
}

CommitsInput defines parameters for listing commits in a merge request.

type CommitsOutput

type CommitsOutput struct {
	toolutil.HintableOutput
	Commits    []commits.Output          `json:"commits"`
	Pagination toolutil.PaginationOutput `json:"pagination"`
}

CommitsOutput holds a paginated list of commits for a merge request.

func Commits

func Commits(ctx context.Context, client *gitlabclient.Client, input CommitsInput) (CommitsOutput, error)

Commits retrieves the list of commits in a merge request.

type CreateInput

type CreateInput struct {
	// Basic metadata
	ProjectID    toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	SourceBranch string               `json:"source_branch" jsonschema:"Source branch name,required"`
	TargetBranch string               `` /* 167-byte string literal not displayed */
	Title        string               `json:"title" jsonschema:"Merge request title,required"`
	Description  string               `json:"description,omitempty" jsonschema:"Merge request description (Markdown supported)"`

	// Assignment and tracking
	AssigneeID  int64   `json:"assignee_id,omitempty" jsonschema:"Single user ID to assign (use assignee_ids for multiple)"`
	AssigneeIDs []int64 `json:"assignee_ids,omitempty" jsonschema:"User IDs to assign"`
	ReviewerIDs []int64 `json:"reviewer_ids,omitempty" jsonschema:"User IDs to add as reviewers"`
	Labels      string  `json:"labels,omitempty" jsonschema:"Comma-separated labels to apply"`
	MilestoneID int64   `json:"milestone_id,omitempty" jsonschema:"Milestone ID to associate with the merge request"`

	// Merge behavior
	RemoveSourceBranch *bool `` /* 167-byte string literal not displayed */
	Squash             *bool `` /* 144-byte string literal not displayed */
	AllowCollaboration *bool `json:"allow_collaboration,omitempty" jsonschema:"Allow commits from upstream members who can merge to target branch"`

	// Cross-project
	TargetProjectID int64 `json:"target_project_id,omitempty" jsonschema:"Target project ID (for cross-project/fork MRs)"`
}

CreateInput defines parameters for creating a merge request.

type CreatePipelineInput

type CreatePipelineInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	MRIID     int64                `json:"mr_iid"     jsonschema:"Merge request IID (project-scoped, not 'merge_request_id'),required"`
}

CreatePipelineInput defines parameters for creating a pipeline for a merge request.

type CreateTodoInput

type CreateTodoInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	MRIID     int64                `json:"mr_iid"     jsonschema:"Merge request IID (project-scoped, not 'merge_request_id'),required"`
}

CreateTodoInput defines parameters for creating a to-do item on a merge request.

type CreateTodoOutput

type CreateTodoOutput struct {
	toolutil.HintableOutput
	ID          int64  `json:"id"`
	ActionName  string `json:"action_name"`
	TargetType  string `json:"target_type"`
	TargetTitle string `json:"target_title"`
	TargetURL   string `json:"target_url"`
	State       string `json:"state"`
	ProjectName string `json:"project_name,omitempty"`
	CreatedAt   string `json:"created_at,omitempty"`
}

CreateTodoOutput holds the created to-do item details.

func CreateTodo

func CreateTodo(ctx context.Context, client *gitlabclient.Client, input CreateTodoInput) (CreateTodoOutput, error)

CreateTodo creates a to-do item on the specified merge request for the authenticated user. Returns the created to-do item details.

type DeleteDependencyInput

type DeleteDependencyInput struct {
	ProjectID              toolutil.StringOrInt `json:"project_id"                jsonschema:"Project ID or URL-encoded path,required"`
	MRIID                  int64                `json:"mr_iid"                    jsonschema:"Merge request IID (project-scoped, not 'merge_request_id'),required"`
	BlockingMergeRequestID int64                `json:"blocking_merge_request_id" jsonschema:"ID of the blocking merge request to remove"`
}

DeleteDependencyInput defines parameters for deleting a merge request dependency.

type DeleteInput

type DeleteInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	MRIID     int64                `json:"mr_iid"     jsonschema:"Merge request IID to delete (project-scoped, not 'merge_request_id'),required"`
}

DeleteInput defines parameters for deleting a merge request.

type DependenciesOutput

type DependenciesOutput struct {
	toolutil.HintableOutput
	Dependencies []DependencyOutput `json:"dependencies"`
}

DependenciesOutput holds a list of merge request dependencies.

func GetDependencies

func GetDependencies(ctx context.Context, client *gitlabclient.Client, input GetDependenciesInput) (DependenciesOutput, error)

GetDependencies retrieves all dependencies (blockers) for a merge request.

type DependencyInput

type DependencyInput struct {
	ProjectID              toolutil.StringOrInt `json:"project_id"                jsonschema:"Project ID or URL-encoded path,required"`
	MRIID                  int64                `json:"mr_iid"                    jsonschema:"Merge request IID (project-scoped, not 'merge_request_id'),required"`
	BlockingMergeRequestID int64                `json:"blocking_merge_request_id" jsonschema:"ID of the merge request that blocks this one"`
}

DependencyInput defines parameters for creating a merge request dependency.

type DependencyOutput

type DependencyOutput struct {
	toolutil.HintableOutput
	ID                   int64  `json:"id"`
	BlockingMRID         int64  `json:"blocking_mr_id"`
	BlockingMRIID        int64  `json:"blocking_mr_iid"`
	BlockingMRTitle      string `json:"blocking_mr_title"`
	BlockingMRState      string `json:"blocking_mr_state"`
	BlockingMRProjectID  int64  `json:"blocking_mr_project_id"`
	BlockingSourceBranch string `json:"blocking_source_branch"`
	BlockingTargetBranch string `json:"blocking_target_branch"`
	ProjectID            int64  `json:"project_id"`
}

DependencyOutput represents a merge request dependency.

func CreateDependency

func CreateDependency(ctx context.Context, client *gitlabclient.Client, input DependencyInput) (DependencyOutput, error)

CreateDependency creates a new dependency (blocker) on a merge request.

type DiffRefsOutput

type DiffRefsOutput struct {
	BaseSHA  string `json:"base_sha"`
	HeadSHA  string `json:"head_sha"`
	StartSHA string `json:"start_sha"`
}

DiffRefsOutput represents the diff refs (base, head, start SHAs) of a merge request.

type GetDependenciesInput

type GetDependenciesInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	MRIID     int64                `json:"mr_iid"     jsonschema:"Merge request IID (project-scoped, not 'merge_request_id'),required"`
}

GetDependenciesInput defines parameters for listing merge request dependencies.

type GetInput

type GetInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	MRIID     int64                `json:"mr_iid"     jsonschema:"Merge request IID (project-scoped, not 'merge_request_id'),required"`
}

GetInput defines parameters for retrieving a merge request.

type IssuesClosedInput

type IssuesClosedInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	MRIID     int64                `json:"mr_iid"     jsonschema:"Merge request IID (project-scoped, not 'merge_request_id'),required"`
	toolutil.PaginationInput
}

IssuesClosedInput defines parameters for listing issues that close on merge.

type IssuesClosedOutput

type IssuesClosedOutput struct {
	toolutil.HintableOutput
	Issues     []issues.Output           `json:"issues"`
	Pagination toolutil.PaginationOutput `json:"pagination"`
}

IssuesClosedOutput holds the list of issues that would be closed by merging an MR.

func IssuesClosed

func IssuesClosed(ctx context.Context, client *gitlabclient.Client, input IssuesClosedInput) (IssuesClosedOutput, error)

IssuesClosed retrieves the list of issues that would be closed when the specified merge request is merged.

type ListGlobalInput

type ListGlobalInput struct {
	State            string `json:"state,omitempty"           jsonschema:"Filter by state (opened, closed, merged, all)"`
	Labels           string `json:"labels,omitempty"          jsonschema:"Comma-separated label names to filter by"`
	NotLabels        string `json:"not_labels,omitempty"      jsonschema:"Comma-separated label names to exclude"`
	Milestone        string `json:"milestone,omitempty"       jsonschema:"Milestone title to filter by"`
	Scope            string `json:"scope,omitempty"           jsonschema:"Filter by scope (created_by_me, assigned_to_me, all)"`
	Search           string `json:"search,omitempty"          jsonschema:"Search in title and description"`
	SourceBranch     string `json:"source_branch,omitempty"   jsonschema:"Filter by source branch name"`
	TargetBranch     string `json:"target_branch,omitempty"   jsonschema:"Filter by target branch name"`
	AuthorUsername   string `json:"author_username,omitempty" jsonschema:"Filter by author username"`
	ReviewerUsername string `json:"reviewer_username,omitempty" jsonschema:"Filter by reviewer username"`
	Draft            *bool  `json:"draft,omitempty"           jsonschema:"Filter by draft status (true=only drafts, false=only non-drafts)"`
	CreatedAfter     string `json:"created_after,omitempty"   jsonschema:"Return MRs created after date (ISO 8601)"`
	CreatedBefore    string `json:"created_before,omitempty"  jsonschema:"Return MRs created before date (ISO 8601)"`
	UpdatedAfter     string `json:"updated_after,omitempty"   jsonschema:"Return MRs updated after date (ISO 8601)"`
	UpdatedBefore    string `json:"updated_before,omitempty"  jsonschema:"Return MRs updated before date (ISO 8601)"`
	OrderBy          string `json:"order_by,omitempty"        jsonschema:"Order by field (created_at, updated_at)"`
	Sort             string `json:"sort,omitempty"            jsonschema:"Sort direction (asc, desc)"`
	toolutil.PaginationInput
}

ListGlobalInput defines filters for listing merge requests across all projects.

type ListGroupInput

type ListGroupInput struct {
	GroupID          toolutil.StringOrInt `json:"group_id"                    jsonschema:"Group ID or URL-encoded path,required"`
	State            string               `json:"state,omitempty"             jsonschema:"Filter by state (opened, closed, merged, all)"`
	Labels           string               `json:"labels,omitempty"            jsonschema:"Comma-separated label names to filter by"`
	NotLabels        string               `json:"not_labels,omitempty"        jsonschema:"Comma-separated label names to exclude"`
	Milestone        string               `json:"milestone,omitempty"         jsonschema:"Milestone title to filter by"`
	Scope            string               `json:"scope,omitempty"             jsonschema:"Filter by scope (created_by_me, assigned_to_me, all)"`
	Search           string               `json:"search,omitempty"            jsonschema:"Search in title and description"`
	SourceBranch     string               `json:"source_branch,omitempty"     jsonschema:"Filter by source branch name"`
	TargetBranch     string               `json:"target_branch,omitempty"     jsonschema:"Filter by target branch name"`
	AuthorUsername   string               `json:"author_username,omitempty"   jsonschema:"Filter by author username"`
	ReviewerUsername string               `json:"reviewer_username,omitempty" jsonschema:"Filter by reviewer username"`
	Draft            *bool                `json:"draft,omitempty"             jsonschema:"Filter by draft status (true=only drafts, false=only non-drafts)"`
	CreatedAfter     string               `json:"created_after,omitempty"     jsonschema:"Return MRs created after date (ISO 8601)"`
	CreatedBefore    string               `json:"created_before,omitempty"    jsonschema:"Return MRs created before date (ISO 8601)"`
	UpdatedAfter     string               `json:"updated_after,omitempty"     jsonschema:"Return MRs updated after date (ISO 8601)"`
	UpdatedBefore    string               `json:"updated_before,omitempty"    jsonschema:"Return MRs updated before date (ISO 8601)"`
	OrderBy          string               `json:"order_by,omitempty"          jsonschema:"Order by field (created_at, updated_at)"`
	Sort             string               `json:"sort,omitempty"              jsonschema:"Sort direction (asc, desc)"`
	toolutil.PaginationInput
}

ListGroupInput defines filters for listing merge requests in a group.

type ListInput

type ListInput struct {
	ProjectID      toolutil.StringOrInt `json:"project_id"              jsonschema:"Project ID or URL-encoded path,required"`
	State          string               `json:"state,omitempty"         jsonschema:"Filter by state (opened, closed, merged, all)"`
	Labels         string               `json:"labels,omitempty"        jsonschema:"Comma-separated label names to filter by"`
	NotLabels      string               `json:"not_labels,omitempty"    jsonschema:"Comma-separated label names to exclude"`
	Milestone      string               `json:"milestone,omitempty"     jsonschema:"Milestone title to filter by"`
	Scope          string               `json:"scope,omitempty"         jsonschema:"Filter by scope (created_by_me, assigned_to_me, all)"`
	Search         string               `json:"search,omitempty"        jsonschema:"Search in title and description"`
	SourceBranch   string               `json:"source_branch,omitempty" jsonschema:"Filter by source branch name"`
	TargetBranch   string               `json:"target_branch,omitempty" jsonschema:"Filter by target branch name"`
	AuthorUsername string               `json:"author_username,omitempty" jsonschema:"Filter by author username"`
	Draft          *bool                `json:"draft,omitempty"         jsonschema:"Filter by draft status (true=only drafts, false=only non-drafts)"`
	IIDs           []int64              `json:"iids,omitempty"          jsonschema:"Filter by merge request internal IDs"`
	CreatedAfter   string               `json:"created_after,omitempty"  jsonschema:"Return MRs created after date (ISO 8601 format, e.g. 2025-01-01T00:00:00Z)"`
	CreatedBefore  string               `json:"created_before,omitempty" jsonschema:"Return MRs created before date (ISO 8601 format, e.g. 2025-12-31T23:59:59Z)"`
	UpdatedAfter   string               `json:"updated_after,omitempty"  jsonschema:"Return MRs updated after date (ISO 8601 format, e.g. 2025-01-01T00:00:00Z)"`
	UpdatedBefore  string               `json:"updated_before,omitempty" jsonschema:"Return MRs updated before date (ISO 8601 format, e.g. 2025-12-31T23:59:59Z)"`
	OrderBy        string               `json:"order_by,omitempty"      jsonschema:"Order by field (created_at, updated_at, title)"`
	Sort           string               `json:"sort,omitempty"          jsonschema:"Sort direction (asc, desc)"`
	toolutil.PaginationInput
}

ListInput defines filters for listing merge requests.

type ListOutput

type ListOutput struct {
	toolutil.HintableOutput
	MergeRequests []Output                  `json:"merge_requests"`
	Pagination    toolutil.PaginationOutput `json:"pagination"`
}

ListOutput holds a paginated list of merge requests.

func List

func List(ctx context.Context, client *gitlabclient.Client, input ListInput) (ListOutput, error)

List returns a paginated list of merge requests for a project. Results can be filtered by state and search terms, and ordered by the specified field and direction.

func ListGlobal

func ListGlobal(ctx context.Context, client *gitlabclient.Client, input ListGlobalInput) (ListOutput, error)

ListGlobal returns a paginated list of merge requests across all projects visible to the authenticated user.

func ListGroup

func ListGroup(ctx context.Context, client *gitlabclient.Client, input ListGroupInput) (ListOutput, error)

ListGroup returns a paginated list of merge requests in a group.

type MergeInput

type MergeInput struct {
	ProjectID                toolutil.StringOrInt `json:"project_id"                              jsonschema:"Project ID or URL-encoded path,required"`
	MRIID                    int64                `` /* 127-byte string literal not displayed */
	MergeCommitMessage       string               `json:"merge_commit_message,omitempty"           jsonschema:"Custom merge commit message"`
	Squash                   *bool                `` /* 168-byte string literal not displayed */
	ShouldRemoveSourceBranch *bool                `` /* 176-byte string literal not displayed */
	AutoMerge                *bool                `json:"auto_merge,omitempty"                     jsonschema:"Automatically merge when pipeline succeeds (auto-merge)"`
	SHA                      string               `` /* 136-byte string literal not displayed */
	SquashCommitMessage      string               `json:"squash_commit_message,omitempty"          jsonschema:"Custom squash commit message (used when squash is enabled)"`
}

MergeInput defines parameters for merging a merge request.

type Output

type Output struct {
	toolutil.HintableOutput
	ID                          int64           `json:"id"`
	IID                         int64           `json:"mr_iid"`
	ProjectID                   int64           `json:"project_id"`
	ProjectPath                 string          `json:"project_path,omitempty"`
	SourceProjectID             int64           `json:"source_project_id,omitempty"`
	TargetProjectID             int64           `json:"target_project_id,omitempty"`
	Title                       string          `json:"title"`
	Description                 string          `json:"description"`
	State                       string          `json:"state"`
	SourceBranch                string          `json:"source_branch"`
	TargetBranch                string          `json:"target_branch"`
	WebURL                      string          `json:"web_url"`
	MergeStatus                 string          `json:"merge_status"`
	Draft                       bool            `json:"draft"`
	HasConflicts                bool            `json:"has_conflicts"`
	BlockingDiscussionsResolved bool            `json:"blocking_discussions_resolved"`
	Squash                      bool            `json:"squash,omitempty"`
	SquashOnMerge               bool            `json:"squash_on_merge,omitempty"`
	MergeWhenPipelineSucceeds   bool            `json:"merge_when_pipeline_succeeds,omitempty"`
	ShouldRemoveSourceBranch    bool            `json:"should_remove_source_branch,omitempty"`
	DiscussionLocked            bool            `json:"discussion_locked"`
	RebaseInProgress            bool            `json:"rebase_in_progress,omitempty"`
	Author                      string          `json:"author,omitempty"`
	MergedBy                    string          `json:"merged_by,omitempty"`
	Assignees                   []string        `json:"assignees"`
	Reviewers                   []string        `json:"reviewers"`
	Labels                      []string        `json:"labels"`
	Milestone                   string          `json:"milestone,omitempty"`
	References                  string          `json:"references,omitempty"`
	SHA                         string          `json:"sha,omitempty"`
	MergeCommitSHA              string          `json:"merge_commit_sha,omitempty"`
	MergeError                  string          `json:"merge_error,omitempty"`
	ChangesCount                string          `json:"changes_count,omitempty"`
	DivergedCommitsCount        int64           `json:"diverged_commits_count,omitempty"`
	Upvotes                     int64           `json:"upvotes,omitempty"`
	Downvotes                   int64           `json:"downvotes,omitempty"`
	SquashCommitSHA             string          `json:"squash_commit_sha,omitempty"`
	ForceRemoveSourceBranch     bool            `json:"force_remove_source_branch,omitempty"`
	AllowCollaboration          bool            `json:"allow_collaboration,omitempty"`
	ClosedBy                    string          `json:"closed_by,omitempty"`
	MergeAfter                  string          `json:"merge_after,omitempty"`
	TaskCompletionCount         int64           `json:"task_completion_count,omitempty"`
	TaskCompletionTotal         int64           `json:"task_completion_total,omitempty"`
	TimeEstimate                int64           `json:"time_estimate,omitempty"`
	TotalTimeSpent              int64           `json:"total_time_spent,omitempty"`
	Subscribed                  bool            `json:"subscribed,omitempty"`
	FirstContribution           bool            `json:"first_contribution,omitempty"`
	DiffRefs                    *DiffRefsOutput `json:"diff_refs,omitempty"`
	PipelineID                  int64           `json:"pipeline_id,omitempty"`
	PipelineWebURL              string          `json:"pipeline_web_url,omitempty"`
	PipelineName                string          `json:"pipeline_name,omitempty"`
	HeadPipelineID              int64           `json:"head_pipeline_id,omitempty"`
	LatestBuildStartedAt        string          `json:"latest_build_started_at,omitempty"`
	LatestBuildFinishedAt       string          `json:"latest_build_finished_at,omitempty"`
	CreatedAt                   string          `json:"created_at"`
	UpdatedAt                   string          `json:"updated_at"`
	MergedAt                    string          `json:"merged_at,omitempty"`
	ClosedAt                    string          `json:"closed_at,omitempty"`
	PreparedAt                  string          `json:"prepared_at,omitempty"`
	UserNotesCount              int64           `json:"user_notes_count,omitempty"`
}

Output represents a merge request.

func BasicToOutput

func BasicToOutput(m *gl.BasicMergeRequest) Output

BasicToOutput converts a GitLab API gl.BasicMergeRequest to the MCP tool output format. BasicMergeRequest is used in list endpoints that return a lighter payload than the full MergeRequest object.

func CancelAutoMerge

func CancelAutoMerge(ctx context.Context, client *gitlabclient.Client, input GetInput) (Output, error)

CancelAutoMerge cancels the "merge when pipeline succeeds" (auto-merge) setting on a merge request. Returns the updated merge request.

func Create

func Create(ctx context.Context, client *gitlabclient.Client, input CreateInput) (Output, error)

Create creates a new merge request in the specified GitLab project. It maps optional fields (description, assignees, reviewers, labels, squash) only when provided. Returns the created merge request details.

func Get

func Get(ctx context.Context, client *gitlabclient.Client, input GetInput) (Output, error)

Get retrieves a single merge request by its internal ID within a project. Returns an error if the merge request does not exist.

func Merge

func Merge(ctx context.Context, client *gitlabclient.Client, input MergeInput) (Output, error)

Merge accepts (merges) a merge request. When squash or should_remove_source_branch are not explicitly set by the caller, the function pre-fetches the MR to detect project-level requirements (squash_on_merge, force_remove_source_branch) and applies them automatically, avoiding merge rejections from enforced settings.

func Subscribe

func Subscribe(ctx context.Context, client *gitlabclient.Client, input GetInput) (Output, error)

Subscribe subscribes the authenticated user to the given merge request to receive notifications. Returns the updated merge request.

func ToOutput

func ToOutput(m *gl.MergeRequest) Output

ToOutput converts a GitLab API gl.MergeRequest to the MCP tool output format.

func Unsubscribe

func Unsubscribe(ctx context.Context, client *gitlabclient.Client, input GetInput) (Output, error)

Unsubscribe unsubscribes the authenticated user from the given merge request. Returns the updated merge request.

func Update

func Update(ctx context.Context, client *gitlabclient.Client, input UpdateInput) (Output, error)

Update modifies an existing merge request. Only non-zero fields in the input are applied, allowing partial updates such as changing the title, description, target branch, assignees, reviewers, or triggering a state transition (close/reopen).

type ParticipantOutput

type ParticipantOutput struct {
	ID        int64  `json:"id"`
	Username  string `json:"username"`
	Name      string `json:"name"`
	State     string `json:"state"`
	AvatarURL string `json:"avatar_url,omitempty"`
	WebURL    string `json:"web_url,omitempty"`
}

ParticipantOutput represents a single MR participant.

type ParticipantsInput

type ParticipantsInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	MRIID     int64                `json:"mr_iid"     jsonschema:"Merge request IID (project-scoped, not 'merge_request_id'),required"`
}

ParticipantsInput defines parameters for listing MR participants.

type ParticipantsOutput

type ParticipantsOutput struct {
	toolutil.HintableOutput
	Participants []ParticipantOutput `json:"participants"`
}

ParticipantsOutput holds the list of participants for a merge request.

func Participants

func Participants(ctx context.Context, client *gitlabclient.Client, input ParticipantsInput) (ParticipantsOutput, error)

Participants retrieves the list of users who participated in a merge request.

type PipelinesInput

type PipelinesInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	MRIID     int64                `json:"mr_iid"     jsonschema:"Merge request IID (project-scoped, not 'merge_request_id'),required"`
}

PipelinesInput defines parameters for listing pipelines of a merge request.

type PipelinesOutput

type PipelinesOutput struct {
	toolutil.HintableOutput
	Pipelines []pipelines.Output `json:"pipelines"`
}

PipelinesOutput holds the list of pipelines for a merge request.

func Pipelines

func Pipelines(ctx context.Context, client *gitlabclient.Client, input PipelinesInput) (PipelinesOutput, error)

Pipelines retrieves the list of pipelines for a merge request.

type RebaseInput

type RebaseInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id"        jsonschema:"Project ID or URL-encoded path,required"`
	MRIID     int64                `json:"mr_iid"            jsonschema:"Merge request IID to rebase (project-scoped, not 'merge_request_id'),required"`
	SkipCI    bool                 `json:"skip_ci,omitempty"  jsonschema:"Skip triggering CI pipeline after rebase"`
}

RebaseInput defines parameters for rebasing a merge request.

type RebaseOutput

type RebaseOutput struct {
	toolutil.HintableOutput
	RebaseInProgress bool `json:"rebase_in_progress"`
}

RebaseOutput represents the result of a rebase operation.

func Rebase

func Rebase(ctx context.Context, client *gitlabclient.Client, input RebaseInput) (RebaseOutput, error)

Rebase triggers a rebase of the merge request's source branch.

type RelatedIssuesInput

type RelatedIssuesInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	MRIID     int64                `json:"mr_iid"     jsonschema:"Merge request IID (project-scoped, not 'merge_request_id'),required"`
	toolutil.PaginationInput
}

RelatedIssuesInput defines parameters for listing issues related to an MR.

type RelatedIssuesOutput

type RelatedIssuesOutput struct {
	toolutil.HintableOutput
	Issues     []issues.Output           `json:"issues"`
	Pagination toolutil.PaginationOutput `json:"pagination"`
}

RelatedIssuesOutput holds the list of issues related to a merge request.

func RelatedIssues

func RelatedIssues(ctx context.Context, client *gitlabclient.Client, input RelatedIssuesInput) (RelatedIssuesOutput, error)

RelatedIssues retrieves the list of issues related to a merge request.

type ReviewerOutput

type ReviewerOutput struct {
	ID        int64  `json:"id"`
	Username  string `json:"username"`
	Name      string `json:"name"`
	State     string `json:"state"`
	AvatarURL string `json:"avatar_url,omitempty"`
	WebURL    string `json:"web_url,omitempty"`
	Review    string `json:"review_state,omitempty"`
	CreatedAt string `json:"created_at,omitempty"`
}

ReviewerOutput represents a single MR reviewer with review state.

type ReviewersOutput

type ReviewersOutput struct {
	toolutil.HintableOutput
	Reviewers []ReviewerOutput `json:"reviewers"`
}

ReviewersOutput holds the list of reviewers for a merge request.

func Reviewers

func Reviewers(ctx context.Context, client *gitlabclient.Client, input ParticipantsInput) (ReviewersOutput, error)

Reviewers retrieves the list of reviewers assigned to a merge request.

type SetTimeEstimateInput

type SetTimeEstimateInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	MRIID     int64                `json:"mr_iid"     jsonschema:"Merge request IID (project-scoped, not 'merge_request_id'),required"`
	Duration  string               `json:"duration"   jsonschema:"Human-readable duration (e.g. 3h30m, 1w2d),required"`
}

SetTimeEstimateInput defines parameters for setting a time estimate on an MR.

type TimeStatsOutput

type TimeStatsOutput struct {
	toolutil.HintableOutput
	HumanTimeEstimate   string `json:"human_time_estimate"`
	HumanTotalTimeSpent string `json:"human_total_time_spent"`
	TimeEstimate        int64  `json:"time_estimate"`
	TotalTimeSpent      int64  `json:"total_time_spent"`
}

TimeStatsOutput represents time tracking statistics for a merge request.

func AddSpentTime

func AddSpentTime(ctx context.Context, client *gitlabclient.Client, input AddSpentTimeInput) (TimeStatsOutput, error)

AddSpentTime adds spent time for a merge request.

func GetTimeStats

func GetTimeStats(ctx context.Context, client *gitlabclient.Client, input GetInput) (TimeStatsOutput, error)

GetTimeStats retrieves total time tracking statistics for a merge request.

func ResetSpentTime

func ResetSpentTime(ctx context.Context, client *gitlabclient.Client, input GetInput) (TimeStatsOutput, error)

ResetSpentTime resets the total spent time for a merge request.

func ResetTimeEstimate

func ResetTimeEstimate(ctx context.Context, client *gitlabclient.Client, input GetInput) (TimeStatsOutput, error)

ResetTimeEstimate resets the time estimate for a merge request.

func SetTimeEstimate

func SetTimeEstimate(ctx context.Context, client *gitlabclient.Client, input SetTimeEstimateInput) (TimeStatsOutput, error)

SetTimeEstimate sets the time estimate for a merge request.

type UpdateInput

type UpdateInput struct {
	ProjectID          toolutil.StringOrInt `json:"project_id"                    jsonschema:"Project ID or URL-encoded path,required"`
	MRIID              int64                `json:"mr_iid"                        jsonschema:"Merge request IID (project-scoped, not 'merge_request_id'),required"`
	Title              string               `json:"title,omitempty"               jsonschema:"New title"`
	Description        string               `json:"description,omitempty"         jsonschema:"New description"`
	TargetBranch       string               `json:"target_branch,omitempty"       jsonschema:"New target branch"`
	AssigneeID         int64                `json:"assignee_id,omitempty"          jsonschema:"Single user ID to assign (use assignee_ids for multiple)"`
	AssigneeIDs        []int64              `json:"assignee_ids,omitempty"         jsonschema:"User IDs to assign as merge request assignees"`
	ReviewerIDs        []int64              `json:"reviewer_ids,omitempty"         jsonschema:"User IDs to add as reviewers"`
	Labels             string               `json:"labels,omitempty"               jsonschema:"Comma-separated label names to replace all labels on the merge request"`
	AddLabels          string               `json:"add_labels,omitempty"          jsonschema:"Comma-separated label names to add without removing existing"`
	RemoveLabels       string               `json:"remove_labels,omitempty"       jsonschema:"Comma-separated label names to remove"`
	MilestoneID        int64                `json:"milestone_id,omitempty"        jsonschema:"Milestone ID (0 to unset)"`
	RemoveSourceBranch *bool                `json:"remove_source_branch,omitempty" jsonschema:"Delete source branch after merge. Only set if explicitly requested"`
	Squash             *bool                `json:"squash,omitempty"              jsonschema:"Squash commits on merge. Only set if explicitly requested"`
	DiscussionLocked   *bool                `json:"discussion_locked,omitempty"   jsonschema:"Lock discussions on the merge request"`
	AllowCollaboration *bool                `json:"allow_collaboration,omitempty" jsonschema:"Allow commits from upstream members who can merge to target branch"`
	StateEvent         string               `json:"state_event,omitempty"         jsonschema:"State transition (close, reopen)"`
}

UpdateInput defines parameters for updating a merge request.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL