mrapprovals

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package mrapprovals implements MCP tools for GitLab merge request approval operations.

The package wraps the GitLab Merge request approvals API:

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 approval actions.

func DeleteRule

func DeleteRule(ctx context.Context, client *gitlabclient.Client, input DeleteRuleInput) error

DeleteRule removes an approval rule from a merge request.

func FormatConfigMarkdown

func FormatConfigMarkdown(c ConfigOutput) string

FormatConfigMarkdown renders the MR approval configuration as Markdown.

func FormatRuleMarkdown

func FormatRuleMarkdown(r RuleOutput) string

FormatRuleMarkdown renders a single MR approval rule as Markdown.

func FormatRulesMarkdown

func FormatRulesMarkdown(out RulesOutput) string

FormatRulesMarkdown renders a list of MR approval rules as Markdown.

func FormatStateMarkdown

func FormatStateMarkdown(s StateOutput) string

FormatStateMarkdown renders the MR approval state as Markdown.

func Reset

func Reset(ctx context.Context, client *gitlabclient.Client, input ResetInput) error

Reset clears all existing approvals on a merge request.

Types

type Approver

type Approver struct {
	Name       string `json:"name"`
	ApprovedAt string `json:"approved_at,omitempty"`
}

Approver holds approver identity and the timestamp of approval.

type ConfigInput

type ConfigInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	MRIID     int64                `json:"merge_request_iid"     jsonschema:"Merge request internal ID,required"`
}

ConfigInput defines parameters for getting approval configuration.

type ConfigOutput

type ConfigOutput struct {
	toolutil.HintableOutput
	ID                   int64      `json:"id"`
	IID                  int64      `json:"merge_request_iid"`
	ProjectID            int64      `json:"project_id"`
	Title                string     `json:"title"`
	State                string     `json:"state"`
	Approved             bool       `json:"approved"`
	ApprovalsRequired    int64      `json:"approvals_required"`
	ApprovalsLeft        int64      `json:"approvals_left"`
	ApprovalsBeforeMerge int64      `json:"approvals_before_merge"`
	HasApprovalRules     bool       `json:"has_approval_rules"`
	UserHasApproved      bool       `json:"user_has_approved"`
	UserCanApprove       bool       `json:"user_can_approve"`
	ApprovedBy           []Approver `json:"approved_by,omitempty"`
	SuggestedNames       []string   `json:"suggested_approvers,omitempty"`
}

ConfigOutput holds the approval configuration for a merge request.

func Config

func Config(ctx context.Context, client *gitlabclient.Client, input ConfigInput) (ConfigOutput, error)

Config retrieves the approval configuration (approvals required, current approvers, suggested approvers) for a merge request.

type CreateRuleInput

type CreateRuleInput struct {
	ProjectID             toolutil.StringOrInt `json:"project_id"               jsonschema:"Project ID or URL-encoded path,required"`
	MRIID                 int64                `json:"merge_request_iid"                   jsonschema:"Merge request internal ID,required"`
	Name                  string               `json:"name"                     jsonschema:"Rule name,required"`
	ApprovalsRequired     int64                `json:"approvals_required"       jsonschema:"Number of approvals required,required"`
	ApprovalProjectRuleID int64                `json:"approval_project_rule_id" jsonschema:"Project-level approval rule ID to inherit from"`
	UserIDs               []int64              `json:"user_ids"                 jsonschema:"User IDs eligible to approve"`
	GroupIDs              []int64              `json:"group_ids"                jsonschema:"Group IDs eligible to approve"`
}

CreateRuleInput defines parameters for creating an MR approval rule.

type DeleteRuleInput

type DeleteRuleInput struct {
	ProjectID      toolutil.StringOrInt `json:"project_id"       jsonschema:"Project ID or URL-encoded path,required"`
	MRIID          int64                `json:"merge_request_iid"           jsonschema:"Merge request internal ID,required"`
	ApprovalRuleID int64                `json:"approval_rule_id" jsonschema:"Approval rule ID,required"`
}

