members

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package members implements MCP tools for GitLab project member operations.

The package wraps the GitLab Members API:

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccessLevelDescription deprecated

func AccessLevelDescription(level gl.AccessLevelValue) string

AccessLevelDescription delegates to toolutil.AccessLevelDescription.

Deprecated: Import toolutil.AccessLevelDescription directly instead.

func ActionSpecs

func ActionSpecs(client *gitlabclient.Client) []toolutil.ActionSpec

ActionSpecs returns canonical specs for project member actions exposed as MCP tools. The list, get, get-inherited, add, edit, and delete routes are projected into the dynamic, meta, individual, and audit surfaces by the action catalog (ADR-0004).

func Delete

func Delete(ctx context.Context, client *gitlabclient.Client, input DeleteInput) error

Delete removes a member from a project via the GitLab Project members API (DELETE /projects/:id/members/:user_id). Requires Maintainer role; the last Owner of a project cannot be removed.

func FormatListMarkdown

func FormatListMarkdown(v ListOutput) *mcp.CallToolResult

FormatListMarkdown returns a Markdown MCP tool result for a ListOutput.

func FormatListMarkdownString

func FormatListMarkdownString(v ListOutput) string

FormatListMarkdownString renders a ListOutput as a Markdown table string.

func FormatMarkdown

func FormatMarkdown(v Output) string

FormatMarkdown renders a single member Output as Markdown.

Types

type AddInput

type AddInput struct {
	ProjectID    toolutil.StringOrInt `json:"project_id"              jsonschema:"Project ID or URL-encoded path,required"`
	UserID       int64                `json:"user_id,omitempty"       jsonschema:"User ID to add (provide user_id or username),required"`
	Username     string               `json:"username,omitempty"      jsonschema:"Username to add (provide user_id or username)"`
	AccessLevel  int                  `` /* 234-byte string literal not displayed */
	ExpiresAt    string               `json:"expires_at,omitempty"    jsonschema:"Membership expiration date (YYYY-MM-DD)"`
	MemberRoleID int64                `json:"member_role_id,omitempty" jsonschema:"Custom member role ID"`
}

AddInput defines parameters for adding a project member.

type CreatedByOutput added in v2.3.0

type CreatedByOutput struct {
	ID        int64  `json:"id"`
	Username  string `json:"username"`
	Name      string `json:"name"`
	State     string `json:"state"`
	AvatarURL string `json:"avatar_url,omitempty"`
	WebURL    string `json:"web_url,omitempty"`
}

CreatedByOutput mirrors gl.MemberCreatedBy, the user who created the membership record (1:1 SDK fidelity).

type DeleteInput

type DeleteInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	UserID    int64                `json:"user_id"    jsonschema:"User ID of the member to remove,required"`
}

DeleteInput defines parameters for removing a project member.

type EditInput

type EditInput struct {
	ProjectID    toolutil.StringOrInt `json:"project_id"              jsonschema:"Project ID or URL-encoded path,required"`
	UserID       int64                `json:"user_id"                 jsonschema:"User ID of the member to edit,required"`
	AccessLevel  int                  `` /* 238-byte string literal not displayed */
	ExpiresAt    string               `json:"expires_at,omitempty"    jsonschema:"Membership expiration date (YYYY-MM-DD)"`
	MemberRoleID int64                `json:"member_role_id,omitempty" jsonschema:"Custom member role ID"`
}

EditInput defines parameters for editing a project member.

type GetInput

type GetInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	UserID    int64                `json:"user_id"    jsonschema:"User ID of the member,required"`
}

GetInput defines parameters for retrieving a single project member.

type ListInput

type ListInput struct {
	ProjectID    toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	Query        string               `json:"query,omitempty" jsonschema:"Filter members by name or username"`
	UserIDs      []int                `json:"user_ids,omitempty" jsonschema:"Filter the results to only the listed user IDs"`
	ShowSeatInfo bool                 `json:"show_seat_info,omitempty" jsonschema:"Include seat usage information (is_using_seat) for each member"`
	OrderBy      string               `json:"order_by,omitempty" jsonschema:"Column to order results by (e.g. id, name, username, access_level)"`
	Sort         string               `json:"sort,omitempty" jsonschema:"Sort direction (asc, desc)"`
	toolutil.PaginationInput
	toolutil.KeysetPaginationInput
}

ListInput defines parameters for listing project members.

type ListOutput

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

ListOutput holds a paginated list of members.

func List

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

