Documentation
¶
Overview ¶
markdown.go provides Markdown formatting functions for merge request changes MCP tool output.
Package mrchanges implements retrieval of merge request file diffs, changes, and diff versions from the GitLab API. It exposes typed input/output structs and handler functions for listing changed files, diff versions, and individual diff version details in a merge request.
register.go wires mrchanges MCP tools to the MCP server.
Index ¶
- func FormatDiffVersionGetMarkdown(out DiffVersionOutput) string
- func FormatDiffVersionsListMarkdown(out DiffVersionsListOutput) string
- func FormatOutputMarkdown(out Output) string
- func FormatRawDiffsMarkdown(out RawDiffsOutput) string
- func RegisterTools(server *mcp.Server, client *gitlabclient.Client)
- type DiffVersionCommitOutput
- type DiffVersionGetInput
- type DiffVersionOutput
- type DiffVersionsListInput
- type DiffVersionsListOutput
- type FileDiffOutput
- type GetInput
- type Output
- type RawDiffsInput
- type RawDiffsOutput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatDiffVersionGetMarkdown ¶
func FormatDiffVersionGetMarkdown(out DiffVersionOutput) string
FormatDiffVersionGetMarkdown renders a single diff version detail as markdown.
func FormatDiffVersionsListMarkdown ¶
func FormatDiffVersionsListMarkdown(out DiffVersionsListOutput) string
FormatDiffVersionsListMarkdown renders the list of diff versions as markdown.
func FormatOutputMarkdown ¶
FormatOutputMarkdown renders the list of file changes in a merge request.
func FormatRawDiffsMarkdown ¶
func FormatRawDiffsMarkdown(out RawDiffsOutput) string
FormatRawDiffsMarkdown renders the raw diff output as a fenced code block.
func RegisterTools ¶
func RegisterTools(server *mcp.Server, client *gitlabclient.Client)
RegisterTools registers MR changes and diff version tools on the given MCP server.
Types ¶
type DiffVersionCommitOutput ¶
type DiffVersionCommitOutput struct {
ID string `json:"id"`
ShortID string `json:"short_id"`
Title string `json:"title"`
AuthorName string `json:"author_name"`
CreatedAt string `json:"created_at,omitempty"`
}
DiffVersionCommitOutput represents a commit summary in a diff version.
type DiffVersionGetInput ¶
type DiffVersionGetInput 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"`
VersionID int64 `json:"version_id" jsonschema:"Diff version ID,required"`
Unidiff bool `json:"unidiff,omitempty" jsonschema:"Return diffs in unified diff format (default: false)"`
}
DiffVersionGetInput defines parameters for getting a single MR diff version.
type DiffVersionOutput ¶
type DiffVersionOutput struct {
toolutil.HintableOutput
ID int64 `json:"id"`
HeadCommitSHA string `json:"head_commit_sha,omitempty"`
BaseCommitSHA string `json:"base_commit_sha,omitempty"`
StartCommitSHA string `json:"start_commit_sha,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
MergeRequestID int64 `json:"merge_request_id,omitempty"`
State string `json:"state,omitempty"`
RealSize string `json:"real_size,omitempty"`
Commits []DiffVersionCommitOutput `json:"commits,omitempty"`
Diffs []FileDiffOutput `json:"diffs,omitempty"`
}
DiffVersionOutput represents a single merge request diff version.
func GetDiffVersion ¶
func GetDiffVersion(ctx context.Context, client *gitlabclient.Client, input DiffVersionGetInput) (DiffVersionOutput, error)
GetDiffVersion retrieves a single diff version with its commits and diffs.
type DiffVersionsListInput ¶
type DiffVersionsListInput 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"`
toolutil.PaginationInput
}
DiffVersionsListInput defines parameters for listing MR diff versions.
type DiffVersionsListOutput ¶
type DiffVersionsListOutput struct {
toolutil.HintableOutput
DiffVersions []DiffVersionOutput `json:"diff_versions"`
Pagination toolutil.PaginationOutput `json:"pagination"`
}
DiffVersionsListOutput holds the paginated list of diff versions.
func ListDiffVersions ¶
func ListDiffVersions(ctx context.Context, client *gitlabclient.Client, input DiffVersionsListInput) (DiffVersionsListOutput, error)
ListDiffVersions retrieves the list of diff versions for a merge request.
type FileDiffOutput ¶
type FileDiffOutput struct {
OldPath string `json:"old_path"`
NewPath string `json:"new_path"`
Diff string `json:"diff"`
NewFile bool `json:"new_file"`
RenamedFile bool `json:"renamed_file"`
DeletedFile bool `json:"deleted_file"`
AMode string `json:"a_mode"`
BMode string `json:"b_mode"`
GeneratedFile bool `json:"generated_file"`
}
FileDiffOutput represents a single file diff in a merge request.
func DiffToOutput ¶
func DiffToOutput(d *gl.MergeRequestDiff) FileDiffOutput
DiffToOutput converts a GitLab API gl.MergeRequestDiff to the MCP tool output format, preserving file paths, diff content, and file mode metadata.
type GetInput ¶
type GetInput 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"`
}
GetInput defines parameters for listing changed files in a merge request.
type Output ¶
type Output struct {
toolutil.HintableOutput
MRIID int64 `json:"merge_request_iid"`
Changes []FileDiffOutput `json:"changes"`
TruncatedFiles []string `json:"truncated_files,omitempty"`
}
Output holds the list of file diffs for a merge request.
type RawDiffsInput ¶
type RawDiffsInput 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"`
}
RawDiffsInput defines parameters for retrieving raw diffs of a merge request.
type RawDiffsOutput ¶
type RawDiffsOutput struct {
toolutil.HintableOutput
MRIID int64 `json:"merge_request_iid"`
RawDiff string `json:"raw_diff"`
}
RawDiffsOutput holds the raw unified-diff output for a merge request.
func RawDiffs ¶
func RawDiffs(ctx context.Context, client *gitlabclient.Client, input RawDiffsInput) (RawDiffsOutput, error)
RawDiffs retrieves the raw diff content for a merge request. The response is a plain-text unified diff that can be applied with git-apply(1).