Documentation
¶
Overview ¶
Package mergetrains implements MCP tools for GitLab merge train operations.
The package wraps the GitLab Merge trains API:
Index ¶
- func ActionSpecs(client *gitlabclient.Client) []toolutil.ActionSpec
- func FormatListMarkdown(out ListOutput) string
- func FormatOutputMarkdown(out Output) string
- type AddInput
- type GetInput
- type ListBranchInput
- type ListOutput
- func AddMergeRequestToMergeTrain(ctx context.Context, client *gitlabclient.Client, input AddInput) (ListOutput, error)
- func ListMergeRequestInMergeTrain(ctx context.Context, client *gitlabclient.Client, input ListBranchInput) (ListOutput, error)
- func ListProjectMergeTrains(ctx context.Context, client *gitlabclient.Client, input ListProjectInput) (ListOutput, error)
- type ListProjectInput
- type MergeRequestOutput
- type Output
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 train actions exposed as MCP tools. The list, get, and add routes are projected into the dynamic, meta, individual, and audit surfaces by the action catalog (ADR-0004).
func FormatListMarkdown ¶
func FormatListMarkdown(out ListOutput) string
FormatListMarkdown formats a list of merge train entries.
func FormatOutputMarkdown ¶
FormatOutputMarkdown formats a single merge train entry.
Types ¶
type AddInput ¶
type AddInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
MergeRequestID int64 `json:"merge_request_iid" jsonschema:"Merge request internal ID,required"`
AutoMerge bool `json:"auto_merge,omitempty" jsonschema:"Enable auto-merge when pipeline succeeds"`
SHA string `json:"sha,omitempty" jsonschema:"Head SHA of the merge request to verify"`
Squash bool `json:"squash,omitempty" jsonschema:"Squash commits when merging"`
WhenPipelineSucceeds bool `` /* 135-byte string literal not displayed */
}
AddInput defines parameters for adding a merge request to a merge train. It mirrors gl.AddMergeRequestToMergeTrainOptions (auto_merge, sha, squash, and the deprecated when_pipeline_succeeds).
type GetInput ¶
type GetInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
MergeRequestID int64 `json:"merge_request_iid" jsonschema:"Merge request internal ID,required"`
}
GetInput defines parameters for getting a merge request on a merge train.
type ListBranchInput ¶
type ListBranchInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
TargetBranch string `json:"target_branch" jsonschema:"Target branch name,required"`
Scope string `json:"scope,omitempty" jsonschema:"Filter by scope: active, complete"`
Sort string `json:"sort,omitempty" jsonschema:"Sort order: asc or desc"`
OrderBy string `json:"order_by,omitempty" jsonschema:"Column to order results by (keyset pagination)"`
toolutil.PaginationInput
toolutil.KeysetPaginationInput
}
ListBranchInput defines parameters for listing MRs in a merge train for a specific branch. It mirrors gl.ListMergeTrainsOptions (scope, sort) and the embedded gl.ListOptions (order_by, sort, pagination, page_token), exposing both offset and keyset pagination.
type ListOutput ¶
type ListOutput struct {
toolutil.HintableOutput
Trains []Output `json:"trains"`
Pagination toolutil.PaginationOutput `json:"pagination"`
}
ListOutput wraps a list of merge train entries.
func AddMergeRequestToMergeTrain ¶
func AddMergeRequestToMergeTrain(ctx context.Context, client *gitlabclient.Client, input AddInput) (ListOutput, error)
AddMergeRequestToMergeTrain adds a merge request to a project's merge train via the GitLab Merge trains API (POST /projects/:id/merge_trains/merge_requests/:merge_request_iid). Optional AutoMerge/SHA/Squash parameters forward to the underlying client-go options. Requires the MR to be approved with a passing pipeline; merge trains require a Premium license.
func ListMergeRequestInMergeTrain ¶
func ListMergeRequestInMergeTrain(ctx context.Context, client *gitlabclient.Client, input ListBranchInput) (ListOutput, error)
ListMergeRequestInMergeTrain lists the merge requests currently sitting on the merge train for a specific target branch via the GitLab Merge trains API (GET /projects/:id/merge_trains/:target_branch).
func ListProjectMergeTrains ¶
func ListProjectMergeTrains(ctx context.Context, client *gitlabclient.Client, input ListProjectInput) (ListOutput, error)
ListProjectMergeTrains lists all merge trains in a project via the GitLab Merge trains API (GET /projects/:id/merge_trains). Merge trains require a Premium license.
type ListProjectInput ¶
type ListProjectInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
Scope string `json:"scope,omitempty" jsonschema:"Filter by scope: active, complete"`
Sort string `json:"sort,omitempty" jsonschema:"Sort order: asc or desc"`
OrderBy string `json:"order_by,omitempty" jsonschema:"Column to order results by (keyset pagination)"`
toolutil.PaginationInput
toolutil.KeysetPaginationInput
}
ListProjectInput defines parameters for listing project merge trains. It mirrors gl.ListMergeTrainsOptions (scope, sort) and the embedded gl.ListOptions (order_by, sort, pagination, page_token), exposing both offset and keyset pagination via the embedded PaginationInput and KeysetPaginationInput.
type MergeRequestOutput ¶
type MergeRequestOutput struct {
ID int64 `json:"id"`
IID int64 `json:"iid"`
ProjectID int64 `json:"project_id"`
Title string `json:"title"`
Description string `json:"description"`
State string `json:"state"`
CreatedAt string `json:"created_at,omitempty"`
UpdatedAt string `json:"updated_at,omitempty"`
WebURL string `json:"web_url,omitempty"`
}
MergeRequestOutput mirrors gl.MergeTrainMergeRequest, the merge request embedded on the merge-train "merge_request" key, surfacing every SDK field.
type Output ¶
type Output struct {
toolutil.HintableOutput
ID int64 `json:"id"`
MergeRequest MergeRequestOutput `json:"merge_request"`
User *toolutil.BasicUserOutput `json:"user,omitempty"`
Pipeline *toolutil.PipelineOutput `json:"pipeline,omitempty"`
TargetBranch string `json:"target_branch"`
Status string `json:"status"`
Duration int64 `json:"duration"`
CreatedAt string `json:"created_at,omitempty"`
UpdatedAt string `json:"updated_at,omitempty"`
MergedAt string `json:"merged_at,omitempty"`
}
Output represents a merge train entry, mirroring gl.MergeTrain with full nested objects for the merge_request, user, and pipeline sub-objects.
func GetMergeRequestOnMergeTrain ¶
func GetMergeRequestOnMergeTrain(ctx context.Context, client *gitlabclient.Client, input GetInput) (Output, error)
GetMergeRequestOnMergeTrain retrieves the merge train status for a single merge request via the GitLab Merge trains API (GET /projects/:id/merge_trains/merge_requests/:merge_request_iid). Returns the active train entry or a 404 when the MR is not on a merge train.