List retrieves all project members (including inherited members from parent groups) via the GitLab Project members API (GET /projects/:id/members/all). Supports filtering by name or username via the Query field and pagination.

type MemberRoleOutput added in v2.3.0

type MemberRoleOutput struct {
	ID                         int64  `json:"id"`
	Name                       string `json:"name"`
	Description                string `json:"description,omitempty"`
	GroupID                    int64  `json:"group_id"`
	BaseAccessLevel            int    `json:"base_access_level"`
	AdminCICDVariables         bool   `json:"admin_cicd_variables,omitempty"`
	AdminComplianceFramework   bool   `json:"admin_compliance_framework,omitempty"`
	AdminGroupMembers          bool   `json:"admin_group_member,omitempty"`
	AdminMergeRequests         bool   `json:"admin_merge_request,omitempty"`
	AdminPushRules             bool   `json:"admin_push_rules,omitempty"`
	AdminTerraformState        bool   `json:"admin_terraform_state,omitempty"`
	AdminVulnerability         bool   `json:"admin_vulnerability,omitempty"`
	AdminWebHook               bool   `json:"admin_web_hook,omitempty"`
	ArchiveProject             bool   `json:"archive_project,omitempty"`
	ManageDeployTokens         bool   `json:"manage_deploy_tokens,omitempty"`
	ManageGroupAccessTokens    bool   `json:"manage_group_access_tokens,omitempty"`
	ManageMergeRequestSettings bool   `json:"manage_merge_request_settings,omitempty"`
	ManageProjectAccessTokens  bool   `json:"manage_project_access_tokens,omitempty"`
	ManageSecurityPolicyLink   bool   `json:"manage_security_policy_link,omitempty"`
	ReadCode                   bool   `json:"read_code,omitempty"`
	ReadRunners                bool   `json:"read_runners,omitempty"`
	ReadDependency             bool   `json:"read_dependency,omitempty"`
	ReadVulnerability          bool   `json:"read_vulnerability,omitempty"`
	RemoveGroup                bool   `json:"remove_group,omitempty"`
	RemoveProject              bool   `json:"remove_project,omitempty"`
}

MemberRoleOutput mirrors gl.MemberRole, the custom member role attached to a membership (Premium/Ultimate). All permission flags are surfaced for 1:1 SDK fidelity.

type Output

type Output struct {
	toolutil.HintableOutput
	ID          int64             `json:"id"`
	Username    string            `json:"username"`
	Name        string            `json:"name"`
	State       string            `json:"state"`
	AvatarURL   string            `json:"avatar_url,omitempty"`
	AccessLevel int               `json:"access_level"`
	WebURL      string            `json:"web_url"`
	CreatedAt   string            `json:"created_at,omitempty"`
	CreatedBy   *CreatedByOutput  `json:"created_by,omitempty"`
	ExpiresAt   string            `json:"expires_at,omitempty"`
	Email       string            `json:"email,omitempty"`
	MemberRole  *MemberRoleOutput `json:"member_role,omitempty" tier:"ultimate"`
	IsUsingSeat bool              `json:"is_using_seat,omitempty"`
}

Output represents a project or group member.

func Add

func Add(ctx context.Context, client *gitlabclient.Client, input AddInput) (Output, error)

Add adds a user as a member of a project via the GitLab Project members API (POST /projects/:id/members). The user may be identified by either user_id or username. The AccessLevel must be one of 5/10/15/20/25/30/40/50/60; a MemberRoleID (Premium/Ultimate) may be provided instead to attach a custom role.

func Edit

func Edit(ctx context.Context, client *gitlabclient.Client, input EditInput) (Output, error)

Edit modifies an existing project member's access level, expiration date, or custom member role via the GitLab Project members API (PUT /projects/:id/members/:user_id). Requires at least the same access level as the target member.

func Get

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

Get retrieves a direct project member by user ID via the GitLab Project members API (GET /projects/:id/members/:user_id). Does not include members inherited from parent groups; use GetInherited for that.

func GetInherited

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

GetInherited retrieves a project member including membership inherited from any parent group via the GitLab Project members API (GET /projects/:id/members/all/:user_id).

func ToOutput

func ToOutput(m *gl.ProjectMember) Output

ToOutput converts a GitLab API gl.ProjectMember to the MCP tool output format, mirroring the SDK fields 1:1 including the full created_by and member_role sub-objects. The numeric access level is surfaced directly; callers can map it via toolutil.AccessLevelDescription when a label is needed.

Jump to

Keyboard shortcuts

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