create_label
Create GitHub labels to organize issues and pull requests by adding color-coded tags with descriptions for better project management.
Instructions
Create a new GitHub label
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| color | Yes | ||
| description | No |
Input Schema (JSON Schema)
{
"properties": {
"color": {
"type": "string"
},
"description": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"name",
"color"
],
"type": "object"
}
Implementation Reference
- Core handler implementation that uses GitHub GraphQL API to create a new repository label with the given name, color, and optional description.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); } }
- Zod schema defining input validation for the create_label tool: name (required string), color (6-digit hex), description (optional string).// Schema for create_label tool 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>;
- src/infrastructure/tools/ToolRegistry.ts:187-189 (registration)Registers the createLabelTool in the central ToolRegistry during initialization.// Register label tools this.registerTool(createLabelTool); this.registerTool(listLabelsTool);
- src/infrastructure/tools/ToolSchemas.ts:1231-1246 (registration)ToolDefinition object that defines the create_label tool's metadata, schema reference, and usage examples for registration.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/index.ts:314-315 (handler)MCP server dispatch handler that routes create_label tool calls to the ProjectManagementService.createLabel method.case "create_label": return await this.service.createLabel(args);