badges

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package badges implements MCP tool handlers for GitLab project and group badges. It wraps the ProjectBadgesService and GroupBadgesService from client-go v2.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteGroup

func DeleteGroup(ctx context.Context, client *gitlabclient.Client, input DeleteGroupInput) error

DeleteGroup deletes a group badge.

func DeleteProject

func DeleteProject(ctx context.Context, client *gitlabclient.Client, input DeleteProjectInput) error

DeleteProject deletes a project badge.

func FormatBadgeListMarkdown

func FormatBadgeListMarkdown(badges []BadgeItem, title string, pagination toolutil.PaginationOutput) *mcp.CallToolResult

FormatBadgeListMarkdown formats a list of badges.

func FormatBadgeMarkdown

func FormatBadgeMarkdown(b BadgeItem) *mcp.CallToolResult

FormatBadgeMarkdown formats a single badge.

func RegisterTools

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

RegisterTools registers all badge tools on the MCP server.

Types

type AddGroupInput

type AddGroupInput struct {
	GroupID  toolutil.StringOrInt `json:"group_id" jsonschema:"Group ID or URL-encoded path,required"`
	LinkURL  string               `json:"link_url" jsonschema:"Badge link URL (supports placeholders),required"`
	ImageURL string               `json:"image_url" jsonschema:"Badge image URL (supports placeholders),required"`
	Name     string               `json:"name,omitempty" jsonschema:"Badge name"`
}

AddGroupInput is the input for adding a group badge.

type AddGroupOutput

type AddGroupOutput struct {
	toolutil.HintableOutput
	Badge BadgeItem `json:"badge"`
}

AddGroupOutput is the output after adding a group badge.

func AddGroup

func AddGroup(ctx context.Context, client *gitlabclient.Client, input AddGroupInput) (AddGroupOutput, error)

AddGroup adds a badge to a group.

type AddProjectInput

type AddProjectInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	LinkURL   string               `json:"link_url" jsonschema:"Badge link URL (supports placeholders),required"`
	ImageURL  string               `json:"image_url" jsonschema:"Badge image URL (supports placeholders),required"`
	Name      string               `json:"name,omitempty" jsonschema:"Badge name"`
}

AddProjectInput is the input for adding a project badge.

type AddProjectOutput

type AddProjectOutput struct {
	toolutil.HintableOutput
	Badge BadgeItem `json:"badge"`
}

AddProjectOutput is the output after adding a project badge.

func AddProject

func AddProject(ctx context.Context, client *gitlabclient.Client, input AddProjectInput) (AddProjectOutput, error)

AddProject adds a badge to a project.

type BadgeItem

type BadgeItem struct {
	ID               int64  `json:"id"`
	Name             string `json:"name,omitempty"`
	LinkURL          string `json:"link_url"`
	ImageURL         string `json:"image_url"`
	RenderedLinkURL  string `json:"rendered_link_url,omitempty"`
	RenderedImageURL string `json:"rendered_image_url,omitempty"`
	Kind             string `json:"kind,omitempty"`
}

BadgeItem represents a badge in output.

type DeleteGroupInput

type DeleteGroupInput struct {
	GroupID toolutil.StringOrInt `json:"group_id" jsonschema:"Group ID or URL-encoded path,required"`
	BadgeID int64                `json:"badge_id" jsonschema:"Badge ID,required"`
}

DeleteGroupInput is the input for deleting a group badge.

type DeleteProjectInput

type DeleteProjectInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	BadgeID   int64                `json:"badge_id" jsonschema:"Badge ID,required"`
}

DeleteProjectInput is the input for deleting a project badge.

type EditGroupInput

type EditGroupInput struct {
	GroupID  toolutil.StringOrInt `json:"group_id" jsonschema:"Group ID or URL-encoded path,required"`
	BadgeID  int64                `json:"badge_id" jsonschema:"Badge ID,required"`
	LinkURL  string               `json:"link_url,omitempty" jsonschema:"New badge link URL"`
	ImageURL string               `json:"image_url,omitempty" jsonschema:"New badge image URL"`
	Name     string               `json:"name,omitempty" jsonschema:"New badge name"`
}

EditGroupInput is the input for editing a group badge.

type EditGroupOutput

type EditGroupOutput struct {
	toolutil.HintableOutput
	Badge BadgeItem `json:"badge"`
}

EditGroupOutput is the output after editing a group badge.

func EditGroup

func EditGroup(ctx context.Context, client *gitlabclient.Client, input EditGroupInput) (EditGroupOutput, error)

EditGroup edits a group badge.

type EditProjectInput

type EditProjectInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	BadgeID   int64                `json:"badge_id" jsonschema:"Badge ID,required"`
	LinkURL   string               `json:"link_url,omitempty" jsonschema:"New badge link URL"`
	ImageURL  string               `json:"image_url,omitempty" jsonschema:"New badge image URL"`
	Name      string               `json:"name,omitempty" jsonschema:"New badge name"`
}

