mergerequests

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package mergerequests implements MCP tools for GitLab merge request operations.

The package covers merge request create, get, list, update, merge, rebase, close, reopen, reviewer and assignee metadata, branch relationships, squash and source-branch cleanup flags, and workflow helpers used by catalog-backed meta and dynamic surfaces. Related domains provide approvals, changes, context commits, discussions, draft notes, notes, and merge trains.

GitLab API References

The primary API backing this package is:

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActionSpecs

func ActionSpecs(client *gitlabclient.Client) []toolutil.ActionSpec

ActionSpecs returns canonical specs for merge request actions exposed as MCP tools. The full MR lifecycle (create, read, update, merge, approve, delete, rebase, subscribe, time tracking, dependencies) is projected into the dynamic, meta, individual, and audit surfaces by the action catalog (ADR-0004).

func AuthorName added in v2.3.0

func AuthorName(mr Output) string

AuthorName returns the username of the merge request author, or "" when the author object is absent. Exported for downstream consumers (e.g. search) that render the author after the 1:1 object migration.

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 DeleteDependencyOutput

func DeleteDependencyOutput(ctx context.Context, client *gitlabclient.Client, input DeleteDependencyInput) (toolutil.DeleteOutput, error)

DeleteDependencyOutput removes a merge request dependency and returns the legacy toolutil.DeleteOutput success shape required by the destructive-action contract.

func DeleteOutput

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

DeleteOutput deletes a merge request and returns the legacy toolutil.DeleteOutput success shape required by the destructive-action contract.

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 ProjectPath added in v2.3.0

func ProjectPath(mr Output) string

ProjectPath returns the "group/project" path derived from the MR references object, or "" when unavailable. Exported for downstream consumers (e.g. search) that previously read the flattened project_path scalar.

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.

func UnapproveOutput

func UnapproveOutput(ctx context.Context, client *gitlabclient.Client, input ApproveInput) (toolutil.DeleteOutput, error)

UnapproveOutput removes approval from a merge request and returns the legacy toolutil.DeleteOutput success shape required by the destructive-action contract.

Types

type AddSpentTimeInput

type AddSpentTimeInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	MRIID     int64                `json:"merge_request_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:"merge_request_iid"     jsonschema:"Merge request IID (project-scoped, not 'merge_request_id'),required"`
	SHA       string               `` /* 144-byte string literal not displayed */
}

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 BlockingMergeRequestOutput added in v2.3.0

