packages

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: 20 Imported by: 0

Documentation

Overview

Package packages implements GitLab Generic Packages API operations as MCP tools. It provides handlers for publishing, downloading, listing, and deleting package files in the GitLab Package Registry.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

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

Delete deletes a package from the GitLab Package Registry.

func FileDelete

func FileDelete(ctx context.Context, _ *mcp.CallToolRequest, client *gitlabclient.Client, input FileDeleteInput) error

FileDelete deletes a single file from a package.

func FormatDownloadMarkdown

func FormatDownloadMarkdown(out DownloadOutput) string

FormatDownloadMarkdown renders a downloaded package file as Markdown.

func FormatFileListMarkdown

func FormatFileListMarkdown(out FileListOutput) string

FormatFileListMarkdown renders a paginated list of package files as a Markdown table.

func FormatListMarkdown

func FormatListMarkdown(out ListOutput) string

FormatListMarkdown renders a paginated list of packages as a Markdown table.

func FormatPublishAndLinkMarkdown

func FormatPublishAndLinkMarkdown(out PublishAndLinkOutput) string

FormatPublishAndLinkMarkdown renders a publish-and-link result as Markdown.

func FormatPublishDirMarkdown

func FormatPublishDirMarkdown(out PublishDirOutput) string

FormatPublishDirMarkdown renders a directory publish result as Markdown.

func FormatPublishMarkdown

func FormatPublishMarkdown(out PublishOutput) string

FormatPublishMarkdown renders a published package file as Markdown.

func RegisterMeta

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

RegisterMeta registers the gitlab_package meta-tool with actions: publish, download, list, file_list, delete, file_delete, publish_and_link, publish_directory.

func RegisterTools

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

RegisterTools registers tools for the GitLab Generic Packages API.

Types

type DeleteInput

type DeleteInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	PackageID toolutil.StringOrInt `json:"package_id" jsonschema:"Package ID to delete,required"`
}

DeleteInput defines input for deleting a package.

type DownloadInput

type DownloadInput struct {
	ProjectID      toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	PackageName    string               `json:"package_name" jsonschema:"Package name,required"`
	PackageVersion string               `json:"package_version" jsonschema:"Package version,required"`
	FileName       string               `json:"file_name" jsonschema:"File name to download,required"`
	OutputPath     string               `json:"output_path" jsonschema:"Absolute path where the file will be saved on the local filesystem,required"`
}

DownloadInput defines input for downloading a package file.

type DownloadOutput

type DownloadOutput struct {
	toolutil.HintableOutput
	OutputPath string `json:"output_path"`
	Size       int64  `json:"size"`
	SHA256     string `json:"sha256"`
}

DownloadOutput contains the result of a package file download.

func Download

Download downloads a file from the GitLab Generic Package Registry.

type FileDeleteInput

type FileDeleteInput struct {
	ProjectID     toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	PackageID     toolutil.StringOrInt `json:"package_id" jsonschema:"Package ID,required"`
	PackageFileID toolutil.StringOrInt `json:"package_file_id" jsonschema:"Package file ID to delete,required"`
}

FileDeleteInput defines input for deleting a single file from a package.

type FileListInput

type FileListInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	PackageID toolutil.StringOrInt `json:"package_id" jsonschema:"Package ID,required"`
	toolutil.PaginationInput
}

FileListInput defines input for listing files within a package.

type FileListItem

type FileListItem struct {
	PackageFileID int64  `json:"package_file_id"`
	PackageID     int64  `json:"package_id"`
	FileName      string `json:"file_name"`
	Size          int64  `json:"size"`
	SHA256        string `json:"sha256"`
	FileMD5       string `json:"file_md5,omitempty"`
	FileSHA1      string `json:"file_sha1,omitempty"`
	CreatedAt     string `json:"created_at,omitempty"`
}

FileListItem represents a single file within a package.

type FileListOutput

type FileListOutput struct {
	toolutil.HintableOutput
	Files      []FileListItem            `json:"files"`
	Pagination toolutil.PaginationOutput `json:"pagination"`
}

FileListOutput contains the paginated list of package files.

func FileList

func FileList(ctx context.Context, client *gitlabclient.Client, input FileListInput) (FileListOutput, error)

FileList lists files within a specific package.

type ListInput

type ListInput struct {
	ProjectID          toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	PackageName        string               `json:"package_name,omitempty" jsonschema:"Filter by package name"`
	PackageVersion     string               `json:"package_version,omitempty" jsonschema:"Filter by package version"`
	PackageType        string               `json:"package_type,omitempty" jsonschema:"Filter by type (generic, npm, maven, etc.)"`
	OrderBy            string               `json:"order_by,omitempty" jsonschema:"Order by: name, created_at, version, type"`
	Sort               string               `json:"sort,omitempty" jsonschema:"Sort direction: asc or desc"`
	IncludeVersionless bool                 `json:"include_versionless,omitempty" jsonschema:"Include versionless packages"`
	Status             string               `json:"status,omitempty" jsonschema:"Filter by status: default, hidden, processing, error"`
	toolutil.PaginationInput
}

ListInput defines input for listing project packages.

type ListItem

type ListItem struct {
	ID               int64    `json:"id"`
	Name             string   `json:"name"`
	Version          string   `json:"version"`
	PackageType      string   `json:"package_type"`
	Status           string   `json:"status"`
	CreatedAt        string   `json:"created_at,omitempty"`
	LastDownloadedAt string   `json:"last_downloaded_at,omitempty"`
	Tags             []string `json:"tags,omitempty"`
	WebPath          string   `json:"web_path,omitempty"`
}

