Skip to main content
Glama

gitlab_get_user_snippets

Retrieve and manage code snippets created by a specific GitLab user across personal and project scopes, including content, metadata, and visibility settings for code reuse and knowledge sharing.

Instructions

List all personal and project snippets created by a user

Find all code snippets created by the specified user across personal and project scopes, with content and metadata.

Returns snippet information with:

  • Snippet details: title, description, visibility

  • Content info: file names, language detection

  • Usage context: project association, sharing scope

  • Metadata: creation date, update history

  • Access info: permissions, visibility settings

Use cases:

  • Personal code library management

  • Knowledge sharing and documentation

  • Code reuse and template management

  • Developer portfolio and examples

Parameters:

  • user_id: Numeric user ID

  • username: Username string (use either user_id or username)

  • scope: Snippet scope (personal, project, all)

  • visibility: Filter by visibility (private, internal, public)

  • language: Filter by programming language

  • sort: Sort order (created, updated, name)

  • per_page: Results per page (default: 20)

  • page: Page number (default: 1)

Example: Get user's public snippets

{ "username": "johndoe", "visibility": "public", "sort": "created" }

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
usernameYesUsername string
per_pageNoNumber of results per page Type: integer Range: 1-100 Default: 20 Example: 50 (for faster browsing) Tip: Use smaller values (10-20) for detailed operations, larger (50-100) for listing
pageNoPage number for pagination Type: integer Range: ≥1 Default: 1 Example: 3 (to get the third page of results) Note: Use with per_page to navigate large result sets

Implementation Reference

  • The handler function that implements the core logic for the gitlab_get_user_snippets tool. It validates input arguments (requiring 'username'), sets defaults for pagination, and delegates to GitLabClient.get_user_snippets().
    def handle_get_user_snippets(client: GitLabClient, arguments: Optional[Dict[str, Any]]) -> Dict[str, Any]: """Handle getting user's snippets""" username = get_argument(arguments, "username") if not username: raise ValueError("username is required") per_page = get_argument(arguments, "per_page", DEFAULT_PAGE_SIZE) page = get_argument(arguments, "page", 1) return client.get_user_snippets( username=username, per_page=per_page, page=page )
  • Pydantic/MCP schema definition for the gitlab_get_user_snippets tool, including input validation schema with required 'username' and optional pagination/visibility parameters.
    types.Tool( name=TOOL_GET_USER_SNIPPETS, description=desc.DESC_GET_USER_SNIPPETS, inputSchema={ "type": "object", "properties": { "username": {"type": "string", "description": "Username string"}, "visibility": {"type": "string", "description": "Snippet visibility", "enum": ["public", "internal", "private", "all"], "default": "all"}, "per_page": {"type": "integer", "description": desc.DESC_PER_PAGE, "default": DEFAULT_PAGE_SIZE, "minimum": 1, "maximum": MAX_PAGE_SIZE}, "page": {"type": "integer", "description": desc.DESC_PAGE_NUMBER, "default": 1, "minimum": 1} }, "required": ["username"] } ),
  • Registration of the tool handler in the TOOL_HANDLERS dictionary, which is used by server.py to dispatch tool calls to the appropriate handler function.
    TOOL_GET_USER_CODE_CHANGES_SUMMARY: handle_get_user_code_changes_summary, TOOL_GET_USER_SNIPPETS: handle_get_user_snippets,
  • Constant defining the exact tool name string 'gitlab_get_user_snippets' used across the codebase for consistency.
    TOOL_GET_USER_SNIPPETS = "gitlab_get_user_snippets"

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Vijay-Duke/mcp-gitlab'

If you have feedback or need assistance with the MCP directory API, please join our Discord server