type BlockingMergeRequestOutput struct {
	ID                          int64                                `json:"id"`
	IID                         int64                                `json:"iid"`
	TargetBranch                string                               `json:"target_branch"`
	SourceBranch                string                               `json:"source_branch"`
	ProjectID                   int64                                `json:"project_id"`
	Title                       string                               `json:"title"`
	State                       string                               `json:"state"`
	CreatedAt                   string                               `json:"created_at,omitempty"`
	UpdatedAt                   string                               `json:"updated_at,omitempty"`
	Upvotes                     int64                                `json:"upvotes"`
	Downvotes                   int64                                `json:"downvotes"`
	Author                      *toolutil.BasicUserOutput            `json:"author,omitempty"`
	Assignee                    *toolutil.BasicUserOutput            `json:"assignee,omitempty"`
	Assignees                   []*toolutil.BasicUserOutput          `json:"assignees,omitempty"`
	Reviewers                   []*toolutil.BasicUserOutput          `json:"reviewers,omitempty"`
	SourceProjectID             int64                                `json:"source_project_id"`
	TargetProjectID             int64                                `json:"target_project_id"`
	Labels                      []string                             `json:"labels"`
	Description                 string                               `json:"description"`
	Draft                       bool                                 `json:"draft"`
	Milestone                   string                               `json:"milestone,omitempty"`
	AutoMerge                   bool                                 `json:"auto_merge"`
	DetailedMergeStatus         string                               `json:"detailed_merge_status"`
	MergedAt                    string                               `json:"merged_at,omitempty"`
	ClosedBy                    *toolutil.BasicUserOutput            `json:"closed_by,omitempty"`
	ClosedAt                    string                               `json:"closed_at,omitempty"`
	SHA                         string                               `json:"sha"`
	MergeCommitSHA              string                               `json:"merge_commit_sha"`
	SquashCommitSHA             string                               `json:"squash_commit_sha"`
	UserNotesCount              int64                                `json:"user_notes_count"`
	ShouldRemoveSourceBranch    *bool                                `json:"should_remove_source_branch,omitempty"`
	ForceRemoveSourceBranch     bool                                 `json:"force_remove_source_branch"`
	WebURL                      string                               `json:"web_url"`
	References                  *toolutil.ReferencesOutput           `json:"references,omitempty"`
	DiscussionLocked            *bool                                `json:"discussion_locked,omitempty"`
	TimeStats                   *toolutil.TimeStatsOutput            `json:"time_stats,omitempty"`
	Squash                      bool                                 `json:"squash"`
	TaskCompletionStatus        *toolutil.TaskCompletionStatusOutput `json:"task_completion_status,omitempty"`
	HasConflicts                bool                                 `json:"has_conflicts"`
	BlockingDiscussionsResolved bool                                 `json:"blocking_discussions_resolved"`
	MergeUser                   *toolutil.BasicUserOutput            `json:"merge_user,omitempty"`
	MergeAfter                  string                               `json:"merge_after,omitempty"`
	Imported                    bool                                 `json:"imported"`
	ImportedFrom                string                               `json:"imported_from"`
	PreparedAt                  string                               `json:"prepared_at,omitempty"`
	SquashOnMerge               bool                                 `json:"squash_on_merge"`
	WorkInProgress              bool                                 `json:"work_in_progress"`
	MergeWhenPipelineSucceeds   bool                                 `json:"merge_when_pipeline_succeeds"`
	MergedBy                    *toolutil.BasicUserOutput            `json:"merged_by,omitempty"`
	ApprovalsBeforeMerge        *int64                               `json:"approvals_before_merge,omitempty" tier:"premium"`
	Reference                   string                               `json:"reference"`
	MergeStatus                 string                               `json:"merge_status"`
}

BlockingMergeRequestOutput mirrors gl.BlockingMergeRequest (the blocking_merge_request object on a merge-request dependency). It is a BasicMergeRequest-shaped object surfaced 1:1 with the SDK field set.

type CommitsInput

type CommitsInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	MRIID     int64                `json:"merge_request_iid"     jsonschema:"Merge request IID (project-scoped, not 'merge_request_id'),required"`
	OrderBy   string               `json:"order_by,omitempty"    jsonschema:"Column to order results by (e.g. created_at)"`
	Sort      string               `json:"sort,omitempty"        jsonschema:"Sort direction (asc, desc)"`
	toolutil.PaginationInput
	toolutil.KeysetPaginationInput
}

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:"Label names 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)"`

	// Deprecated approvals control (use the Merge Request Approvals API instead)
	ApprovalsBeforeMerge int64 `` /* 166-byte string literal not displayed */
}

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:"merge_request_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:"merge_request_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:"merge_request_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:"merge_request_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:"merge_request_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"`
	BlockingMergeRequest *BlockingMergeRequestOutput `json:"blocking_merge_request,omitempty"`
	ProjectID            int64                       `json:"project_id"`
}

DependencyOutput mirrors gl.MergeRequestDependency. The blocking merge request is surfaced as a full nested object on the canonical blocking_merge_request key rather than flattened scalars.

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 = toolutil.DiffRefsOutput

DiffRefsOutput is the diff refs object (base, head, start SHAs) of a merge request. The canonical definition lives in toolutil.DiffRefsOutput; this alias preserves all existing references within the package unchanged.

type GetDependenciesInput

type GetDependenciesInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	MRIID     int64                `json:"merge_request_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:"merge_request_iid"     jsonschema:"Merge request IID (project-scoped, not 'merge_request_id'),required"`
	IncludeDivergedCommitsCount *bool                `` /* 160-byte string literal not displayed */
	IncludeRebaseInProgress     *bool                `` /* 131-byte string literal not displayed */
	RenderHTML                  *bool                `json:"render_html,omitempty"                    jsonschema:"Return the title and description rendered to HTML"`
}

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:"merge_request_iid"     jsonschema:"Merge request IID (project-scoped, not 'merge_request_id'),required"`
	OrderBy   string               `json:"order_by,omitempty"    jsonschema:"Column to order results by (e.g. created_at)"`
	Sort      string               `json:"sort,omitempty"        jsonschema:"Sort direction (asc, desc)"`
	toolutil.PaginationInput
	toolutil.KeysetPaginationInput
}

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:"Label names to filter by"`
	NotLabels              []string `json:"not_labels,omitempty"      jsonschema:"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"`
	NotAuthorUsername      string   `json:"not_author_username,omitempty" jsonschema:"Exclude MRs authored by this username"`
	ReviewerUsername       string   `json:"reviewer_username,omitempty"   jsonschema:"Filter by reviewer username"`
	Approved               string   `json:"approved,omitempty"            jsonschema:"Filter by approval status: 'yes' or 'no' (Premium)"`
	In                     string   `json:"in,omitempty"                  jsonschema:"Scope of the search filter (e.g. title, description, or title,description)"`
	MyReactionEmoji        string   `json:"my_reaction_emoji,omitempty"   jsonschema:"Filter by MRs the caller reacted to with this emoji (e.g. thumbsup)"`
	View                   string   `json:"view,omitempty"                jsonschema:"Set to 'simple' to return only basic MR fields"`
	WIP                    string   `json:"wip,omitempty"                 jsonschema:"Filter by draft/WIP status: 'yes' for draft MRs, 'no' for non-draft"`
	AuthorID               int64    `json:"author_id,omitempty"           jsonschema:"Filter by author user ID"`
	AssigneeID             int64    `json:"assignee_id,omitempty"         jsonschema:"Filter by assignee user ID"`
	ReviewerID             int64    `json:"reviewer_id,omitempty"         jsonschema:"Filter by reviewer user ID"`
	ApproverIDs            []int64  `json:"approver_ids,omitempty"        jsonschema:"Filter by MRs with all listed users as eligible approvers"`
	ApprovedByIDs          []int64  `json:"approved_by_ids,omitempty"     jsonschema:"Filter by MRs approved by all listed user IDs"`
	WithLabelsDetails      *bool    `json:"with_labels_details,omitempty"       jsonschema:"Include full label details (color, description) in the response"`
	WithMergeStatusRecheck *bool    `json:"with_merge_status_recheck,omitempty" jsonschema:"Asynchronously recalculate each MR's merge_status before returning"`
	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
	toolutil.KeysetPaginationInput
}

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:"Label names to filter by"`
	NotLabels              []string             `json:"not_labels,omitempty"        jsonschema:"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"`
	NotAuthorUsername      string               `json:"not_author_username,omitempty" jsonschema:"Exclude MRs authored by this username"`
	ReviewerUsername       string               `json:"reviewer_username,omitempty"   jsonschema:"Filter by reviewer username"`
	In                     string               `json:"in,omitempty"                  jsonschema:"Scope of the search filter (e.g. title, description, or title,description)"`
	MyReactionEmoji        string               `json:"my_reaction_emoji,omitempty"   jsonschema:"Filter by MRs the caller reacted to with this emoji (e.g. thumbsup)"`
	View                   string               `json:"view,omitempty"                jsonschema:"Set to 'simple' to return only basic MR fields"`
	WIP                    string               `json:"wip,omitempty"                 jsonschema:"Filter by draft/WIP status: 'yes' for draft MRs, 'no' for non-draft"`
	AuthorID               int64                `json:"author_id,omitempty"           jsonschema:"Filter by author user ID"`
	AssigneeID             int64                `json:"assignee_id,omitempty"         jsonschema:"Filter by assignee user ID"`
	ReviewerID             int64                `json:"reviewer_id,omitempty"         jsonschema:"Filter by reviewer user ID"`
	ApproverIDs            []int64              `json:"approver_ids,omitempty"        jsonschema:"Filter by MRs with all listed users as eligible approvers"`
	ApprovedByIDs          []int64              `json:"approved_by_ids,omitempty"     jsonschema:"Filter by MRs approved by all listed user IDs"`
	WithLabelsDetails      *bool                `json:"with_labels_details,omitempty"       jsonschema:"Include full label details (color, description) in the response"`
	WithMergeStatusRecheck *bool                `json:"with_merge_status_recheck,omitempty" jsonschema:"Asynchronously recalculate each MR's merge_status before returning"`
	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
	toolutil.KeysetPaginationInput
}

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:"Label names to filter by"`
	NotLabels              []string             `json:"not_labels,omitempty"    jsonschema:"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"`
	NotAuthorUsername      string               `json:"not_author_username,omitempty" jsonschema:"Exclude MRs authored by this username"`
	ReviewerUsername       string               `json:"reviewer_username,omitempty"   jsonschema:"Filter by reviewer username"`
	Environment            string               `json:"environment,omitempty"         jsonschema:"Filter by deployment environment name"`
	MyReactionEmoji        string               `json:"my_reaction_emoji,omitempty"   jsonschema:"Filter by MRs the caller reacted to with this emoji (e.g. thumbsup)"`
	View                   string               `json:"view,omitempty"                jsonschema:"Set to 'simple' to return only basic MR fields"`
	WIP                    string               `json:"wip,omitempty"                 jsonschema:"Filter by draft/WIP status: 'yes' for draft MRs, 'no' for non-draft"`
	AuthorID               int64                `json:"author_id,omitempty"           jsonschema:"Filter by author user ID"`
	AssigneeID             int64                `json:"assignee_id,omitempty"         jsonschema:"Filter by assignee user ID"`
	ReviewerID             int64                `json:"reviewer_id,omitempty"         jsonschema:"Filter by reviewer user ID"`
	ApproverIDs            []int64              `json:"approver_ids,omitempty"        jsonschema:"Filter by MRs with all listed users as eligible approvers"`
	ApprovedByIDs          []int64              `json:"approved_by_ids,omitempty"     jsonschema:"Filter by MRs approved by all listed user IDs"`
	WithLabelsDetails      *bool                `json:"with_labels_details,omitempty"        jsonschema:"Include full label details (color, description) in the response"`
	WithMergeStatusRecheck *bool                `json:"with_merge_status_recheck,omitempty"  jsonschema:"Asynchronously recalculate each MR's merge_status before returning"`
	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)"`
	DeployedAfter          string               `json:"deployed_after,omitempty"  jsonschema:"Return MRs deployed after date (ISO 8601 format)"`
	DeployedBefore         string               `json:"deployed_before,omitempty" jsonschema:"Return MRs deployed before date (ISO 8601 format)"`
	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
	toolutil.KeysetPaginationInput
}

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                `` /* 138-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)"`
	MergeWhenPipelineSucceeds *bool                `` /* 145-byte string literal not displayed */
	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