ListItem represents a single package in the list output.

type ListOutput

type ListOutput struct {
	toolutil.HintableOutput
	Packages   []ListItem                `json:"packages"`
	Pagination toolutil.PaginationOutput `json:"pagination"`
}

ListOutput contains the paginated list of packages.

func List

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

List lists packages in a GitLab project.

type PublishAndLinkInput

type PublishAndLinkInput struct {
	ProjectID      toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	PackageName    string               `json:"package_name" jsonschema:"Package name (alphanumeric, dots, dashes, underscores),required"`
	PackageVersion string               `json:"package_version" jsonschema:"Package version (e.g. 1.0.0),required"`
	FileName       string               `json:"file_name" jsonschema:"Name of the file within the package,required"`
	FilePath       string               `json:"file_path,omitempty" jsonschema:"Absolute path to a local file. Alternative to content_base64."`
	ContentBase64  string               `json:"content_base64,omitempty" jsonschema:"Base64-encoded file content. Alternative to file_path."`
	Status         string               `json:"status,omitempty" jsonschema:"Package status: default or hidden"`
	TagName        string               `json:"tag_name" jsonschema:"Tag name of the release to link the package file to,required"`
	LinkName       string               `` /* 170-byte string literal not displayed */
	LinkType       string               `json:"link_type,omitempty" jsonschema:"Type of the release link: package, runbook, image, or other. Defaults to package."`
}

PublishAndLinkInput defines input for publishing a file to the Generic Package Registry and creating a release asset link in one step.

type PublishAndLinkOutput

type PublishAndLinkOutput struct {
	toolutil.HintableOutput
	Package     PublishOutput       `json:"package"`
	ReleaseLink releaselinks.Output `json:"release_link"`
}

PublishAndLinkOutput contains the results of both the publish and release link creation operations.

PublishAndLink publishes a file to the Generic Package Registry and then creates a release asset link pointing to it. If the publish succeeds but the link creation fails, the package file remains published and the error includes the package details so the caller can retry the link.

type PublishDirInput

type PublishDirInput struct {
	ProjectID      toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	PackageName    string               `json:"package_name" jsonschema:"Package name (alphanumeric, dots, dashes, underscores),required"`
	PackageVersion string               `json:"package_version" jsonschema:"Package version (e.g. 1.0.0),required"`
	DirectoryPath  string               `json:"directory_path" jsonschema:"Absolute path to a local directory whose files will be published,required"`
	IncludePattern string               `` /* 156-byte string literal not displayed */
	Status         string               `json:"status,omitempty" jsonschema:"Package status: default or hidden"`
}

PublishDirInput defines input for publishing all matching files in a directory to the Generic Package Registry.

type PublishDirItem

type PublishDirItem struct {
	FileName      string `json:"file_name"`
	PackageFileID int64  `json:"package_file_id"`
	Size          int64  `json:"size"`
	SHA256        string `json:"sha256"`
	URL           string `json:"url"`
}

PublishDirItem represents a single file published from a directory.

type PublishDirOutput

type PublishDirOutput struct {
	toolutil.HintableOutput
	Published  []PublishDirItem `json:"published"`
	TotalFiles int              `json:"total_files"`
	TotalBytes int64            `json:"total_bytes"`
	Errors     []string         `json:"errors,omitempty"`
}

PublishDirOutput contains the aggregated results of publishing all matching files from a directory.

func PublishDirectory

func PublishDirectory(ctx context.Context, req *mcp.CallToolRequest, client *gitlabclient.Client, input PublishDirInput) (PublishDirOutput, error)

PublishDirectory walks a directory, filters files by an optional glob pattern, and publishes each matching regular file to the Generic Package Registry. It continues on individual file errors and reports them in output.

type PublishInput

type PublishInput struct {
	ProjectID      toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	PackageName    string               `json:"package_name" jsonschema:"Package name (alphanumeric, dots, dashes, underscores),required"`
	PackageVersion string               `json:"package_version" jsonschema:"Package version (e.g. 1.0.0),required"`
	FileName       string               `json:"file_name" jsonschema:"Name of the file within the package,required"`
	FilePath       string               `` /* 161-byte string literal not displayed */
	ContentBase64  string               `json:"content_base64,omitempty" jsonschema:"Base64-encoded file content. Only one should be provided."`
	Status         string               `json:"status,omitempty" jsonschema:"Package status: default or hidden"`
}

PublishInput defines input for publishing a file to the Generic Package Registry.

type PublishOutput

type PublishOutput struct {
	toolutil.HintableOutput
	PackageFileID int64  `json:"package_file_id"`
	PackageID     int64  `json:"package_id"`
	FileName      string `json:"file_name"`
	Size          int64  `json:"size"`
	SHA256        string `json:"sha256"`
	FileMD5       string `json:"file_md5,omitempty"`
	FileSHA1      string `json:"file_sha1,omitempty"`
	FileStore     int64  `json:"file_store"`
	CreatedAt     string `json:"created_at,omitempty"`
	UpdatedAt     string `json:"updated_at,omitempty"`
	URL           string `json:"url"`
}

PublishOutput contains the result of a package file publish operation.

func Publish

Publish publishes a file to the GitLab Generic Package Registry.

Jump to

Keyboard shortcuts

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