mrdraftnotes

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

markdown.go provides Markdown formatting functions for merge request draft note MCP tool output.

Package mrdraftnotes implements MCP tool handlers for GitLab merge request draft notes (pending review comments). It supports list, get, create, update, delete, publish, and publish-all operations via the MR DraftNotes API.

register.go wires MR draft note tools into the MCP server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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.

func RegisterTools

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

RegisterTools registers all MR draft note MCP tools with the server.

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 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 */
}

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.

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
}

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"`
	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"`
	NewPath  string `json:"new_path,omitempty"`
	OldPath  string `json:"old_path,omitempty"`
	NewLine  int64  `json:"new_line,omitempty"`
	OldLine  int64  `json:"old_line,omitempty"`
}

PositionOutput represents the diff position of an inline draft note.

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