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
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes | ||
| page | No | ||
| per_page | No |
Implementation Reference
- src/api/labels.ts:6-25 (handler)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); } - src/schemas.ts:312-316 (schema)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) }] }; }