Documentation
¶
Overview ¶
markdown.go provides Markdown formatting functions for pipeline MCP tool output.
Package pipelines implements MCP tool handlers for GitLab pipeline operations including list, get, create, cancel, retry, and delete. It wraps the Pipelines service from client-go v2.
register.go wires pipelines MCP tools to the MCP server.
wait.go implements a server-side polling tool that waits for a pipeline to reach a terminal state, sending MCP progress notifications during polling.
Index ¶
- func Delete(ctx context.Context, client *gitlabclient.Client, input DeleteInput) error
- func FormatDetailMarkdown(p DetailOutput) string
- func FormatListMarkdown(out ListOutput) string
- func FormatTestReportMarkdown(out TestReportOutput) string
- func FormatTestReportSummaryMarkdown(out TestReportSummaryOutput) string
- func FormatVariablesMarkdown(out VariablesOutput) string
- func FormatWaitMarkdown(out WaitOutput) string
- func RegisterTools(server *mcp.Server, client *gitlabclient.Client)
- type ActionInput
- type CreateInput
- type DeleteInput
- type DetailOutput
- func Cancel(ctx context.Context, client *gitlabclient.Client, input ActionInput) (DetailOutput, error)
- func Create(ctx context.Context, client *gitlabclient.Client, input CreateInput) (DetailOutput, error)
- func DetailToOutput(p *gl.Pipeline) DetailOutput
- func Get(ctx context.Context, client *gitlabclient.Client, input GetInput) (DetailOutput, error)
- func GetLatest(ctx context.Context, client *gitlabclient.Client, input GetLatestInput) (DetailOutput, error)
- func Retry(ctx context.Context, client *gitlabclient.Client, input ActionInput) (DetailOutput, error)
- func UpdateMetadata(ctx context.Context, client *gitlabclient.Client, input UpdateMetadataInput) (DetailOutput, error)
- type GetInput
- type GetLatestInput
- type ListInput
- type ListOutput
- type Output
- type StatusOutput
- type TestReportOutput
- type TestReportSummaryOutput
- type TestSuiteOutput
- type TestSuiteSummaryOutput
- type UpdateMetadataInput
- type VariableOptionInput
- type VariableOutput
- type VariablesOutput
- type WaitInput
- type WaitOutput
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 permanently deletes a pipeline and all its jobs.
func FormatDetailMarkdown ¶
func FormatDetailMarkdown(p DetailOutput) string
FormatDetailMarkdown renders a single pipeline detail as a Markdown summary.
func FormatListMarkdown ¶
func FormatListMarkdown(out ListOutput) string
FormatListMarkdown renders a paginated list of pipelines as a Markdown table.
func FormatTestReportMarkdown ¶
func FormatTestReportMarkdown(out TestReportOutput) string
FormatTestReportMarkdown renders a pipeline test report as Markdown.
func FormatTestReportSummaryMarkdown ¶
func FormatTestReportSummaryMarkdown(out TestReportSummaryOutput) string
FormatTestReportSummaryMarkdown renders a pipeline test report summary as Markdown.
func FormatVariablesMarkdown ¶
func FormatVariablesMarkdown(out VariablesOutput) string
FormatVariablesMarkdown renders pipeline variables as a Markdown table.
func FormatWaitMarkdown ¶
func FormatWaitMarkdown(out WaitOutput) string
FormatWaitMarkdown renders the wait result as a Markdown summary.
func RegisterTools ¶
func RegisterTools(server *mcp.Server, client *gitlabclient.Client)
RegisterTools registers all pipeline MCP tools on the given server.
Types ¶
type ActionInput ¶
type ActionInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
PipelineID int64 `json:"pipeline_id" jsonschema:"Pipeline ID to act on,required"`
}
ActionInput defines parameters for pipeline cancel/retry actions.
type CreateInput ¶
type CreateInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
Ref string `json:"ref" jsonschema:"Branch or tag name to run the pipeline for"`
Variables []VariableOptionInput `json:"variables,omitempty" jsonschema:"Pipeline variables to set"`
}
CreateInput defines parameters for creating a new pipeline.
type DeleteInput ¶
type DeleteInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
PipelineID int64 `json:"pipeline_id" jsonschema:"Pipeline ID to delete,required"`
}
DeleteInput defines parameters for deleting a pipeline.
type DetailOutput ¶
type DetailOutput struct {
toolutil.HintableOutput
ID int64 `json:"id"`
IID int64 `json:"iid"`
ProjectID int64 `json:"project_id"`
Status string `json:"status"`
Source string `json:"source"`
Ref string `json:"ref"`
SHA string `json:"sha"`
BeforeSHA string `json:"before_sha,omitempty"`
Name string `json:"name"`
Tag bool `json:"tag"`
YamlErrors string `json:"yaml_errors,omitempty"`
Duration int64 `json:"duration"`
QueuedDuration int64 `json:"queued_duration"`
Coverage string `json:"coverage,omitempty"`
DetailedStatus *StatusOutput `json:"detailed_status,omitempty"`
WebURL string `json:"web_url"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
StartedAt string `json:"started_at,omitempty"`
FinishedAt string `json:"finished_at,omitempty"`
CommittedAt string `json:"committed_at,omitempty"`
UserUsername string `json:"user_username,omitempty"`
}
DetailOutput represents a single pipeline with full details.
func Cancel ¶
func Cancel(ctx context.Context, client *gitlabclient.Client, input ActionInput) (DetailOutput, error)
Cancel cancels a running pipeline's jobs.
func Create ¶
func Create(ctx context.Context, client *gitlabclient.Client, input CreateInput) (DetailOutput, error)
Create creates a new pipeline for the given ref with optional variables.
func DetailToOutput ¶
func DetailToOutput(p *gl.Pipeline) DetailOutput
DetailToOutput converts a GitLab API gl.Pipeline to MCP output.
func Get ¶
func Get(ctx context.Context, client *gitlabclient.Client, input GetInput) (DetailOutput, error)
Get retrieves a single pipeline by ID from a GitLab project.
func GetLatest ¶
func GetLatest(ctx context.Context, client *gitlabclient.Client, input GetLatestInput) (DetailOutput, error)
GetLatest retrieves the latest pipeline for a project, optionally filtered by ref. Falls back to listing pipelines (per_page=1, sort=desc) if the /latest endpoint returns 403, which happens for users without Maintainer+ role.
func Retry ¶
func Retry(ctx context.Context, client *gitlabclient.Client, input ActionInput) (DetailOutput, error)
Retry retries failed jobs in a pipeline.
func UpdateMetadata ¶
func UpdateMetadata(ctx context.Context, client *gitlabclient.Client, input UpdateMetadataInput) (DetailOutput, error)
UpdateMetadata updates the metadata (name) of a pipeline.
type GetInput ¶
type GetInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
PipelineID int64 `json:"pipeline_id" jsonschema:"Pipeline ID to retrieve,required"`
}
GetInput defines parameters for retrieving a single pipeline.
type GetLatestInput ¶
type GetLatestInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
Ref string `json:"ref,omitempty" jsonschema:"Branch or tag name to filter by (defaults to the default branch)"`
}
GetLatestInput defines parameters for getting the latest pipeline.
type ListInput ¶
type ListInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
Scope string `json:"scope,omitempty" jsonschema:"Filter by scope (running, pending, finished, branches, tags)"`
Status string `` /* 176-byte string literal not displayed */
Source string `` /* 143-byte string literal not displayed */
Ref string `json:"ref,omitempty" jsonschema:"Filter by branch or tag name"`
SHA string `json:"sha,omitempty" jsonschema:"Filter by commit SHA"`
Name string `json:"name,omitempty" jsonschema:"Filter by pipeline name"`
Username string `json:"username,omitempty" jsonschema:"Filter by username that triggered the pipeline"`
YamlErrors bool `json:"yaml_errors,omitempty" jsonschema:"Return only pipelines with YAML errors"`
OrderBy string `json:"order_by,omitempty" jsonschema:"Order by field (id, status, ref, updated_at, user_id)"`
Sort string `json:"sort,omitempty" jsonschema:"Sort direction (asc, desc)"`
CreatedAfter string `json:"created_after,omitempty" jsonschema:"Return pipelines created after date (ISO 8601 format, e.g. 2025-01-01T00:00:00Z)"`
CreatedBefore string `` /* 126-byte string literal not displayed */
UpdatedAfter string `json:"updated_after,omitempty" jsonschema:"Return pipelines updated after date (ISO 8601 format, e.g. 2025-01-01T00:00:00Z)"`
UpdatedBefore string `` /* 126-byte string literal not displayed */
toolutil.PaginationInput
}
ListInput defines parameters for listing pipelines in a GitLab project.
type ListOutput ¶
type ListOutput struct {
toolutil.HintableOutput
Pipelines []Output `json:"pipelines"`
Pagination toolutil.PaginationOutput `json:"pagination"`
}
ListOutput holds a paginated list of pipelines.
func List ¶
func List(ctx context.Context, client *gitlabclient.Client, input ListInput) (ListOutput, error)
List retrieves a paginated list of pipelines for a GitLab project. Supports filtering by scope, status, source, ref, SHA, username, and date ranges.
type Output ¶
type Output struct {
toolutil.HintableOutput
ID int64 `json:"id"`
IID int64 `json:"iid"`
ProjectID int64 `json:"project_id"`
Status string `json:"status"`
Source string `json:"source"`
Ref string `json:"ref"`
SHA string `json:"sha"`
Name string `json:"name"`
WebURL string `json:"web_url"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
Output represents a single pipeline in the list response.
func ToOutput ¶
func ToOutput(p *gl.PipelineInfo) Output
ToOutput converts a GitLab API gl.PipelineInfo to MCP output format.
type StatusOutput ¶
type StatusOutput struct {
Icon string `json:"icon"`
Text string `json:"text"`
Label string `json:"label"`
Group string `json:"group"`
Tooltip string `json:"tooltip"`
HasDetails bool `json:"has_details"`
DetailsPath string `json:"details_path,omitempty"`
Favicon string `json:"favicon,omitempty"`
}
StatusOutput represents the detailed status of a pipeline.
type TestReportOutput ¶
type TestReportOutput struct {
toolutil.HintableOutput
TotalTime float64 `json:"total_time"`
TotalCount int64 `json:"total_count"`
SuccessCount int64 `json:"success_count"`
FailedCount int64 `json:"failed_count"`
SkippedCount int64 `json:"skipped_count"`
ErrorCount int64 `json:"error_count"`
TestSuites []TestSuiteOutput `json:"test_suites"`
}
TestReportOutput represents a pipeline test report.
func GetTestReport ¶
func GetTestReport(ctx context.Context, client *gitlabclient.Client, input GetInput) (TestReportOutput, error)
GetTestReport retrieves the test report for a specific pipeline.
type TestReportSummaryOutput ¶
type TestReportSummaryOutput struct {
toolutil.HintableOutput
TotalTime float64 `json:"total_time"`
TotalCount int64 `json:"total_count"`
SuccessCount int64 `json:"success_count"`
FailedCount int64 `json:"failed_count"`
SkippedCount int64 `json:"skipped_count"`
ErrorCount int64 `json:"error_count"`
TestSuites []TestSuiteSummaryOutput `json:"test_suites"`
}
TestReportSummaryOutput represents a pipeline test report summary.
func GetTestReportSummary ¶
func GetTestReportSummary(ctx context.Context, client *gitlabclient.Client, input GetInput) (TestReportSummaryOutput, error)
GetTestReportSummary retrieves the test report summary for a specific pipeline.
type TestSuiteOutput ¶
type TestSuiteOutput struct {
Name string `json:"name"`
TotalTime float64 `json:"total_time"`
TotalCount int64 `json:"total_count"`
SuccessCount int64 `json:"success_count"`
FailedCount int64 `json:"failed_count"`
SkippedCount int64 `json:"skipped_count"`
ErrorCount int64 `json:"error_count"`
}
TestSuiteOutput represents a test suite within a test report.
type TestSuiteSummaryOutput ¶
type TestSuiteSummaryOutput struct {
Name string `json:"name"`
TotalTime float64 `json:"total_time"`
TotalCount int64 `json:"total_count"`
SuccessCount int64 `json:"success_count"`
FailedCount int64 `json:"failed_count"`
SkippedCount int64 `json:"skipped_count"`
ErrorCount int64 `json:"error_count"`
BuildIDs []int64 `json:"build_ids"`
}
TestSuiteSummaryOutput represents a test suite summary.
type UpdateMetadataInput ¶
type UpdateMetadataInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
PipelineID int64 `json:"pipeline_id" jsonschema:"Pipeline ID to update,required"`
Name string `json:"name" jsonschema:"New pipeline name,required"`
}
UpdateMetadataInput defines parameters for updating pipeline metadata.
type VariableOptionInput ¶
type VariableOptionInput struct {
Key string `json:"key" jsonschema:"Variable key,required"`
Value string `json:"value" jsonschema:"Variable value"`
VariableType string `json:"variable_type,omitempty" jsonschema:"Variable type (env_var or file, default: env_var)"`
}
VariableOptionInput represents a variable to pass when creating a pipeline.
type VariableOutput ¶
type VariableOutput struct {
Key string `json:"key"`
Value string `json:"value"`
VariableType string `json:"variable_type"`
}
VariableOutput represents a single pipeline variable.
type VariablesOutput ¶
type VariablesOutput struct {
toolutil.HintableOutput
Variables []VariableOutput `json:"variables"`
}
VariablesOutput holds a list of pipeline variables.
func GetVariables ¶
func GetVariables(ctx context.Context, client *gitlabclient.Client, input GetInput) (VariablesOutput, error)
GetVariables retrieves the variables for a specific pipeline.
type WaitInput ¶
type WaitInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
PipelineID int64 `json:"pipeline_id" jsonschema:"Pipeline ID to wait for,required"`
IntervalSeconds int `json:"interval_seconds,omitempty" jsonschema:"Polling interval in seconds (5-60, default 10)"`
TimeoutSeconds int `json:"timeout_seconds,omitempty" jsonschema:"Maximum wait time in seconds (1-3600, default 300)"`
FailOnError *bool `json:"fail_on_error,omitempty" jsonschema:"Return isError when pipeline ends in failed/canceled status (default true)"`
}
WaitInput defines parameters for waiting on a pipeline to complete.
type WaitOutput ¶
type WaitOutput struct {
toolutil.HintableOutput
Pipeline DetailOutput `json:"pipeline"`
WaitedFor string `json:"waited_for"`
PollCount int `json:"poll_count"`
FinalStatus string `json:"final_status"`
TimedOut bool `json:"timed_out"`
}
WaitOutput holds the result of waiting for a pipeline.
func Wait ¶
func Wait(ctx context.Context, req *mcp.CallToolRequest, client *gitlabclient.Client, input WaitInput) (WaitOutput, error)
Wait polls a pipeline until it reaches a terminal state or the timeout is reached. It sends MCP progress notifications to keep the client informed during polling.