Documentation
¶
Overview ¶
Package projectimportexport implements MCP tools for GitLab project import and export operations.
The package wraps the GitLab Project import/export API:
Index ¶
- func ActionSpecs(client *gitlabclient.Client) []toolutil.ActionSpec
- func FormatExportDownloadMarkdown(out ExportDownloadOutput) *mcp.CallToolResult
- func FormatExportStatusMarkdown(out ExportStatusOutput) *mcp.CallToolResult
- func FormatImportStatusMarkdown(out ImportStatusOutput) *mcp.CallToolResult
- func FormatScheduleExportMarkdown(out ScheduleExportOutput) *mcp.CallToolResult
- type ExportDownloadInput
- type ExportDownloadOutput
- type ExportStatusInput
- type ExportStatusOutput
- type FailedRelationOutput
- type GetImportStatusInput
- type ImportFromFileInput
- type ImportOverrideParamsInput
- type ImportStatusOutput
- type ScheduleExportInput
- type ScheduleExportOutput
- type ScheduleExportUploadInput
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 import and export actions.
func FormatExportDownloadMarkdown ¶
func FormatExportDownloadMarkdown(out ExportDownloadOutput) *mcp.CallToolResult
FormatExportDownloadMarkdown renders the one line a downloaded archive answers with: the size, and where the bytes are.
func FormatExportStatusMarkdown ¶
func FormatExportStatusMarkdown(out ExportStatusOutput) *mcp.CallToolResult
FormatExportStatusMarkdown renders an export's status as a card: the project's identity, the status GitLab reports and the two addresses the archive is reachable at when the export has finished.
func FormatImportStatusMarkdown ¶
func FormatImportStatusMarkdown(out ImportStatusOutput) *mcp.CallToolResult
FormatImportStatusMarkdown renders an import's status as a card, with GitLab's own failure text when the import failed.
func FormatScheduleExportMarkdown ¶
func FormatScheduleExportMarkdown(out ScheduleExportOutput) *mcp.CallToolResult
FormatScheduleExportMarkdown renders the one sentence a scheduled export answers with. The sentence is this package's own literal; the cell escaper is idempotent over it and is what keeps the line one line whatever a later GitLab-authored message holds.
Types ¶
type ExportDownloadInput ¶
type ExportDownloadInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
}
ExportDownloadInput is the input for downloading a project export.
type ExportDownloadOutput ¶
type ExportDownloadOutput struct {
toolutil.HintableOutput
ContentBase64 string `json:"content_base64"`
SizeBytes int `json:"size_bytes"`
}
ExportDownloadOutput is the output for downloading a project export.
func ExportDownload ¶
func ExportDownload(ctx context.Context, client *gitlabclient.Client, input ExportDownloadInput) (ExportDownloadOutput, error)
ExportDownload downloads the finished export archive of a project as base64.
client-go reads the whole body before it returns it, so the shared download ceiling is applied where the body is read, as a response limit on this one request: an archive over it stops the read there instead of being buffered up to the client's own ceiling and then refused, and is answered with the way out rather than returned or truncated.
type ExportStatusInput ¶
type ExportStatusInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
}
ExportStatusInput is the input for getting export status.
type ExportStatusOutput ¶
type ExportStatusOutput struct {
toolutil.HintableOutput
ID int64 `json:"id"`
Description string `json:"description"`
Name string `json:"name"`
NameWithNamespace string `json:"name_with_namespace"`
Path string `json:"path"`
PathWithNamespace string `json:"path_with_namespace"`
CreatedAt string `json:"created_at,omitempty"`
ExportStatus string `json:"export_status"`
APIURL string `json:"api_url,omitempty"`
WebURL string `json:"web_url,omitempty"`
}
ExportStatusOutput is the output for getting export status.
func GetExportStatus ¶
func GetExportStatus(ctx context.Context, client *gitlabclient.Client, input ExportStatusInput) (ExportStatusOutput, error)
GetExportStatus returns the export status of a project.
type FailedRelationOutput ¶ added in v3.1.0
type FailedRelationOutput struct {
ID int64 `json:"id"`
CreatedAt string `json:"created_at,omitempty"`
ExceptionClass string `json:"exception_class"`
Source string `json:"source"`
RelationName string `json:"relation_name"`
LineNumber int64 `json:"line_number"`
}
FailedRelationOutput is one relation an import could not bring over, as lib/api/entities/project_import_failed_relation.rb renders it: when and where it failed, the exception's class, and the relation and line it was reading. The entity also exposes exception_message through a block that returns nil whatever the relation, so it is never filled and is not published.
type GetImportStatusInput ¶
type GetImportStatusInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
}
GetImportStatusInput is the input for getting import status.
type ImportFromFileInput ¶
type ImportFromFileInput struct {
FilePath string `` /* 289-byte string literal not displayed */
ContentBase64 string `` /* 143-byte string literal not displayed */
Namespace string `json:"namespace,omitempty" jsonschema:"Namespace to import the project into (user or group path)"`
Name string `json:"name,omitempty" jsonschema:"Name for the imported project"`
Path string `json:"path,omitempty" jsonschema:"URL path for the imported project,required"`
Overwrite *bool `json:"overwrite,omitempty" jsonschema:"If true, overwrite an existing project with the same path"`
OverrideParams *ImportOverrideParamsInput `` /* 179-byte string literal not displayed */
}
ImportFromFileInput is the input for importing a project from an archive file. Fields mirror gl.ImportFileOptions 1:1 (override_params is exposed as a curated nested struct over gl.CreateProjectOptions).
type ImportOverrideParamsInput ¶
type ImportOverrideParamsInput struct {
Name string `json:"name,omitempty" jsonschema:"Override the imported project's name"`
Path string `json:"path,omitempty" jsonschema:"Override the imported project's URL path (slug)"`
NamespaceID *int64 `json:"namespace_id,omitempty" jsonschema:"Override the namespace ID the imported project is created in"`
Description string `json:"description,omitempty" jsonschema:"Override the imported project's description"`
Visibility string `json:"visibility,omitempty" jsonschema:"Override visibility level (private, internal, public)"`
DefaultBranch string `json:"default_branch,omitempty" jsonschema:"Override the default branch name"`
MergeMethod string `json:"merge_method,omitempty" jsonschema:"Override merge method (merge, rebase_merge, ff)"`
RequestAccessEnabled *bool `json:"request_access_enabled,omitempty" jsonschema:"Override whether users can request access"`
LFSEnabled *bool `json:"lfs_enabled,omitempty" jsonschema:"Override Git LFS enablement"`
IssuesAccessLevel string `json:"issues_access_level,omitempty" jsonschema:"Override issues access level (disabled, private, enabled)"`
MergeRequestsAccessLevel string `json:"merge_requests_access_level,omitempty" jsonschema:"Override merge requests access level (disabled, private, enabled)"`
WikiAccessLevel string `json:"wiki_access_level,omitempty" jsonschema:"Override wiki access level (disabled, private, enabled)"`
BuildsAccessLevel string `json:"builds_access_level,omitempty" jsonschema:"Override CI/CD builds access level (disabled, private, enabled)"`
SnippetsAccessLevel string `json:"snippets_access_level,omitempty" jsonschema:"Override snippets access level (disabled, private, enabled)"`
ContainerRegistryAccessLevel string `` /* 131-byte string literal not displayed */
}
ImportOverrideParamsInput mirrors the project-create attributes that GitLab accepts under the import-from-file `override_params` field. It maps to gl.CreateProjectOptions (the type of gl.ImportFileOptions.OverrideParams).
GitLab documents override_params as accepting the full set of create-project attributes (the entire gl.CreateProjectOptions set, ~79 fields). Exposing all of them as flat MCP input fields would bloat this tool's schema and duplicate the dedicated gitlab_project create/update tools, so this struct deliberately surfaces only the commonly-overridden subset a user realistically changes during an import (identity, visibility, default branch, merge method, access-request/LFS/shared-runner toggles, and the high-traffic feature access levels). Full project configuration remains available via the dedicated gitlab_project create/update tools. Only set fields are forwarded.
type ImportStatusOutput ¶
type ImportStatusOutput struct {
toolutil.HintableOutput
ID int64 `json:"id"`
Description string `json:"description"`
Name string `json:"name"`
NameWithNamespace string `json:"name_with_namespace"`
Path string `json:"path"`
PathWithNamespace string `json:"path_with_namespace"`
CreatedAt string `json:"created_at,omitempty"`
ImportStatus string `json:"import_status"`
ImportType string `json:"import_type,omitempty"`
CorrelationID string `json:"correlation_id,omitempty"`
ImportError string `json:"import_error,omitempty"`
FailedRelations []FailedRelationOutput `json:"failed_relations"`
Stats map[string]map[string]int64 `json:"stats,omitempty"`
}
ImportStatusOutput is the output for import operations: every key lib/api/entities/project_import_status.rb sends. FailedRelations are the relations the import could not bring over, at most a hundred, and Stats is what a GitHub import has fetched and imported so far, per object type, which GitLab sends as null for any other import. client-go's ImportStatus models neither, and both are read by the raw decode this package already makes.
func GetImportStatus ¶
func GetImportStatus(ctx context.Context, client *gitlabclient.Client, input GetImportStatusInput) (ImportStatusOutput, error)
GetImportStatus returns the import status of a project.
func ImportFromFile ¶
func ImportFromFile(ctx context.Context, client *gitlabclient.Client, input ImportFromFileInput) (ImportStatusOutput, error)
ImportFromFile imports a project from an export archive.
type ScheduleExportInput ¶
type ScheduleExportInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
Description string `json:"description,omitempty" jsonschema:"Override the project description in the export"`
Upload *ScheduleExportUploadInput `` /* 135-byte string literal not displayed */
// Deprecated: use Upload.URL. Retained as a flat alias for backward
// compatibility; ignored when Upload is set.
UploadURL string `` /* 129-byte string literal not displayed */
// Deprecated: use Upload.HTTPMethod. Retained as a flat alias for backward
// compatibility; ignored when Upload is set.
UploadHTTP string `` /* 132-byte string literal not displayed */
}
ScheduleExportInput is the input for scheduling a project export. Fields mirror gl.ScheduleExportOptions 1:1.
type ScheduleExportOutput ¶
type ScheduleExportOutput struct {
toolutil.HintableOutput
Message string `json:"message"`
}
ScheduleExportOutput is the output for scheduling a project export.
func ScheduleExport ¶
func ScheduleExport(ctx context.Context, client *gitlabclient.Client, input ScheduleExportInput) (ScheduleExportOutput, error)
ScheduleExport schedules an asynchronous project export.
type ScheduleExportUploadInput ¶
type ScheduleExportUploadInput struct {
URL string `json:"url,omitempty" jsonschema:"URL to upload the exported project archive to after export completes"`
HTTPMethod string `json:"http_method,omitempty" jsonschema:"HTTP method to use for the upload (PUT or POST. Default PUT)"`
}
ScheduleExportUploadInput mirrors gl.ScheduleExportUploadOptions: the nested upload destination for a scheduled export. When set, GitLab uploads the generated archive to the given URL instead of (or in addition to) keeping it for download.