Documentation
¶
Overview ¶
Package accesstokens implements GitLab Access Token operations as MCP tools. It supports project access tokens, group access tokens, and personal access tokens, including listing, getting, creating, rotating, and revoking tokens.
Index ¶
- func FormatListMarkdown(out ListOutput) string
- func FormatOutputMarkdown(out Output) string
- func GroupRevoke(ctx context.Context, client *gitlabclient.Client, input GroupRevokeInput) error
- func PersonalRevoke(ctx context.Context, client *gitlabclient.Client, input PersonalRevokeInput) error
- func PersonalRevokeSelf(ctx context.Context, client *gitlabclient.Client, _ PersonalRevokeSelfInput) error
- func ProjectRevoke(ctx context.Context, client *gitlabclient.Client, input ProjectRevokeInput) error
- func RegisterMeta(server *mcp.Server, client *gitlabclient.Client)
- func RegisterTools(server *mcp.Server, client *gitlabclient.Client)
- type GroupCreateInput
- type GroupGetInput
- type GroupListInput
- type GroupRevokeInput
- type GroupRotateInput
- type GroupRotateSelfInput
- type ListOutput
- func GroupList(ctx context.Context, client *gitlabclient.Client, input GroupListInput) (ListOutput, error)
- func PersonalList(ctx context.Context, client *gitlabclient.Client, input PersonalListInput) (ListOutput, error)
- func ProjectList(ctx context.Context, client *gitlabclient.Client, input ProjectListInput) (ListOutput, error)
- type Output
- func GroupCreate(ctx context.Context, client *gitlabclient.Client, input GroupCreateInput) (Output, error)
- func GroupGet(ctx context.Context, client *gitlabclient.Client, input GroupGetInput) (Output, error)
- func GroupRotate(ctx context.Context, client *gitlabclient.Client, input GroupRotateInput) (Output, error)
- func GroupRotateSelf(ctx context.Context, client *gitlabclient.Client, input GroupRotateSelfInput) (Output, error)
- func PersonalGet(ctx context.Context, client *gitlabclient.Client, input PersonalGetInput) (Output, error)
- func PersonalRotate(ctx context.Context, client *gitlabclient.Client, input PersonalRotateInput) (Output, error)
- func PersonalRotateSelf(ctx context.Context, client *gitlabclient.Client, ...) (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 ProjectRotate(ctx context.Context, client *gitlabclient.Client, input ProjectRotateInput) (Output, error)
- func ProjectRotateSelf(ctx context.Context, client *gitlabclient.Client, input ProjectRotateSelfInput) (Output, error)
- type PersonalGetInput
- type PersonalListInput
- type PersonalRevokeInput
- type PersonalRevokeSelfInput
- type PersonalRotateInput
- type PersonalRotateSelfInput
- type ProjectCreateInput
- type ProjectGetInput
- type ProjectListInput
- type ProjectRevokeInput
- type ProjectRotateInput
- type ProjectRotateSelfInput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatListMarkdown ¶
func FormatListMarkdown(out ListOutput) string
FormatListMarkdown renders a list of access tokens as Markdown.
func FormatOutputMarkdown ¶
FormatOutputMarkdown renders an access token as Markdown.
func GroupRevoke ¶
func GroupRevoke(ctx context.Context, client *gitlabclient.Client, input GroupRevokeInput) error
GroupRevoke revokes a group access token.
func PersonalRevoke ¶
func PersonalRevoke(ctx context.Context, client *gitlabclient.Client, input PersonalRevokeInput) error
PersonalRevoke revokes a personal access token by ID.
func PersonalRevokeSelf ¶
func PersonalRevokeSelf(ctx context.Context, client *gitlabclient.Client, _ PersonalRevokeSelfInput) error
PersonalRevokeSelf revokes the personal access token used for the current request.
func ProjectRevoke ¶
func ProjectRevoke(ctx context.Context, client *gitlabclient.Client, input ProjectRevokeInput) error
ProjectRevoke revokes a project access token.
func RegisterMeta ¶
func RegisterMeta(server *mcp.Server, client *gitlabclient.Client)
RegisterMeta registers the gitlab_access_token meta-tool with all access token actions.
func RegisterTools ¶
func RegisterTools(server *mcp.Server, client *gitlabclient.Client)
RegisterTools registers all access token management MCP tools.
Types ¶
type GroupCreateInput ¶
type GroupCreateInput struct {
GroupID toolutil.StringOrInt `json:"group_id" jsonschema:"Group ID or URL-encoded path,required"`
Name string `json:"name" jsonschema:"Token name,required"`
Description string `json:"description,omitempty" jsonschema:"Token description"`
Scopes []string `json:"scopes" jsonschema:"Token scopes: api, read_api, read_repository, write_repository, etc.,required"`
AccessLevel int `` /* 128-byte string literal not displayed */
ExpiresAt string `json:"expires_at,omitempty" jsonschema:"Expiry date in YYYY-MM-DD format"`
}
GroupCreateInput defines parameters for creating a group access token.
type GroupGetInput ¶
type GroupGetInput struct {
GroupID toolutil.StringOrInt `json:"group_id" jsonschema:"Group ID or URL-encoded path,required"`
TokenID int64 `json:"token_id" jsonschema:"Access token ID,required"`
}
GroupGetInput defines parameters for getting a group access token.
type GroupListInput ¶
type GroupListInput struct {
GroupID toolutil.StringOrInt `json:"group_id" jsonschema:"Group ID or URL-encoded path,required"`
State string `json:"state,omitempty" jsonschema:"Token state filter: active, inactive"`
toolutil.PaginationInput
}
GroupListInput defines parameters for listing group access tokens.
type GroupRevokeInput ¶
type GroupRevokeInput struct {
GroupID toolutil.StringOrInt `json:"group_id" jsonschema:"Group ID or URL-encoded path,required"`
TokenID int64 `json:"token_id" jsonschema:"Access token ID to revoke,required"`
}
GroupRevokeInput defines parameters for revoking a group access token.
type GroupRotateInput ¶
type GroupRotateInput struct {
GroupID toolutil.StringOrInt `json:"group_id" jsonschema:"Group ID or URL-encoded path,required"`
TokenID int64 `json:"token_id" jsonschema:"Access token ID,required"`
ExpiresAt string `json:"expires_at,omitempty" jsonschema:"New expiry date in YYYY-MM-DD format"`
}
GroupRotateInput defines parameters for rotating a group access token.
type GroupRotateSelfInput ¶
type GroupRotateSelfInput struct {
GroupID toolutil.StringOrInt `json:"group_id" jsonschema:"Group ID or URL-encoded path,required"`
ExpiresAt string `json:"expires_at,omitempty" jsonschema:"New expiry date in YYYY-MM-DD format"`
}
GroupRotateSelfInput defines parameters for self-rotating a group access token.
type ListOutput ¶
type ListOutput struct {
toolutil.HintableOutput
Tokens []Output `json:"tokens"`
Pagination toolutil.PaginationOutput `json:"pagination"`
}
ListOutput holds a paginated list of access tokens.
func GroupList ¶
func GroupList(ctx context.Context, client *gitlabclient.Client, input GroupListInput) (ListOutput, error)
GroupList returns access tokens for a group.
func PersonalList ¶
func PersonalList(ctx context.Context, client *gitlabclient.Client, input PersonalListInput) (ListOutput, error)
PersonalList returns personal access tokens.
func ProjectList ¶
func ProjectList(ctx context.Context, client *gitlabclient.Client, input ProjectListInput) (ListOutput, error)
ProjectList returns access tokens for a project.
type Output ¶
type Output struct {
toolutil.HintableOutput
ID int64 `json:"id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Revoked bool `json:"revoked"`
Active bool `json:"active"`
Scopes []string `json:"scopes,omitempty"`
UserID int64 `json:"user_id,omitempty"`
AccessLevel int `json:"access_level,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
LastUsedAt string `json:"last_used_at,omitempty"`
ExpiresAt string `json:"expires_at,omitempty"`
Token string `json:"token,omitempty"`
}
Output represents a GitLab access token in responses.
func GroupCreate ¶
func GroupCreate(ctx context.Context, client *gitlabclient.Client, input GroupCreateInput) (Output, error)
GroupCreate creates a new group access token.
func GroupGet ¶
func GroupGet(ctx context.Context, client *gitlabclient.Client, input GroupGetInput) (Output, error)
GroupGet returns a specific group access token.
func GroupRotate ¶
func GroupRotate(ctx context.Context, client *gitlabclient.Client, input GroupRotateInput) (Output, error)
GroupRotate rotates a group access token and returns the new token.
func GroupRotateSelf ¶
func GroupRotateSelf(ctx context.Context, client *gitlabclient.Client, input GroupRotateSelfInput) (Output, error)
GroupRotateSelf rotates the group access token used for the current request.
func PersonalGet ¶
func PersonalGet(ctx context.Context, client *gitlabclient.Client, input PersonalGetInput) (Output, error)
PersonalGet returns a specific personal access token by ID, or the current token if ID is 0.
func PersonalRotate ¶
func PersonalRotate(ctx context.Context, client *gitlabclient.Client, input PersonalRotateInput) (Output, error)
PersonalRotate rotates a personal access token and returns the new token.
func PersonalRotateSelf ¶
func PersonalRotateSelf(ctx context.Context, client *gitlabclient.Client, input PersonalRotateSelfInput) (Output, error)
PersonalRotateSelf rotates the personal access token used for the current request.
func ProjectCreate ¶
func ProjectCreate(ctx context.Context, client *gitlabclient.Client, input ProjectCreateInput) (Output, error)
ProjectCreate creates a new project access token.
func ProjectGet ¶
func ProjectGet(ctx context.Context, client *gitlabclient.Client, input ProjectGetInput) (Output, error)
ProjectGet returns a specific project access token.
func ProjectRotate ¶
func ProjectRotate(ctx context.Context, client *gitlabclient.Client, input ProjectRotateInput) (Output, error)
ProjectRotate rotates a project access token and returns the new token.
func ProjectRotateSelf ¶
func ProjectRotateSelf(ctx context.Context, client *gitlabclient.Client, input ProjectRotateSelfInput) (Output, error)
ProjectRotateSelf rotates the project access token used for the current request.
type PersonalGetInput ¶
type PersonalGetInput struct {
TokenID int64 `json:"token_id" jsonschema:"Access token ID (required, use 0 for current token)"`
}
PersonalGetInput defines parameters for getting a personal access token.
type PersonalListInput ¶
type PersonalListInput struct {
State string `json:"state,omitempty" jsonschema:"Token state filter: active, inactive"`
Search string `json:"search,omitempty" jsonschema:"Search by token name"`
UserID int64 `json:"user_id,omitempty" jsonschema:"Filter by user ID (admin only)"`
toolutil.PaginationInput
}
PersonalListInput defines parameters for listing personal access tokens.
type PersonalRevokeInput ¶
type PersonalRevokeInput struct {
TokenID int64 `json:"token_id" jsonschema:"Access token ID to revoke,required"`
}
PersonalRevokeInput defines parameters for revoking a personal access token.
type PersonalRevokeSelfInput ¶
type PersonalRevokeSelfInput struct{}
PersonalRevokeSelfInput is an empty struct for self-revoking the current PAT.
type PersonalRotateInput ¶
type PersonalRotateInput struct {
TokenID int64 `json:"token_id" jsonschema:"Access token ID,required"`
ExpiresAt string `json:"expires_at,omitempty" jsonschema:"New expiry date in YYYY-MM-DD format"`
}
PersonalRotateInput defines parameters for rotating a personal access token.
type PersonalRotateSelfInput ¶
type PersonalRotateSelfInput struct {
ExpiresAt string `json:"expires_at,omitempty" jsonschema:"New expiry date in YYYY-MM-DD format"`
}
PersonalRotateSelfInput defines parameters for self-rotating the current personal access token.
type ProjectCreateInput ¶
type ProjectCreateInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
Name string `json:"name" jsonschema:"Token name,required"`
Description string `json:"description,omitempty" jsonschema:"Token description"`
Scopes []string `json:"scopes" jsonschema:"Token scopes: api, read_api, read_repository, write_repository, etc.,required"`
AccessLevel int `json:"access_level,omitempty" jsonschema:"Access level: 10 (guest), 20 (reporter), 30 (developer), 40 (maintainer)"`
ExpiresAt string `json:"expires_at,omitempty" jsonschema:"Expiry date in YYYY-MM-DD format"`
}
ProjectCreateInput defines parameters for creating a project access token.
type ProjectGetInput ¶
type ProjectGetInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
TokenID int64 `json:"token_id" jsonschema:"Access token ID,required"`
}
ProjectGetInput defines parameters for getting a project access token.
type ProjectListInput ¶
type ProjectListInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
State string `json:"state,omitempty" jsonschema:"Token state filter: active, inactive"`
toolutil.PaginationInput
}
ProjectListInput defines parameters for listing project access tokens.
type ProjectRevokeInput ¶
type ProjectRevokeInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
TokenID int64 `json:"token_id" jsonschema:"Access token ID to revoke,required"`
}
ProjectRevokeInput defines parameters for revoking a project access token.
type ProjectRotateInput ¶
type ProjectRotateInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
TokenID int64 `json:"token_id" jsonschema:"Access token ID,required"`
ExpiresAt string `json:"expires_at,omitempty" jsonschema:"New expiry date in YYYY-MM-DD format"`
}
ProjectRotateInput defines parameters for rotating a project access token.
type ProjectRotateSelfInput ¶
type ProjectRotateSelfInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
ExpiresAt string `json:"expires_at,omitempty" jsonschema:"New expiry date in YYYY-MM-DD format"`
}
ProjectRotateSelfInput defines parameters for self-rotating a project access token.