EditProjectInput is the input for editing a project badge.

type EditProjectOutput

type EditProjectOutput struct {
	toolutil.HintableOutput
	Badge BadgeItem `json:"badge"`
}

EditProjectOutput is the output after editing a project badge.

func EditProject

func EditProject(ctx context.Context, client *gitlabclient.Client, input EditProjectInput) (EditProjectOutput, error)

EditProject edits a project badge.

type GetGroupInput

type GetGroupInput struct {
	GroupID toolutil.StringOrInt `json:"group_id" jsonschema:"Group ID or URL-encoded path,required"`
	BadgeID int64                `json:"badge_id" jsonschema:"Badge ID,required"`
}

GetGroupInput is the input for getting a group badge.

type GetGroupOutput

type GetGroupOutput struct {
	toolutil.HintableOutput
	Badge BadgeItem `json:"badge"`
}

GetGroupOutput is the output for getting a group badge.

func GetGroup

func GetGroup(ctx context.Context, client *gitlabclient.Client, input GetGroupInput) (GetGroupOutput, error)

GetGroup gets a specific group badge.

type GetProjectInput

type GetProjectInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	BadgeID   int64                `json:"badge_id" jsonschema:"Badge ID,required"`
}

GetProjectInput is the input for getting a project badge.

type GetProjectOutput

type GetProjectOutput struct {
	toolutil.HintableOutput
	Badge BadgeItem `json:"badge"`
}

GetProjectOutput is the output for getting a project badge.

func GetProject

func GetProject(ctx context.Context, client *gitlabclient.Client, input GetProjectInput) (GetProjectOutput, error)

GetProject gets a specific project badge.

type ListGroupInput

type ListGroupInput struct {
	GroupID toolutil.StringOrInt `json:"group_id" jsonschema:"Group ID or URL-encoded path,required"`
	Name    string               `json:"name,omitempty" jsonschema:"Filter by badge name"`
	Page    int64                `json:"page,omitempty" jsonschema:"Page number"`
	PerPage int64                `json:"per_page,omitempty" jsonschema:"Items per page"`
}

ListGroupInput is the input for listing group badges.

type ListGroupOutput

type ListGroupOutput struct {
	toolutil.HintableOutput
	Badges     []BadgeItem               `json:"badges"`
	Pagination toolutil.PaginationOutput `json:"pagination"`
}

ListGroupOutput is the output for listing group badges.

func ListGroup

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

ListGroup returns all badges for a group.

type ListProjectInput

type ListProjectInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	Name      string               `json:"name,omitempty" jsonschema:"Filter by badge name"`
	Page      int64                `json:"page,omitempty" jsonschema:"Page number"`
	PerPage   int64                `json:"per_page,omitempty" jsonschema:"Items per page"`
}

ListProjectInput is the input for listing project badges.

type ListProjectOutput

type ListProjectOutput struct {
	toolutil.HintableOutput
	Badges     []BadgeItem               `json:"badges"`
	Pagination toolutil.PaginationOutput `json:"pagination"`
}

ListProjectOutput is the output for listing project badges.

func ListProject

func ListProject(ctx context.Context, client *gitlabclient.Client, input ListProjectInput) (ListProjectOutput, error)

ListProject returns all badges for a project.

type PreviewGroupInput

type PreviewGroupInput struct {
	GroupID  toolutil.StringOrInt `json:"group_id" jsonschema:"Group ID or URL-encoded path,required"`
	LinkURL  string               `json:"link_url" jsonschema:"Badge link URL with placeholders,required"`
	ImageURL string               `json:"image_url" jsonschema:"Badge image URL with placeholders,required"`
	Name     string               `json:"name,omitempty" jsonschema:"Badge name"`
}

PreviewGroupInput is the input for previewing a group badge.

type PreviewGroupOutput

type PreviewGroupOutput struct {
	toolutil.HintableOutput
	Badge BadgeItem `json:"badge"`
}

PreviewGroupOutput is the output for group badge preview.

func PreviewGroup

func PreviewGroup(ctx context.Context, client *gitlabclient.Client, input PreviewGroupInput) (PreviewGroupOutput, error)

PreviewGroup previews how group badge URLs render after placeholder resolution.

type PreviewProjectInput

type PreviewProjectInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	LinkURL   string               `json:"link_url" jsonschema:"Badge link URL with placeholders,required"`
	ImageURL  string               `json:"image_url" jsonschema:"Badge image URL with placeholders,required"`
}

PreviewProjectInput is the input for previewing a project badge.

type PreviewProjectOutput

type PreviewProjectOutput struct {
	toolutil.HintableOutput
	Badge BadgeItem `json:"badge"`
}

PreviewProjectOutput is the output for badge preview.

func PreviewProject

func PreviewProject(ctx context.Context, client *gitlabclient.Client, input PreviewProjectInput) (PreviewProjectOutput, error)

PreviewProject previews how badge URLs render after placeholder resolution.

Jump to

Keyboard shortcuts

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