Documentation
¶
Overview ¶
Package snippets implements MCP tools for GitLab personal and project snippets via the SnippetsService and ProjectSnippetsService APIs.
Index ¶
- func Delete(ctx context.Context, client *gitlabclient.Client, input DeleteInput) error
- func FormatContentMarkdown(out ContentOutput) string
- func FormatFileContentMarkdown(out FileContentOutput) string
- func FormatListMarkdown(out ListOutput) string
- func FormatMarkdown(out Output) string
- func ProjectDelete(ctx context.Context, client *gitlabclient.Client, input ProjectDeleteInput) error
- func RegisterMeta(server *mcp.Server, client *gitlabclient.Client)
- func RegisterTools(server *mcp.Server, client *gitlabclient.Client)
- type AuthorOutput
- type ContentInput
- type ContentOutput
- type CreateFileInput
- type CreateInput
- type DeleteInput
- type ExploreInput
- type FileContentInput
- type FileContentOutput
- type FileOutput
- type GetInput
- type ListAllInput
- type ListInput
- type ListOutput
- func Explore(ctx context.Context, client *gitlabclient.Client, input ExploreInput) (ListOutput, error)
- func List(ctx context.Context, client *gitlabclient.Client, input ListInput) (ListOutput, error)
- func ListAll(ctx context.Context, client *gitlabclient.Client, input ListAllInput) (ListOutput, error)
- func ProjectList(ctx context.Context, client *gitlabclient.Client, input ProjectListInput) (ListOutput, error)
- type Output
- func Create(ctx context.Context, client *gitlabclient.Client, input CreateInput) (Output, error)
- func Get(ctx context.Context, client *gitlabclient.Client, input GetInput) (Output, error)
- func ProjectCreate(ctx context.Context, client *gitlabclient.Client, input ProjectCreateInput) (Output, error)
- func ProjectGet(ctx context.Context, client *gitlabclient.Client, input ProjectGetInput) (Output, error)
- func ProjectUpdate(ctx context.Context, client *gitlabclient.Client, input ProjectUpdateInput) (Output, error)
- func Update(ctx context.Context, client *gitlabclient.Client, input UpdateInput) (Output, error)
- type ProjectContentInput
- type ProjectCreateInput
- type ProjectDeleteInput
- type ProjectGetInput
- type ProjectListInput
- type ProjectUpdateInput
- type UpdateFileInput
- type UpdateInput
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 personal snippet.
func FormatContentMarkdown ¶
func FormatContentMarkdown(out ContentOutput) string
FormatContentMarkdown formats snippet content as markdown.
func FormatFileContentMarkdown ¶
func FormatFileContentMarkdown(out FileContentOutput) string
FormatFileContentMarkdown formats snippet file content as markdown.
func FormatListMarkdown ¶
func FormatListMarkdown(out ListOutput) string
FormatListMarkdown formats a list of snippets as markdown.
func FormatMarkdown ¶
FormatMarkdown formats a single snippet as markdown.
func ProjectDelete ¶
func ProjectDelete(ctx context.Context, client *gitlabclient.Client, input ProjectDeleteInput) error
ProjectDelete deletes a project snippet.
func RegisterMeta ¶
func RegisterMeta(server *mcp.Server, client *gitlabclient.Client)
RegisterMeta registers the gitlab_snippet and gitlab_project_snippet meta-tools.
func RegisterTools ¶
func RegisterTools(server *mcp.Server, client *gitlabclient.Client)
RegisterTools registers all snippet MCP tools (personal + project).
Types ¶
type AuthorOutput ¶
type AuthorOutput struct {
ID int64 `json:"id"`
Username string `json:"username"`
Name string `json:"name"`
Email string `json:"email"`
State string `json:"state"`
}
AuthorOutput represents a snippet author.
type ContentInput ¶
type ContentInput struct {
SnippetID int64 `json:"snippet_id" jsonschema:"Snippet ID,required"`
}
ContentInput represents the input for getting snippet content.
type ContentOutput ¶
type ContentOutput struct {
toolutil.HintableOutput
SnippetID int64 `json:"snippet_id"`
Content string `json:"content"`
}
ContentOutput represents raw snippet content.
func Content ¶
func Content(ctx context.Context, client *gitlabclient.Client, input ContentInput) (ContentOutput, error)
Content retrieves the raw content of a snippet.
func ProjectContent ¶
func ProjectContent(ctx context.Context, client *gitlabclient.Client, input ProjectContentInput) (ContentOutput, error)
ProjectContent retrieves the raw content of a project snippet.
type CreateFileInput ¶
type CreateFileInput struct {
FilePath string `json:"file_path" jsonschema:"File path for the snippet file,required"`
Content string `json:"content" jsonschema:"Content of the file,required"`
}
CreateFileInput represents a file to include when creating a snippet.
type CreateInput ¶
type CreateInput struct {
Title string `json:"title" jsonschema:"Snippet title,required"`
FileName string `json:"file_name,omitempty" jsonschema:"File name (single-file snippet, deprecated in favor of files)"`
Description string `json:"description,omitempty" jsonschema:"Snippet description"`
ContentBody string `json:"content,omitempty" jsonschema:"Snippet content (single-file, deprecated in favor of files)"`
Visibility string `json:"visibility,omitempty" jsonschema:"Visibility: private, internal, or public"`
Files []CreateFileInput `json:"files,omitempty" jsonschema:"Files to include in the snippet"`
}
CreateInput represents the input for creating a personal snippet.
type DeleteInput ¶
type DeleteInput struct {
SnippetID int64 `json:"snippet_id" jsonschema:"Snippet ID,required"`
}
DeleteInput represents the input for deleting a personal snippet.
type ExploreInput ¶
type ExploreInput struct {
toolutil.PaginationInput
}
ExploreInput represents the input for exploring public snippets.
type FileContentInput ¶
type FileContentInput struct {
SnippetID int64 `json:"snippet_id" jsonschema:"Snippet ID,required"`
Ref string `json:"ref" jsonschema:"Git ref (branch, tag, or commit SHA),required"`
FileName string `json:"file_name" jsonschema:"File name to retrieve,required"`
}
FileContentInput represents the input for getting a specific snippet file.
type FileContentOutput ¶
type FileContentOutput struct {
toolutil.HintableOutput
SnippetID int64 `json:"snippet_id"`
Ref string `json:"ref"`
FileName string `json:"file_name"`
Content string `json:"content"`
}
FileContentOutput represents raw snippet file content.
func FileContent ¶
func FileContent(ctx context.Context, client *gitlabclient.Client, input FileContentInput) (FileContentOutput, error)
FileContent retrieves the raw content of a specific file in a snippet.
type FileOutput ¶
FileOutput represents a file attached to a snippet.
type GetInput ¶
type GetInput struct {
SnippetID int64 `json:"snippet_id" jsonschema:"Snippet ID,required"`
}
GetInput represents the input for getting a single snippet.
type ListAllInput ¶
type ListAllInput struct {
CreatedAfter string `json:"created_after,omitempty" jsonschema:"Filter snippets created after (ISO 8601)"`
CreatedBefore string `json:"created_before,omitempty" jsonschema:"Filter snippets created before (ISO 8601)"`
toolutil.PaginationInput
}
ListAllInput represents the input for listing all snippets (admin).
type ListInput ¶
type ListInput struct {
toolutil.PaginationInput
}
ListInput represents the input for listing current user's snippets.
type ListOutput ¶
type ListOutput struct {
toolutil.HintableOutput
Snippets []Output `json:"snippets"`
Pagination toolutil.PaginationOutput `json:"pagination"`
}
ListOutput represents a list of snippets with pagination.
func Explore ¶
func Explore(ctx context.Context, client *gitlabclient.Client, input ExploreInput) (ListOutput, error)
Explore lists all public snippets.
func List ¶
func List(ctx context.Context, client *gitlabclient.Client, input ListInput) (ListOutput, error)
List lists all snippets for the current user.
func ListAll ¶
func ListAll(ctx context.Context, client *gitlabclient.Client, input ListAllInput) (ListOutput, error)
ListAll lists all snippets (admin endpoint).
func ProjectList ¶
func ProjectList(ctx context.Context, client *gitlabclient.Client, input ProjectListInput) (ListOutput, error)
ProjectList lists snippets for a project.
type Output ¶
type Output struct {
toolutil.HintableOutput
ID int64 `json:"id"`
Title string `json:"title"`
FileName string `json:"file_name"`
Description string `json:"description"`
Visibility string `json:"visibility"`
Author AuthorOutput `json:"author"`
ProjectID int64 `json:"project_id,omitempty"`
WebURL string `json:"web_url"`
RawURL string `json:"raw_url"`
Files []FileOutput `json:"files,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`
}
Output represents a single snippet.
func Create ¶
func Create(ctx context.Context, client *gitlabclient.Client, input CreateInput) (Output, error)
Create creates a new personal snippet.
func ProjectCreate ¶
func ProjectCreate(ctx context.Context, client *gitlabclient.Client, input ProjectCreateInput) (Output, error)
ProjectCreate creates a new project snippet.
func ProjectGet ¶
func ProjectGet(ctx context.Context, client *gitlabclient.Client, input ProjectGetInput) (Output, error)
ProjectGet retrieves a single project snippet.
func ProjectUpdate ¶
func ProjectUpdate(ctx context.Context, client *gitlabclient.Client, input ProjectUpdateInput) (Output, error)
ProjectUpdate updates an existing project snippet.
func Update ¶
func Update(ctx context.Context, client *gitlabclient.Client, input UpdateInput) (Output, error)
Update updates an existing personal snippet.
type ProjectContentInput ¶
type ProjectContentInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or path,required"`
SnippetID int64 `json:"snippet_id" jsonschema:"Snippet ID,required"`
}
ProjectContentInput represents the input for getting project snippet content.
type ProjectCreateInput ¶
type ProjectCreateInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or path,required"`
Title string `json:"title" jsonschema:"Snippet title,required"`
Description string `json:"description,omitempty" jsonschema:"Snippet description"`
Visibility string `json:"visibility,omitempty" jsonschema:"Visibility: private, internal, or public"`
Files []CreateFileInput `json:"files,omitempty" jsonschema:"Files to include in the snippet"`
FileName string `json:"file_name,omitempty" jsonschema:"File name (single-file, deprecated in favor of files)"`
ContentBody string `json:"content,omitempty" jsonschema:"Content (single-file, deprecated in favor of files)"`
}
ProjectCreateInput represents the input for creating a project snippet.
type ProjectDeleteInput ¶
type ProjectDeleteInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or path,required"`
SnippetID int64 `json:"snippet_id" jsonschema:"Snippet ID,required"`
}
ProjectDeleteInput represents the input for deleting a project snippet.
type ProjectGetInput ¶
type ProjectGetInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or path,required"`
SnippetID int64 `json:"snippet_id" jsonschema:"Snippet ID,required"`
}
ProjectGetInput represents the input for getting a project snippet.
type ProjectListInput ¶
type ProjectListInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or path,required"`
toolutil.PaginationInput
}
ProjectListInput represents the input for listing project snippets.
type ProjectUpdateInput ¶
type ProjectUpdateInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or path,required"`
SnippetID int64 `json:"snippet_id" jsonschema:"Snippet ID,required"`
Title string `json:"title,omitempty" jsonschema:"New title"`
Description string `json:"description,omitempty" jsonschema:"New description"`
Visibility string `json:"visibility,omitempty" jsonschema:"New visibility: private, internal, or public"`
Files []UpdateFileInput `json:"files,omitempty" jsonschema:"File operations to apply"`
FileName string `json:"file_name,omitempty" jsonschema:"New file name (single-file, deprecated in favor of files)"`
ContentBody string `json:"content,omitempty" jsonschema:"New content (single-file, deprecated in favor of files)"`
}
ProjectUpdateInput represents the input for updating a project snippet.
type UpdateFileInput ¶
type UpdateFileInput struct {
Action string `json:"action" jsonschema:"File action: create, update, delete, move,required"`
FilePath string `json:"file_path" jsonschema:"File path,required"`
Content string `json:"content,omitempty" jsonschema:"File content (for create/update)"`
PreviousPath string `json:"previous_path,omitempty" jsonschema:"Previous file path (for move)"`
}
UpdateFileInput represents a file operation when updating a snippet.
type UpdateInput ¶
type UpdateInput struct {
SnippetID int64 `json:"snippet_id" jsonschema:"Snippet ID,required"`
Title string `json:"title,omitempty" jsonschema:"New title"`
FileName string `json:"file_name,omitempty" jsonschema:"New file name (single-file, deprecated in favor of files)"`
Description string `json:"description,omitempty" jsonschema:"New description"`
ContentBody string `json:"content,omitempty" jsonschema:"New content (single-file, deprecated in favor of files)"`
Visibility string `json:"visibility,omitempty" jsonschema:"New visibility: private, internal, or public"`
Files []UpdateFileInput `json:"files,omitempty" jsonschema:"File operations to apply"`
}
UpdateInput represents the input for updating a personal snippet.