environments

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package environments implements MCP tool handlers for GitLab environment lifecycle management including list, get, create, update, delete, and stop. It wraps the Environments service from client-go v2.

markdown.go provides Markdown formatting functions for environment MCP tool output.

register.go wires environments MCP tools to the MCP server.

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 an environment from a project.

func FormatListMarkdown

func FormatListMarkdown(out ListOutput) string

FormatListMarkdown renders a paginated list of environments as a Markdown table.

func FormatOutputMarkdown

func FormatOutputMarkdown(e Output) string

FormatOutputMarkdown renders a single environment as Markdown.

func RegisterTools

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

RegisterTools registers all environment-related MCP tools on the given server.

Types

type CreateInput

type CreateInput struct {
	ProjectID   toolutil.StringOrInt `json:"project_id"             jsonschema:"Project ID or URL-encoded path,required"`
	Name        string               `json:"name"                   jsonschema:"Environment name (e.g. production, staging),required"`
	Description string               `json:"description,omitempty"  jsonschema:"Description of the environment"`
	ExternalURL string               `json:"external_url,omitempty" jsonschema:"URL of the environment's external deployment"`
	Tier        string               `json:"tier,omitempty"         jsonschema:"Deployment tier: production, staging, testing, development, other"`
}

CreateInput defines parameters for creating an environment.

type DeleteInput

type DeleteInput struct {
	ProjectID     toolutil.StringOrInt `json:"project_id"      jsonschema:"Project ID or URL-encoded path,required"`
	EnvironmentID int64                `json:"environment_id"  jsonschema:"Environment ID,required"`
}

DeleteInput defines parameters for deleting an environment.

type GetInput

type GetInput struct {
	ProjectID     toolutil.StringOrInt `json:"project_id"      jsonschema:"Project ID or URL-encoded path,required"`
	EnvironmentID int64                `json:"environment_id"  jsonschema:"Environment ID,required"`
}

GetInput defines parameters for getting a single environment.

type ListInput

type ListInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	Name      string               `json:"name,omitempty"   jsonschema:"Filter by exact environment name"`
	Search    string               `json:"search,omitempty" jsonschema:"Search environments by name (fuzzy)"`
	States    string               `json:"states,omitempty" jsonschema:"Filter by state: available, stopping, stopped"`
	toolutil.PaginationInput
}

ListInput defines parameters for listing project environments.

type ListOutput

type ListOutput struct {
	toolutil.HintableOutput
	Environments []Output                  `json:"environments"`
	Pagination   toolutil.PaginationOutput `json:"pagination"`
}

ListOutput holds a paginated list of environments.

func List

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

List retrieves all environments for a project.

type Output

type Output struct {
	toolutil.HintableOutput
	ID          int64  `json:"id"`
	Name        string `json:"name"`
	Slug        string `json:"slug"`
	Description string `json:"description,omitempty"`
	State       string `json:"state"`
	Tier        string `json:"tier,omitempty"`
	ExternalURL string `json:"external_url,omitempty"`
	CreatedAt   string `json:"created_at,omitempty"`
	UpdatedAt   string `json:"updated_at,omitempty"`
	AutoStopAt  string `json:"auto_stop_at,omitempty"`
}

Output represents a single GitLab environment.

func Create

func Create(ctx context.Context, client *gitlabclient.Client, input CreateInput) (Output, error)

Create creates a new environment in a project.

func Get

func Get(ctx context.Context, client *gitlabclient.Client, input GetInput) (Output, error)

Get retrieves a single environment by ID.

func Stop

func Stop(ctx context.Context, client *gitlabclient.Client, input StopInput) (Output, error)

Stop stops an active environment.

func Update

func Update(ctx context.Context, client *gitlabclient.Client, input UpdateInput) (Output, error)

Update updates an existing environment.

type StopInput

type StopInput struct {
	ProjectID     toolutil.StringOrInt `json:"project_id"          jsonschema:"Project ID or URL-encoded path,required"`
	EnvironmentID int64                `json:"environment_id"      jsonschema:"Environment ID,required"`
	Force         *bool                `json:"force,omitempty"     jsonschema:"Force stop even if environment has active deployments"`
}

StopInput defines parameters for stopping an environment.

type UpdateInput

type UpdateInput struct {
	ProjectID     toolutil.StringOrInt `json:"project_id"             jsonschema:"Project ID or URL-encoded path,required"`
	EnvironmentID int64                `json:"environment_id"         jsonschema:"Environment ID,required"`
	Name          string               `json:"name,omitempty"         jsonschema:"New environment name"`
	Description   string               `json:"description,omitempty"  jsonschema:"Updated description"`
	ExternalURL   string               `json:"external_url,omitempty" jsonschema:"Updated external URL"`
	Tier          string               `json:"tier,omitempty"         jsonschema:"Updated tier: production, staging, testing, development, other"`
}

UpdateInput defines parameters for updating an environment.

Jump to

Keyboard shortcuts

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