create_label
Generate and manage GitHub labels by defining name, color, and optional description, streamlining project organization and task categorization within GitHub Projects V2.
Instructions
Create a new GitHub label
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| color | Yes | ||
| description | No | ||
| name | Yes |
Implementation Reference
- The main handler function that executes the create_label tool logic using GitHub GraphQL API to create a new repository label.async createLabel(data: { name: string; color: string; description?: string; }): Promise<{ id: string; name: string; color: string; description: string }> { try { const mutation = ` mutation($input: CreateLabelInput!) { createLabel(input: $input) { label { id name color description } } } `; interface CreateLabelResponse { createLabel: { label: { id: string; name: string; color: string; description: string; } } } const response = await this.factory.graphql<CreateLabelResponse>(mutation, { input: { repositoryId: this.factory.getConfig().repo, name: data.name, color: data.color, description: data.description || '' } }); return response.createLabel.label; } catch (error) { throw this.mapErrorToMCPError(error); } }
- ToolDefinition for create_label including name, description, input schema (createLabelSchema), and usage examples.export const createLabelTool: ToolDefinition<CreateLabelArgs> = { name: "create_label", description: "Create a new GitHub label", schema: createLabelSchema as unknown as ToolSchema<CreateLabelArgs>, examples: [ { name: "Create bug label", description: "Create a red bug label", args: { name: "bug", color: "ff0000", description: "Something isn't working" } } ] };
- src/infrastructure/tools/ToolRegistry.ts:264-266 (registration)Registers the createLabelTool in the central ToolRegistry singleton during initialization.// Register label tools this.registerTool(createLabelTool); this.registerTool(listLabelsTool);
- src/index.ts:384-385 (registration)MCP server dispatches create_label calls to the ProjectManagementService.createLabel handler.case "create_label": return await this.service.createLabel(args);
- Zod schema for validating create_label input parameters: name (required string), color (6-digit hex), description (optional).export const createLabelSchema = z.object({ name: z.string().min(1, "Label name is required"), color: z.string().regex(/^[0-9a-fA-F]{6}$/, "Color must be a valid 6-digit hex color code without #"), description: z.string().optional(), }); export type CreateLabelArgs = z.infer<typeof createLabelSchema>;