mrdraftnotes

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package mrdraftnotes implements MCP tools for GitLab merge request draft note operations.

The package wraps GitLab GraphQL draft note fields:

Index

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 draft note actions. The list, get, create, update, delete, publish, and publish_all routes are projected into the dynamic, meta, individual, and audit surfaces by the action catalog (ADR-0004).

func Delete

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

Delete deletes a draft note from a merge request.

func FormatListMarkdown

func FormatListMarkdown(out ListOutput) string

FormatListMarkdown renders a paginated list of draft notes as a Markdown table.

func FormatOutputMarkdown

func FormatOutputMarkdown(out Output) string

FormatOutputMarkdown renders a single draft note as Markdown.

func Publish

func Publish(ctx context.Context, client *gitlabclient.Client, input PublishInput) error

Publish publishes a single draft note, making it visible to all.

func PublishAll

func PublishAll(ctx context.Context, client *gitlabclient.Client, input PublishAllInput) error

PublishAll publishes all pending draft notes on a merge request.

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 internal ID,required"`
	Note                  string               `json:"note"                              jsonschema:"Note body text (Markdown),required"`
	CommitID              string               `json:"commit_id,omitempty"               jsonschema:"SHA of the commit to comment on"`
	InReplyToDiscussionID string               `json:"in_reply_to_discussion_id,omitempty" jsonschema:"Discussion ID to reply to"`
	ResolveDiscussion     *bool                `json:"resolve_discussion,omitempty"      jsonschema:"Resolve the discussion when published"`
	Position              *DiffPosition        `` /* 136-byte string literal not displayed */
}

CreateInput defines parameters for creating a draft note.

type DeleteInput

type DeleteInput 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"`
	NoteID    int64                `json:"note_id"    jsonschema:"Draft note ID,required"`
}

DeleteInput defines parameters for deleting a draft note.

type DiffLinePosition added in v2.3.0

type DiffLinePosition struct {
	LineCode string `json:"line_code,omitempty" jsonschema:"Line code identifying the diff line (sha_oldline_newline)."`
	Type     string `json:"type,omitempty"      jsonschema:"Line type: 'new', 'old', or empty for unchanged context lines."`
	OldLine  int    `json:"old_line,omitempty"  jsonschema:"Line number in the old file for this range boundary."`
	NewLine  int    `json:"new_line,omitempty"  jsonschema:"Line number in the new file for this range boundary."`
}

DiffLinePosition describes a single line position within a line range. It mirrors the GitLab client-go LinePositionOptions.

type DiffLineRange added in v2.3.0

type DiffLineRange struct {
	Start *DiffLinePosition `json:"start,omitempty" jsonschema:"Start line position of the range."`
	End   *DiffLinePosition `json:"end,omitempty"   jsonschema:"End line position of the range."`
}

DiffLineRange describes the start and end line positions of a multi-line inline draft note. It mirrors the GitLab client-go LineRangeOptions.

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"`
	PositionType string         `json:"position_type,omitempty" jsonschema:"Position type: 'text' for code diffs (default) or 'image' for image diffs."`
	OldLine      int            `` /* 199-byte string literal not displayed */
	NewLine      int            `` /* 199-byte string literal not displayed */
	LineRange    *DiffLineRange `` /* 142-byte string literal not displayed */
	Width        int            `json:"width,omitempty" jsonschema:"Image width in pixels. Only for position_type 'image'."`
	Height       int            `json:"height,omitempty" jsonschema:"Image height in pixels. Only for position_type 'image'."`
	X            float64        `json:"x,omitempty" jsonschema:"X coordinate of the comment on an image diff. Only for position_type 'image'."`
	Y            float64        `json:"y,omitempty" jsonschema:"Y coordinate of the comment on an image diff. Only for position_type 'image'."`
}

DiffPosition defines the location of an inline diff comment on a merge request. Use this to place a draft note on a specific line in the diff. It mirrors the GitLab client-go PositionOptions (discussions.go) one-to-one.

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"`
	NoteID    int64                `json:"note_id"    jsonschema:"Draft note ID,required"`
}

GetInput defines parameters for retrieving a single draft note.

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 internal ID,required"`
	OrderBy   string               `json:"order_by,omitempty" jsonschema:"Order by: id (default)"`
	Sort      string               `json:"sort,omitempty"     jsonschema:"Sort: asc or desc (default)"`
	toolutil.PaginationInput
	toolutil.KeysetPaginationInput
}

ListInput defines parameters for listing draft notes in a merge request.

type ListOutput

type ListOutput struct {
	toolutil.HintableOutput
	DraftNotes []Output                  `json:"draft_notes"`
	Pagination toolutil.PaginationOutput `json:"pagination"`
}

ListOutput holds a paginated list of draft notes.

func List

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

List retrieves all draft notes for a merge request.

type Output

type Output struct {
	toolutil.HintableOutput
	ID                int64           `json:"id"`
	AuthorID          int64           `json:"author_id"`
	MergeRequestID    int64           `json:"merge_request_id"`
	Note              string          `json:"note"`
	CommitID          string          `json:"commit_id,omitempty"`
	LineCode          string          `json:"line_code,omitempty"`
	DiscussionID      string          `json:"discussion_id,omitempty"`
	ResolveDiscussion bool            `json:"resolve_discussion"`
	Position          *PositionOutput `json:"position,omitempty"`
}

Output represents a single draft note.

func Create

func Create(ctx context.Context, client *gitlabclient.Client, input CreateInput) (Output, error)

Create creates a new draft note on a merge request.

func Get

func Get(ctx context.Context, client *gitlabclient.Client, input GetInput) (Output, error)

Get retrieves a single draft note by ID.

func ToOutput

func ToOutput(d *gl.DraftNote) Output

ToOutput converts a client-go DraftNote to the MCP output type.

func Update

func Update(ctx context.Context, client *gitlabclient.Client, input UpdateInput) (Output, error)

Update updates an existing draft note.

type PositionOutput

type PositionOutput struct {
	BaseSHA      string                    `json:"base_sha"`
	StartSHA     string                    `json:"start_sha"`
	HeadSHA      string                    `json:"head_sha"`
	PositionType string                    `json:"position_type,omitempty"`
	NewPath      string                    `json:"new_path,omitempty"`
	OldPath      string                    `json:"old_path,omitempty"`
	NewLine      int64                     `json:"new_line,omitempty"`
	OldLine      int64                     `json:"old_line,omitempty"`
	LineRange    *toolutil.LineRangeOutput `json:"line_range,omitempty"`
}

PositionOutput represents the diff position of an inline draft note. It mirrors the GitLab client-go NotePosition (notes.go) one-to-one.

type PublishAllInput

type PublishAllInput 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"`
}

PublishAllInput defines parameters for publishing all draft notes.

type PublishInput

type PublishInput 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"`
	NoteID    int64                `json:"note_id"    jsonschema:"Draft note ID,required"`
}

PublishInput defines parameters for publishing a single draft note.

type UpdateInput

type UpdateInput 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"`
	NoteID    int64                `json:"note_id"    jsonschema:"Draft note ID,required"`
	Note      string               `json:"note,omitempty" jsonschema:"Updated note body text (Markdown)"`
	Position  *DiffPosition        `json:"position,omitempty" jsonschema:"Updated diff position for inline comments"`
}

UpdateInput defines parameters for updating a draft note.

Jump to

Keyboard shortcuts

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