Output is the canonical merge-request output shape. The authoritative definition lives in toolutil.MergeRequestOutput; this alias keeps all existing call sites within this package unchanged (ADR-0004).

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 (the get endpoint payload) to the MCP tool output format. It first projects the embedded BasicMergeRequest, then layers on the MergeRequest-only fields.

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:"merge_request_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:"merge_request_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                `` /* 126-byte string literal not displayed */
	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:"merge_request_iid"     jsonschema:"Merge request IID (project-scoped, not 'merge_request_id'),required"`
	OrderBy   string               `json:"order_by,omitempty"    jsonschema:"Column to order results by (e.g. created_at)"`
	Sort      string               `json:"sort,omitempty"        jsonschema:"Sort direction (asc, desc)"`
	toolutil.PaginationInput
	toolutil.KeysetPaginationInput
}

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:"merge_request_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
	toolutil.TimeStatsOutput
}

TimeStatsOutput is the standalone return type for the five time-tracking handlers (SetTimeEstimate, ResetTimeEstimate, AddSpentTime, ResetSpentTime, GetTimeStats). It embeds both HintableOutput (adds next_steps at the top level) and toolutil.TimeStatsOutput (the pure four-field sub-object). JSON serialization flattens both embeds, producing:

{ "next_steps": [...], "human_time_estimate": "3h", ... }

The nested Output.TimeStats field uses *toolutil.TimeStatsOutput (pure, no next_steps) to avoid schema noise inside a compound response.

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                `` /* 128-byte string literal not displayed */
	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:"Label names to replace all labels on the merge request"`
	AddLabels          []string             `json:"add_labels,omitempty"          jsonschema:"Label names to add without removing existing"`
	RemoveLabels       []string             `json:"remove_labels,omitempty"       jsonschema:"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