labels

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package labels implements MCP tool handlers for GitLab label operations including get, create, update, delete, subscribe, unsubscribe, promote, and list. It wraps the Labels service from client-go v2.

markdown.go provides Markdown formatting functions for project label MCP tool output.

register.go wires labels MCP tools to the MCP server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

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

Delete removes a label from a GitLab project.

func FormatListMarkdown

func FormatListMarkdown(out ListOutput) *mcp.CallToolResult

FormatListMarkdown renders a paginated list of labels as an MCP Markdown result.

func FormatListMarkdownString

func FormatListMarkdownString(out ListOutput) string

FormatListMarkdownString renders a paginated list of labels as a Markdown table string.

func FormatMarkdown

func FormatMarkdown(l Output) string

FormatMarkdown renders a single label as a Markdown summary.

func Promote

func Promote(ctx context.Context, client *gitlabclient.Client, input PromoteInput) error

Promote promotes a project label to a group label.

func RegisterTools

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

RegisterTools registers label-related tools on the MCP server.

func Unsubscribe

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

Unsubscribe removes the authenticated user's subscription from a label.

Types

type CreateInput

type CreateInput struct {
	ProjectID   toolutil.StringOrInt `json:"project_id"            jsonschema:"Project ID or URL-encoded path,required"`
	Name        string               `json:"name"                  jsonschema:"Label name,required"`
	Color       string               `json:"color"                 jsonschema:"Label color in hex format (e.g. #FF0000),required"`
	Description string               `json:"description,omitempty" jsonschema:"Label description"`
	Priority    int64                `json:"priority,omitempty"    jsonschema:"Label priority (lower is higher priority, 0 means no priority)"`
}

CreateInput defines parameters for creating a label.

type DeleteInput

type DeleteInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	LabelID   toolutil.StringOrInt `json:"label_id"   jsonschema:"Label ID or name,required"`
}

DeleteInput defines parameters for deleting a label.

type GetInput

type GetInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	LabelID   toolutil.StringOrInt `json:"label_id"   jsonschema:"Label ID or name,required"`
}

GetInput defines parameters for retrieving a single label.

type ListInput

type ListInput struct {
	ProjectID             toolutil.StringOrInt `json:"project_id"                       jsonschema:"Project ID or URL-encoded path,required"`
	Search                string               `json:"search,omitempty"                 jsonschema:"Filter labels by keyword search"`
	WithCounts            bool                 `json:"with_counts,omitempty"            jsonschema:"Include issue and merge request counts"`
	IncludeAncestorGroups bool                 `json:"include_ancestor_groups,omitempty" jsonschema:"Include labels from ancestor groups"`
	toolutil.PaginationInput
}

ListInput defines parameters for listing labels in a GitLab project.

type ListOutput

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

ListOutput holds a paginated list of labels.

func List

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

List retrieves a paginated list of labels for a GitLab project. Supports filtering by search keyword and including ancestor group labels.

type Output

type Output struct {
	toolutil.HintableOutput
	ID                     int64  `json:"id"`
	Name                   string `json:"name"`
	Color                  string `json:"color"`
	TextColor              string `json:"text_color"`
	Description            string `json:"description"`
	OpenIssuesCount        int64  `json:"open_issues_count"`
	ClosedIssuesCount      int64  `json:"closed_issues_count"`
	OpenMergeRequestsCount int64  `json:"open_merge_requests_count"`
	Priority               int64  `json:"priority"`
	IsProjectLabel         bool   `json:"is_project_label"`
	Subscribed             bool   `json:"subscribed"`
}

Output represents a single project label.

func Create

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

Create creates a new label in a GitLab project.

func Get

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

Get retrieves a single label by ID or name.

func Subscribe

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

Subscribe subscribes the authenticated user to a label to receive notifications.

func Update

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

Update modifies an existing label. Only non-empty fields are applied.

type PromoteInput

type PromoteInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	LabelID   toolutil.StringOrInt `json:"label_id"   jsonschema:"Label ID or name,required"`
}

PromoteInput defines parameters for promoting a project label to a group label.

type SubscribeInput

type SubscribeInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	LabelID   toolutil.StringOrInt `json:"label_id"   jsonschema:"Label ID or name,required"`
}

SubscribeInput defines parameters for subscribing/unsubscribing to a label.

type UpdateInput

type UpdateInput struct {
	ProjectID   toolutil.StringOrInt `json:"project_id"            jsonschema:"Project ID or URL-encoded path,required"`
	LabelID     toolutil.StringOrInt `json:"label_id"              jsonschema:"Label ID or name,required"`
	NewName     string               `json:"new_name,omitempty"    jsonschema:"New label name"`
	Color       string               `json:"color,omitempty"       jsonschema:"New label color in hex format"`
	Description string               `json:"description,omitempty" jsonschema:"New label description"`
	Priority    int64                `json:"priority,omitempty"    jsonschema:"New label priority (0 to remove)"`
}

UpdateInput defines parameters for updating a label.

Jump to

Keyboard shortcuts

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