Documentation
¶
Overview ¶
Package repository implements MCP tool handlers for GitLab repository operations including tree listing, branch/tag/commit comparison, contributors, merge base, blob retrieval, changelog generation, and archive URLs. It wraps the Repositories service from client-go v2.
Index ¶
- func FormatAddChangelogMarkdown(out AddChangelogOutput) string
- func FormatArchiveMarkdown(out ArchiveOutput) string
- func FormatBlobMarkdown(out BlobOutput) string
- func FormatChangelogDataMarkdown(out ChangelogDataOutput) string
- func FormatCompareMarkdown(out CompareOutput) string
- func FormatContributorsMarkdown(out ContributorsOutput) string
- func FormatRawBlobContentMarkdown(out RawBlobContentOutput) string
- func FormatTreeMarkdown(out TreeOutput) string
- func MergeBase(ctx context.Context, client *gitlabclient.Client, input MergeBaseInput) (commits.Output, error)
- func RegisterTools(server *mcp.Server, client *gitlabclient.Client)
- type AddChangelogInput
- type AddChangelogOutput
- type ArchiveInput
- type ArchiveOutput
- type BlobInput
- type BlobOutput
- type ChangelogDataOutput
- type CompareInput
- type CompareOutput
- type ContributorOutput
- type ContributorsInput
- type ContributorsOutput
- type DiffOutput
- type GenerateChangelogInput
- type MergeBaseInput
- type RawBlobContentOutput
- type TreeInput
- type TreeNodeOutput
- type TreeOutput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatAddChangelogMarkdown ¶
func FormatAddChangelogMarkdown(out AddChangelogOutput) string
FormatAddChangelogMarkdown renders changelog addition confirmation.
func FormatArchiveMarkdown ¶
func FormatArchiveMarkdown(out ArchiveOutput) string
FormatArchiveMarkdown renders archive download info.
func FormatBlobMarkdown ¶
func FormatBlobMarkdown(out BlobOutput) string
FormatBlobMarkdown renders blob metadata.
func FormatChangelogDataMarkdown ¶
func FormatChangelogDataMarkdown(out ChangelogDataOutput) string
FormatChangelogDataMarkdown renders generated changelog notes.
func FormatCompareMarkdown ¶
func FormatCompareMarkdown(out CompareOutput) string
FormatCompareMarkdown renders a repository comparison result.
func FormatContributorsMarkdown ¶
func FormatContributorsMarkdown(out ContributorsOutput) string
FormatContributorsMarkdown renders a list of contributors.
func FormatRawBlobContentMarkdown ¶
func FormatRawBlobContentMarkdown(out RawBlobContentOutput) string
FormatRawBlobContentMarkdown renders raw blob content.
func FormatTreeMarkdown ¶
func FormatTreeMarkdown(out TreeOutput) string
FormatTreeMarkdown renders a paginated repository tree as a Markdown table.
func MergeBase ¶
func MergeBase(ctx context.Context, client *gitlabclient.Client, input MergeBaseInput) (commits.Output, error)
MergeBase finds the common ancestor (merge base) of two or more refs.
func RegisterTools ¶
func RegisterTools(server *mcp.Server, client *gitlabclient.Client)
RegisterTools registers repository tree and compare tools on the MCP server.
Types ¶
type AddChangelogInput ¶
type AddChangelogInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
Version string `json:"version" jsonschema:"Version string for the changelog,required"`
Branch string `json:"branch,omitempty" jsonschema:"Branch to commit the changelog to (default: default branch)"`
ConfigFile string `json:"config_file,omitempty" jsonschema:"Path to the changelog config file in the project"`
File string `json:"file,omitempty" jsonschema:"Path to the changelog file (default: CHANGELOG.md)"`
From string `json:"from,omitempty" jsonschema:"Start of the range (commit SHA or tag)"`
To string `json:"to,omitempty" jsonschema:"End of the range (commit SHA or tag, default: HEAD)"`
Message string `json:"message,omitempty" jsonschema:"Commit message for the changelog update"`
Trailer string `json:"trailer,omitempty" jsonschema:"Git trailer to use for changelog generation (default: Changelog)"`
}
AddChangelogInput defines parameters for adding changelog data to a changelog file.
type AddChangelogOutput ¶
type AddChangelogOutput struct {
toolutil.HintableOutput
Success bool `json:"success"`
Version string `json:"version"`
}
AddChangelogOutput confirms the changelog was added.
func AddChangelog ¶
func AddChangelog(ctx context.Context, client *gitlabclient.Client, input AddChangelogInput) (AddChangelogOutput, error)
AddChangelog adds changelog data to a changelog file by creating a commit.
type ArchiveInput ¶
type ArchiveInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
SHA string `json:"sha,omitempty" jsonschema:"Commit SHA, branch, or tag to archive (default: default branch)"`
Format string `json:"format,omitempty" jsonschema:"Archive format: tar.gz, tar.bz2, tbz, tbz2, tb2, bz2, tar, zip (default: tar.gz)"`
Path string `json:"path,omitempty" jsonschema:"Subdirectory path to archive (omit for entire repo)"`
}
ArchiveInput defines parameters for getting a repository archive URL.
type ArchiveOutput ¶
type ArchiveOutput struct {
toolutil.HintableOutput
ProjectID string `json:"project_id"`
SHA string `json:"sha,omitempty"`
Format string `json:"format"`
URL string `json:"url"`
}
ArchiveOutput holds archive metadata and download URL.
func Archive ¶
func Archive(ctx context.Context, client *gitlabclient.Client, input ArchiveInput) (ArchiveOutput, error)
Archive generates the download URL for a repository archive. Binary content is not returned; use the URL to download the archive.
type BlobInput ¶
type BlobInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
SHA string `json:"sha" jsonschema:"Blob SHA (from tree listing or commit diff),required"`
}
BlobInput defines parameters for retrieving a git blob by SHA.
type BlobOutput ¶
type BlobOutput struct {
toolutil.HintableOutput
SHA string `json:"sha"`
Size int `json:"size"`
Content string `json:"content"`
ContentCategory string `json:"content_category"`
// ImageData holds raw image bytes for ImageContent responses (not serialized).
ImageData []byte `json:"-"`
// ImageMIMEType holds the MIME type for image files (not serialized).
ImageMIMEType string `json:"-"`
}
BlobOutput holds the content of a git blob.
func Blob ¶
func Blob(ctx context.Context, client *gitlabclient.Client, input BlobInput) (BlobOutput, error)
Blob retrieves a git blob by SHA. For text content, returns decoded text. For images, returns ImageContent (visible to multimodal LLMs). For other binary formats, returns metadata only (no content).
type ChangelogDataOutput ¶
type ChangelogDataOutput struct {
toolutil.HintableOutput
Notes string `json:"notes"`
}
ChangelogDataOutput holds the generated changelog notes.
func GenerateChangelogData ¶
func GenerateChangelogData(ctx context.Context, client *gitlabclient.Client, input GenerateChangelogInput) (ChangelogDataOutput, error)
GenerateChangelogData generates changelog notes without committing.
type CompareInput ¶
type CompareInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
From string `json:"from" jsonschema:"Branch name, tag, or commit SHA to compare from,required"`
To string `json:"to" jsonschema:"Branch name, tag, or commit SHA to compare to,required"`
Straight bool `json:"straight,omitempty" jsonschema:"Use straight comparison (from..to) instead of merge-base (from...to)"`
Unidiff bool `json:"unidiff,omitempty" jsonschema:"Return diffs in unified diff format"`
}
CompareInput defines parameters for comparing branches, tags, or commits.
type CompareOutput ¶
type CompareOutput struct {
toolutil.HintableOutput
Commits []commits.Output `json:"commits"`
Diffs []DiffOutput `json:"diffs"`
CompareTimeout bool `json:"compare_timeout"`
CompareSameRef bool `json:"compare_same_ref"`
WebURL string `json:"web_url"`
}
CompareOutput holds the comparison result.
func Compare ¶
func Compare(ctx context.Context, client *gitlabclient.Client, input CompareInput) (CompareOutput, error)
Compare compares two branches, tags, or commits in a project.
type ContributorOutput ¶
type ContributorOutput struct {
Name string `json:"name"`
Email string `json:"email"`
Commits int64 `json:"commits"`
Additions int64 `json:"additions"`
Deletions int64 `json:"deletions"`
}
ContributorOutput represents a repository contributor.
type ContributorsInput ¶
type ContributorsInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
OrderBy string `json:"order_by,omitempty" jsonschema:"Order by: name, email, or commits (default: commits)"`
Sort string `json:"sort,omitempty" jsonschema:"Sort direction: asc or desc (default: asc)"`
toolutil.PaginationInput
}
ContributorsInput defines parameters for listing repository contributors.
type ContributorsOutput ¶
type ContributorsOutput struct {
toolutil.HintableOutput
Contributors []ContributorOutput `json:"contributors"`
Pagination toolutil.PaginationOutput `json:"pagination"`
}
ContributorsOutput holds a paginated list of contributors.
func Contributors ¶
func Contributors(ctx context.Context, client *gitlabclient.Client, input ContributorsInput) (ContributorsOutput, error)
Contributors lists the repository contributors with commit/addition/deletion counts.
type DiffOutput ¶
type DiffOutput = toolutil.DiffOutput
DiffOutput is an alias for the shared diff type in toolutil.
type GenerateChangelogInput ¶
type GenerateChangelogInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
Version string `json:"version" jsonschema:"Version string,required"`
ConfigFile string `json:"config_file,omitempty" jsonschema:"Path to the changelog config file"`
From string `json:"from,omitempty" jsonschema:"Start of the range (commit SHA or tag)"`
To string `json:"to,omitempty" jsonschema:"End of the range (commit SHA or tag, default: HEAD)"`
Trailer string `json:"trailer,omitempty" jsonschema:"Git trailer to use (default: Changelog)"`
}
GenerateChangelogInput defines parameters for generating changelog data.
type MergeBaseInput ¶
type MergeBaseInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
Refs []string `json:"refs" jsonschema:"Two or more branch names, tags, or commit SHAs to find the merge base of,required"`
}
MergeBaseInput defines parameters for finding the merge base of two or more refs.
type RawBlobContentOutput ¶
type RawBlobContentOutput struct {
toolutil.HintableOutput
SHA string `json:"sha"`
Size int `json:"size"`
Content string `json:"content"`
ContentCategory string `json:"content_category"`
// ImageData holds raw image bytes for ImageContent responses (not serialized).
ImageData []byte `json:"-"`
// ImageMIMEType holds the MIME type for image files (not serialized).
ImageMIMEType string `json:"-"`
}
RawBlobContentOutput holds the content of a git blob.
func RawBlobContent ¶
func RawBlobContent(ctx context.Context, client *gitlabclient.Client, input BlobInput) (RawBlobContentOutput, error)
RawBlobContent retrieves the raw content of a git blob by SHA. For text content, returns decoded text. For images, returns ImageContent. For other binary formats, returns metadata only.
type TreeInput ¶
type TreeInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
Path string `json:"path,omitempty" jsonschema:"Path inside the repository to list (default: root)"`
Ref string `json:"ref,omitempty" jsonschema:"Branch name, tag, or commit SHA (default: default branch)"`
Recursive bool `json:"recursive,omitempty" jsonschema:"List files recursively through subdirectories"`
toolutil.PaginationInput
}
TreeInput defines parameters for listing files in a repository tree.
type TreeNodeOutput ¶
type TreeNodeOutput struct {
ID string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
Path string `json:"path"`
Mode string `json:"mode"`
}
TreeNodeOutput represents a file or directory in the repository tree.
type TreeOutput ¶
type TreeOutput struct {
toolutil.HintableOutput
Tree []TreeNodeOutput `json:"tree"`
Pagination toolutil.PaginationOutput `json:"pagination"`
}
TreeOutput holds a paginated list of tree nodes.
func Tree ¶
func Tree(ctx context.Context, client *gitlabclient.Client, input TreeInput) (TreeOutput, error)
Tree retrieves the file/directory listing for a repository path.