update_label
Modify an existing label in a GitLab project to change its name, color, description, or priority.
Instructions
Update an existing label in a GitLab project
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes | ||
| name | Yes | ||
| new_name | No | ||
| color | No | ||
| description | No | ||
| priority | No |
Implementation Reference
- src/api/labels.ts:59-90 (handler)The implementation of the updateLabel function which handles the GitLab API request for updating an existing label.
export async function updateLabel( projectId: string, name: string, options: { new_name?: string; color?: string; description?: string; priority?: number; } ): Promise<GitLabLabelResponse> { if (!projectId?.trim()) { throw new Error("Project ID is required"); } if (!name?.trim()) { throw new Error("Label name is required"); } if (options.color && !options.color.match(/^#[0-9a-fA-F]{6}$/)) { throw new Error("Label color must be a valid hex color (e.g., #ff0000)"); } const encodedName = encodeURIComponent(name); const endpoint = `/projects/${encodeProjectId(projectId)}/labels/${encodedName}`; const label = await gitlabPut<GitLabLabelResponse>(endpoint, { new_name: options.new_name, color: options.color, description: options.description, priority: options.priority }); return GitLabLabelSchema.parse(label); } - src/schemas.ts:298-305 (schema)Zod schema for validating the input arguments of the update_label tool.
export const UpdateLabelSchema = z.object({ project_id: z.string(), name: z.string(), // Current name (identifier) new_name: z.string().optional(), color: z.string().optional(), description: z.string().optional(), priority: z.number().optional() }); - src/server.ts:312-317 (registration)Tool registration and handler execution logic for update_label in the MCP server.
case "update_label": { const args = UpdateLabelSchema.parse(request.params.arguments); const { project_id, name, ...options } = args; const label = await api.updateLabel(project_id, name, options); return { content: [{ type: "text", text: JSON.stringify(label, null, 2) }] }; }