Skip to main content
Glama

list_labels

Retrieve all labels from a GitLab project to organize and categorize issues, merge requests, and other project items.

Instructions

List all labels in a GitLab project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYes
pageNo
per_pageNo

Implementation Reference

  • The actual implementation of the listLabels function, which calls the GitLab API to retrieve labels for a project.
    export async function listLabels(projectId: string, page: number = 1, perPage: number = 20): Promise<GitLabLabelResponse[]> {
      if (!projectId?.trim()) {
        throw new Error("Project ID is required");
      }
      if (page < 1) {
        throw new Error("Page number must be 1 or greater");
      }
      if (perPage < 1 || perPage > 100) {
        throw new Error("Per page must be between 1 and 100");
      }
    
      const endpoint = `/projects/${encodeProjectId(projectId)}/labels`;
      const params = buildSearchParams({
        page: page.toString(),
        per_page: perPage.toString()
      });
    
      const labels = await gitlabGet<GitLabLabelResponse[]>(endpoint, params);
      return z.array(GitLabLabelSchema).parse(labels);
    }
  • Zod schema definition for input validation of the list_labels tool.
    export const ListLabelsSchema = z.object({
      project_id: z.string(),
      page: z.number().optional(),
      per_page: z.number().optional()
    });
  • src/server.ts:300-304 (registration)
    Registration and invocation logic for the list_labels tool within the MCP server's request handler.
    case "list_labels": {
      const args = ListLabelsSchema.parse(request.params.arguments);
      const labels = await api.listLabels(args.project_id, args.page, args.per_page);
      return { content: [{ type: "text", text: JSON.stringify(labels, null, 2) }] };
    }

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/TheRealChrisThomas/gitlab-mcp-server'

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