Skip to main content
Glama

gitlab_list_snippets

Browse and filter reusable code snippets from GitLab projects. Retrieve metadata including title, description, and visibility. Supports pagination and project-specific filtering for efficient snippet discovery.

Instructions

List project snippets Returns: Array of snippets with metadata Use when: Browsing code snippets, finding reusable code Pagination: Yes (default 20 per page) Filtering: By project

Example response: [{ "id": 123, "title": "Database Helper", "file_name": "db_helper.py", "description": "Common database operations", "visibility": "private", "author": {"name": "John Doe"}, "created_at": "2023-01-01T00:00:00Z", "web_url": "https://gitlab.com/group/project/snippets/123" }]

Related tools:

  • gitlab_get_snippet: Get snippet content

  • gitlab_create_snippet: Create new snippet

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
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
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
project_idNoProject identifier (auto-detected if not provided) Type: integer OR string Format: numeric ID or 'namespace/project' Optional: Yes - auto-detects from current git repository Examples: - 12345 (numeric ID) - 'gitlab-org/gitlab' (namespace/project path) - 'my-group/my-subgroup/my-project' (nested groups) Note: If in a git repo with GitLab remote, this can be omitted

Implementation Reference

  • The primary handler function that implements the core logic for the 'gitlab_list_snippets' tool. It determines the project ID (auto-detecting from the current git repository if not specified), parses pagination parameters, and calls the underlying GitLabClient.list_snippets method to fetch the snippets.
    def handle_list_snippets(client: GitLabClient, arguments: Optional[Dict[str, Any]]) -> Dict[str, Any]: """Handle listing project snippets""" project_id = require_project_id(client, arguments) per_page = get_argument(arguments, "per_page", DEFAULT_PAGE_SIZE) page = get_argument(arguments, "page", 1) return client.list_snippets(project_id, per_page=per_page, page=page)
  • The MCP tool schema definition for 'gitlab_list_snippets', including input parameter validation for project_id, per_page (1-100), and page.
    name=TOOL_LIST_SNIPPETS, description=desc.DESC_LIST_SNIPPETS, inputSchema={ "type": "object", "properties": { "project_id": {"type": "string", "description": desc.DESC_PROJECT_ID}, "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} } } ),
  • Registration of the tool handler in the TOOL_HANDLERS dictionary mapping, used by the MCP server to dispatch calls to the correct handler function.
    TOOL_LIST_SNIPPETS: handle_list_snippets,
  • Constant definition for the tool name 'gitlab_list_snippets', used consistently across tool definitions, registrations, and handlers.
    TOOL_LIST_SNIPPETS = "gitlab_list_snippets"

Other Tools

Related 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