uploads

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package uploads implements GitLab project file upload operations. It supports two input modes: base64-encoded content (for small files via JSON) and file_path (for larger files read directly from the local filesystem). Also provides list and delete operations for project markdown uploads.

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 markdown upload from a GitLab project.

func FormatUploadMarkdown

func FormatUploadMarkdown(u UploadOutput) string

FormatUploadMarkdown renders an uploaded file result as Markdown.

func RegisterTools

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

RegisterTools registers upload-related tools for GitLab projects.

func UploadToolResult

func UploadToolResult(u UploadOutput) *mcp.CallToolResult

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

Types

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

ListInput defines input for listing a project's markdown uploads.

type ListItem

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

ListItem represents a single markdown upload entry.

type ListOutput

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

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

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.

Jump to

Keyboard shortcuts

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