mrdiscussions

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: May 2, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package mrdiscussions implements GitLab merge request discussion MCP tools.

It supports creating general and inline discussions, resolving and unresolving discussions, replying to discussion threads, and listing merge request discussions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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

func FormatOutputMarkdown(d Output) string

FormatOutputMarkdown renders a discussion thread with all its notes as Markdown.

func RegisterTools

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

RegisterTools registers all merge request discussion tools on the MCP 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 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."`
}

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 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.

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"`
	toolutil.PaginationInput
}

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 struct {
	toolutil.HintableOutput
	ID          int64  `json:"id"`
	Body        string `json:"body"`
	Author      string `json:"author"`
	CreatedAt   string `json:"created_at"`
	UpdatedAt   string `json:"updated_at,omitempty"`
	Resolved    bool   `json:"resolved"`
	Resolvable  bool   `json:"resolvable"`
	System      bool   `json:"system"`
	Internal    bool   `json:"internal"`
	Type        string `json:"type,omitempty"`
	NoteableID  int64  `json:"notable_id,omitempty"`
	NoteableIID int64  `json:"notable_iid,omitempty"`
	CommitID    string `json:"commit_id,omitempty"`
	ProjectID   int64  `json:"project_id,omitempty"`
}

NoteOutput represents a single note within a discussion.

func NoteToOutput

func NoteToOutput(n *gl.Note) NoteOutput

NoteToOutput converts a GitLab API gl.Note to a NoteOutput, formatting the creation timestamp as RFC 3339.

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 struct {
	toolutil.HintableOutput
	ID             string       `json:"id"`
	IndividualNote bool         `json:"individual_note"`
	Notes          []NoteOutput `json:"notes"`
}

Output represents a discussion thread.

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 Get

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

Get retrieves a single discussion thread from a merge request.

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

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."`
}

UpdateNoteInput defines parameters for updating a discussion note.

Jump to

Keyboard shortcuts

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