DeleteRuleInput defines parameters for deleting an MR approval rule.

type ResetInput

type ResetInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	MRIID     int64                `json:"merge_request_iid"     jsonschema:"Merge request internal ID,required"`
}

ResetInput defines parameters for resetting approvals on a merge request.

type RuleOutput

type RuleOutput struct {
	toolutil.HintableOutput
	ID                   int64    `json:"id"`
	Name                 string   `json:"name"`
	RuleType             string   `json:"rule_type"`
	ReportType           string   `json:"report_type,omitempty"`
	Section              string   `json:"section,omitempty"`
	ApprovalsRequired    int      `json:"approvals_required"`
	Approved             bool     `json:"approved"`
	ContainsHiddenGroups bool     `json:"contains_hidden_groups,omitempty"`
	ApprovedByNames      []string `json:"approved_by_names,omitempty"`
	EligibleNames        []string `json:"eligible_names,omitempty"`
	UserNames            []string `json:"user_names,omitempty"`
	GroupNames           []string `json:"group_names,omitempty"`
}

RuleOutput represents a single approval rule for a merge request.

func CreateRule

func CreateRule(ctx context.Context, client *gitlabclient.Client, input CreateRuleInput) (RuleOutput, error)

CreateRule creates a new approval rule on a merge request.

func RuleToOutput

func RuleToOutput(r *gl.MergeRequestApprovalRule) RuleOutput

RuleToOutput converts a client-go MergeRequestApprovalRule to the MCP output representation.

func UpdateRule

func UpdateRule(ctx context.Context, client *gitlabclient.Client, input UpdateRuleInput) (RuleOutput, error)

UpdateRule updates an existing approval rule on a merge request.

type RulesInput

type RulesInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	MRIID     int64                `json:"merge_request_iid"     jsonschema:"Merge request internal ID,required"`
}

RulesInput defines parameters for listing the approval rules of a merge request.

type RulesOutput

type RulesOutput struct {
	toolutil.HintableOutput
	Rules []RuleOutput `json:"rules"`
}

RulesOutput holds the list of approval rules for a merge request.

func Rules

func Rules(ctx context.Context, client *gitlabclient.Client, input RulesInput) (RulesOutput, error)

Rules lists the approval rules configured for a merge request.

type StateInput

type StateInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	MRIID     int64                `json:"merge_request_iid"     jsonschema:"Merge request internal ID,required"`
}

StateInput defines parameters for retrieving the approval state of a merge request.

type StateOutput

type StateOutput struct {
	toolutil.HintableOutput
	ApprovalRulesOverwritten bool         `json:"approval_rules_overwritten"`
	Rules                    []RuleOutput `json:"rules"`
}

StateOutput holds the overall approval state for a merge request, including whether rules have been overridden and the list of applicable rules.

func State

func State(ctx context.Context, client *gitlabclient.Client, input StateInput) (StateOutput, error)

State retrieves the approval state of a merge request, including whether approval rules have been overridden and the list of rules with their current approval status.

type UpdateRuleInput

type UpdateRuleInput struct {
	ProjectID         toolutil.StringOrInt `json:"project_id"         jsonschema:"Project ID or URL-encoded path,required"`
	MRIID             int64                `json:"merge_request_iid"             jsonschema:"Merge request internal ID,required"`
	ApprovalRuleID    int64                `json:"approval_rule_id"   jsonschema:"Approval rule ID,required"`
	Name              string               `json:"name"               jsonschema:"Rule name"`
	ApprovalsRequired *int64               `json:"approvals_required" jsonschema:"Number of approvals required"`
	UserIDs           []int64              `json:"user_ids"           jsonschema:"User IDs eligible to approve"`
	GroupIDs          []int64              `json:"group_ids"          jsonschema:"Group IDs eligible to approve"`
}

UpdateRuleInput defines parameters for updating an MR approval rule.

Jump to

Keyboard shortcuts

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