create_label
Create a new label in a GitLab project to organize issues and merge requests by specifying name, color, and optional description or priority.
Instructions
Create a new label in a GitLab project
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes | ||
| name | Yes | ||
| color | Yes | ||
| description | No | ||
| priority | No |
Implementation Reference
- src/api/labels.ts:27-57 (handler)The handler function that creates a label in a GitLab project.
export async function createLabel( projectId: string, 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 (!color?.trim()) { throw new Error("Label color is required"); } if (!color.match(/^#[0-9a-fA-F]{6}$/)) { throw new Error("Label color must be a valid hex color (e.g., #ff0000)"); } const endpoint = `/projects/${encodeProjectId(projectId)}/labels`; const label = await gitlabPost<GitLabLabelResponse>(endpoint, { name, color, description, priority }); return GitLabLabelSchema.parse(label); } - src/schemas.ts:290-296 (schema)The schema defining the input validation for the create_label tool.
export const CreateLabelSchema = z.object({ project_id: z.string(), name: z.string(), color: z.string(), description: z.string().optional(), priority: z.number().optional() }); - src/server.ts:115-118 (registration)Tool registration for create_label.
name: "create_label", description: "Create a new label in a GitLab project", inputSchema: zodToJsonSchema(CreateLabelSchema) },