Documentation
¶
Overview ¶
Package mrdiscussions implements MCP tools for GitLab merge request discussion operations.
The package wraps the GitLab Discussions API for merge request threads:
Index ¶
- func ActionSpecs(client *gitlabclient.Client) []toolutil.ActionSpec
- func DeleteNote(ctx context.Context, client *gitlabclient.Client, input DeleteNoteInput) error
- func FormatListMarkdown(out ListOutput) string
- func FormatNoteMarkdown(n NoteOutput) string
- func FormatOutputMarkdown(d Output) string
- type CreateInput
- type DeleteNoteInput
- type DiffLinePositionInput
- type DiffLineRangeInput
- type DiffPosition
- type GetInput
- type ListInput
- type ListOutput
- type NoteOutput
- type Output
- func Create(ctx context.Context, client *gitlabclient.Client, input CreateInput) (Output, error)
- func Get(ctx context.Context, client *gitlabclient.Client, input GetInput) (Output, error)
- func Resolve(ctx context.Context, client *gitlabclient.Client, input ResolveInput) (Output, error)
- func ToOutput(d *gl.Discussion) Output
- type ReplyInput
- type ResolveInput
- type UpdateNoteInput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ActionSpecs ¶
func ActionSpecs(client *gitlabclient.Client) []toolutil.ActionSpec
ActionSpecs returns canonical specs for merge request discussion actions.
func DeleteNote ¶
func DeleteNote(ctx context.Context, client *gitlabclient.Client, input DeleteNoteInput) error
DeleteNote removes a note from a discussion thread.
func FormatListMarkdown ¶
func FormatListMarkdown(out ListOutput) string
FormatListMarkdown renders a list of discussion threads as a Markdown table.
func FormatNoteMarkdown ¶
func FormatNoteMarkdown(n NoteOutput) string
FormatNoteMarkdown renders a single discussion note as Markdown.
func FormatOutputMarkdown ¶
FormatOutputMarkdown renders a discussion thread with all its notes as Markdown.
Types ¶
type CreateInput ¶
type CreateInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
MRIID int64 `json:"merge_request_iid" jsonschema:"Merge request IID (project-scoped, not 'merge_request_id'),required"`
Body string `json:"body" jsonschema:"Discussion body,required"`
Position *DiffPosition `json:"position,omitempty" jsonschema:"Diff position for inline comments. Omit for general MR discussions."`
// CommitID anchors the discussion to a specific commit within the MR.
CommitID string `json:"commit_id,omitempty" jsonschema:"SHA of the commit to anchor the discussion to (optional)."`
// CreatedAt backdates the discussion's first note; requires admin or project/group owner rights (ISO 8601).
CreatedAt string `` /* 148-byte string literal not displayed */
}
CreateInput defines parameters for creating a discussion (inline or general).
type DeleteNoteInput ¶
type DeleteNoteInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
MRIID int64 `json:"merge_request_iid" jsonschema:"Merge request IID (project-scoped, not 'merge_request_id'),required"`
DiscussionID string `json:"discussion_id" jsonschema:"ID of the discussion containing the note,required"`
NoteID int64 `json:"note_id" jsonschema:"ID of the note to delete,required"`
}
DeleteNoteInput defines parameters for deleting a discussion note.
type DiffLinePositionInput ¶ added in v2.3.0
type DiffLinePositionInput struct {
LineCode string `json:"line_code,omitempty" jsonschema:"Line code identifying this line in the diff."`
Type string `json:"type,omitempty" jsonschema:"Line type (new, old, or expanded)."`
OldLine int `json:"old_line,omitempty" jsonschema:"Line number in the old file for this endpoint."`
NewLine int `json:"new_line,omitempty" jsonschema:"Line number in the new file for this endpoint."`
}
DiffLinePositionInput mirrors gl.LinePositionOptions: one endpoint of a multi-line diff comment range.
type DiffLineRangeInput ¶ added in v2.3.0
type DiffLineRangeInput struct {
Start *DiffLinePositionInput `json:"start,omitempty" jsonschema:"Start endpoint of a multi-line diff comment range."`
End *DiffLinePositionInput `json:"end,omitempty" jsonschema:"End endpoint of a multi-line diff comment range."`
}
DiffLineRangeInput mirrors gl.LineRangeOptions: the start/end endpoints of a multi-line diff comment position.
type DiffPosition ¶
type DiffPosition struct {
BaseSHA string `json:"base_sha" jsonschema:"Base commit SHA (merge-base),required"`
StartSHA string `json:"start_sha" jsonschema:"SHA of the first commit in the MR,required"`
HeadSHA string `json:"head_sha" jsonschema:"HEAD commit SHA of the MR source branch,required"`
OldPath string `json:"old_path,omitempty" jsonschema:"File path before the change (for modified/deleted files)"`
NewPath string `json:"new_path" jsonschema:"File path after the change,required"`
OldLine int `` /* 199-byte string literal not displayed */
NewLine int `` /* 199-byte string literal not displayed */
PositionType string `` /* 129-byte string literal not displayed */
LineRange *DiffLineRangeInput `json:"line_range,omitempty" jsonschema:"Start/end line range for a multi-line text diff comment."`
Width int `json:"width,omitempty" jsonschema:"Image width in pixels (position_type=image)."`
Height int `json:"height,omitempty" jsonschema:"Image height in pixels (position_type=image)."`
X float64 `json:"x,omitempty" jsonschema:"X coordinate of the comment on the image (position_type=image)."`
Y float64 `json:"y,omitempty" jsonschema:"Y coordinate of the comment on the image (position_type=image)."`
}
DiffPosition defines the location of an inline diff comment. It mirrors gl.PositionOptions in full, supporting both text (line) positions and image (coordinate) positions.
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 IID (project-scoped, not 'merge_request_id'),required"`
DiscussionID string `json:"discussion_id" jsonschema:"ID of the discussion,required"`
}
GetInput defines parameters for getting a single discussion.
type ListInput ¶
type ListInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
MRIID int64 `json:"merge_request_iid" jsonschema:"Merge request IID (project-scoped, not 'merge_request_id'),required"`
// OrderBy names the column used to order keyset-paginated results.
OrderBy string `json:"order_by,omitempty" jsonschema:"Column to order keyset-paginated results by (e.g. created_at, updated_at)"`
// Sort selects the sort direction for ordered results.
Sort string `json:"sort,omitempty" jsonschema:"Sort direction (asc or desc)"`
toolutil.PaginationInput
toolutil.KeysetPaginationInput
}
ListInput defines parameters for listing discussions.
type ListOutput ¶
type ListOutput struct {
toolutil.HintableOutput
Discussions []Output `json:"discussions"`
Pagination toolutil.PaginationOutput `json:"pagination"`
}
ListOutput holds a list of discussions.
func List ¶
func List(ctx context.Context, client *gitlabclient.Client, input ListInput) (ListOutput, error)
List returns a paginated list of discussion threads for a merge request, including all notes within each thread.
type NoteOutput ¶
type NoteOutput = toolutil.DiscussionThreadNoteOutput
NoteOutput is an alias of toolutil.DiscussionThreadNoteOutput, the rich note shape used within discussion threads, shared with commitdiscussions. Field layout and JSON tags (including UpdatedAt with omitempty and Resolved/Resolvable without omitempty) are defined in toolutil.
func NoteToOutput ¶
func NoteToOutput(n *gl.Note) NoteOutput
NoteToOutput converts a GitLab API gl.Note to a NoteOutput. Per the 1:1 audit policy it surfaces the full author object on the canonical `author` key, additively surfaces the resolved_by / position sub-objects, and mirrors every other gl.Note field. Timestamps are formatted as RFC 3339 strings.
func Reply ¶
func Reply(ctx context.Context, client *gitlabclient.Client, input ReplyInput) (NoteOutput, error)
Reply adds a reply note to an existing discussion thread on a merge request. Returns the newly created note.
func UpdateNote ¶
func UpdateNote(ctx context.Context, client *gitlabclient.Client, input UpdateNoteInput) (NoteOutput, error)
UpdateNote modifies an existing note within a discussion thread.
type Output ¶
type Output = toolutil.DiscussionThreadOutput
Output is an alias of toolutil.DiscussionThreadOutput, the discussion thread shape with full note payloads, shared with commitdiscussions.
func Create ¶
func Create(ctx context.Context, client *gitlabclient.Client, input CreateInput) (Output, error)
Create creates a new discussion on a merge request. When a DiffPosition is provided the discussion is attached as an inline comment on the specified file and line; otherwise a general discussion is created.
func Resolve ¶
func Resolve(ctx context.Context, client *gitlabclient.Client, input ResolveInput) (Output, error)
Resolve resolves or unresolves a discussion thread on a merge request, depending on the Resolved flag in the input.
func ToOutput ¶
func ToOutput(d *gl.Discussion) Output
ToOutput converts a GitLab API gl.Discussion to an Output, including all notes within the thread.
type ReplyInput ¶
type ReplyInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
MRIID int64 `json:"merge_request_iid" jsonschema:"Merge request IID (project-scoped, not 'merge_request_id'),required"`
DiscussionID string `json:"discussion_id" jsonschema:"ID of the discussion to reply to,required"`
Body string `json:"body" jsonschema:"Reply body,required"`
// CreatedAt backdates the reply note; requires admin or project/group owner rights (ISO 8601).
CreatedAt string `` /* 142-byte string literal not displayed */
}
ReplyInput defines parameters for replying to an existing discussion.
type ResolveInput ¶
type ResolveInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
MRIID int64 `json:"merge_request_iid" jsonschema:"Merge request IID (project-scoped, not 'merge_request_id'),required"`
DiscussionID string `json:"discussion_id" jsonschema:"ID of the discussion to resolve,required"`
Resolved bool `json:"resolved" jsonschema:"True to resolve, false to unresolve,required"`
}
ResolveInput defines parameters for resolving/unresolving a discussion.
type UpdateNoteInput ¶
type UpdateNoteInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
MRIID int64 `json:"merge_request_iid" jsonschema:"Merge request IID (project-scoped, not 'merge_request_id'),required"`
DiscussionID string `json:"discussion_id" jsonschema:"ID of the discussion containing the note,required"`
NoteID int64 `json:"note_id" jsonschema:"ID of the note to update,required"`
Body string `json:"body,omitempty" jsonschema:"New body text (Markdown). Leave empty to keep current body."`
Resolved *bool `json:"resolved,omitempty" jsonschema:"Set to true to resolve, false to unresolve. Omit to leave unchanged."`
// CreatedAt overrides the note's creation timestamp; requires admin or project/group owner rights (ISO 8601).
CreatedAt string `` /* 142-byte string literal not displayed */
}
UpdateNoteInput defines parameters for updating a discussion note.