Help us shape the future of Go! Take the 2026 Go Developer Survey

uploads

package
v3.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package uploads implements MCP tools for GitLab project upload operations.

The package wraps the GitLab Project uploads API:

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 project upload actions.

func Delete

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

Delete deletes a markdown upload from a GitLab project.

func DeleteBySecret

func DeleteBySecret(ctx context.Context, client *gitlabclient.Client, input DeleteBySecretInput) error

DeleteBySecret deletes a markdown upload from a GitLab project by its secret and filename. This is the alternative to deleting by numeric upload ID and matches the /uploads/:secret/:filename reference embedded in an upload's Markdown link.

func FormatListMarkdown

func FormatListMarkdown(o ListOutput) string

FormatListMarkdown renders a list of project markdown uploads as Markdown.

func FormatUploadMarkdown

func FormatUploadMarkdown(u UploadOutput) string

FormatUploadMarkdown renders an uploaded file result as the card of one object.

func UploadToolResult

func UploadToolResult(u UploadOutput) *mcp.CallToolResult

UploadToolResult builds a CallToolResult for upload operations. For image files the card carries a Markdown image embed with the full URL so capable MCP clients can render the image inline. Non-image uploads return text only.

Two things the hand-built literal this replaced got wrong. The embed was appended after the card, which put it below the guidance section and left that section neither leading nor trailing, the one position toolutil.ExtractHints refuses to read, so the upload's hint never reached next_steps; it is now written between the rows and the guidance. And the result was assembled as a literal with no annotations and no normalization, which skipped the control-byte strip every other response passes through; it now goes through toolutil.ToolResultAnnotated, carrying toolutil.ContentUser when an image embed is present, since that block is for a person to look at, and the assistant default otherwise.

Types

type DeleteBySecretInput

type DeleteBySecretInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	Secret    string               `json:"secret" jsonschema:"32-character upload secret from the upload URL (/uploads/<secret>/<filename>),required"`
	Filename  string               `json:"filename" jsonschema:"Filename of the upload as it appears in the upload URL,required"`
}

DeleteBySecretInput defines input for deleting a project markdown upload identified by its 32-character secret and filename, as returned in an upload's url/markdown reference (/uploads/:secret/:filename).

type DeleteInput

type DeleteInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	UploadID  int64                `json:"upload_id" jsonschema:"ID of the upload to delete,required"`
}

DeleteInput defines input for deleting a project markdown upload.

type ListInput

type ListInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	OrderBy   string               `json:"order_by,omitempty" jsonschema:"For keyset pagination, the column to order results by"`
	Sort      string               `json:"sort,omitempty"     jsonschema:"Sort order for keyset pagination: 'asc' or 'desc'"`
	toolutil.PaginationInput
	toolutil.KeysetPaginationInput
}

ListInput defines input for listing a project's markdown uploads. It mirrors the offset and keyset pagination supported by the GitLab uploads list endpoint (page/per_page plus order_by/sort/page_token for keyset traversal).

type ListItem

type ListItem struct {
	ID         int64             `json:"id"`
	Size       int64             `json:"size"`
	Filename   string            `json:"filename"`
	CreatedAt  string            `json:"created_at,omitempty"`
	UploadedBy *UploadedByOutput `json:"uploaded_by,omitempty"`
}

ListItem represents a single markdown upload entry. It mirrors the canonical keys of gl.MarkdownUpload (id, size, filename, created_at, uploaded_by).

type ListOutput

type ListOutput struct {
	toolutil.HintableOutput
	Uploads    []ListItem                `json:"uploads"`
	Pagination toolutil.PaginationOutput `json:"pagination"`
}

ListOutput contains the list of markdown uploads for a project.

func List

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

List lists all markdown uploads for a GitLab project.

type UploadInput

type UploadInput struct {
	ProjectID     toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	Filename      string               `json:"filename" jsonschema:"Name of the file to upload (e.g. screenshot.png),required"`
	FilePath      string               `` /* 227-byte string literal not displayed */
	ContentBase64 string               `` /* 133-byte string literal not displayed */
}

UploadInput defines input for uploading a file to a GitLab project. Exactly one of FilePath or ContentBase64 must be provided.

type UploadOutput

type UploadOutput struct {
	toolutil.HintableOutput
	ID       int64  `json:"id,omitempty"`
	Alt      string `json:"alt"`
	URL      string `json:"url"`
	FullPath string `json:"full_path"`
	Markdown string `json:"markdown"`
	FullURL  string `json:"full_url,omitempty"`
}

UploadOutput contains the result of a file upload. Fields mirror the documented create-upload response (id, alt, url, full_path, markdown) per doc/api/project_markdown_uploads.md. ID is omitempty because GitLab only returns it from 17.3 onward (MR 161160); older instances omit it.

func Upload

func Upload(ctx context.Context, req *mcp.CallToolRequest, client *gitlabclient.Client, input UploadInput) (UploadOutput, error)

Upload uploads a file to a GitLab project's markdown uploads area. Accepts either file_path (local file) or content_base64 (base64-encoded string). Returns the upload metadata including the Markdown-embeddable reference or an error if validation, decoding, or upload fails.

type UploadedByOutput

type UploadedByOutput struct {
	ID       int64  `json:"id"`
	Username string `json:"username"`
	Name     string `json:"name"`
}

UploadedByOutput mirrors the short-user representation in a markdown upload's uploaded_by field (gl.MarkdownUpload.UploadedBy, a *gl.User). Per the list response in doc/api/project_markdown_uploads.md, the nested uploaded_by object documents only id, name, and username, so this is trimmed to that documented reference subset even though the SDK *gl.User carries additional fields. Documented reference subset per doc/api/project_markdown_uploads.md

Jump to

Keyboard shortcuts

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