list_labels
Retrieve all GitHub labels to organize issues and pull requests, enabling efficient project management and categorization within repositories.
Instructions
List all GitHub labels
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No |
Input Schema (JSON Schema)
{
"properties": {
"limit": {
"type": "string"
}
},
"required": [],
"type": "object"
}
Implementation Reference
- Core handler function that executes the list_labels tool by querying the GitHub GraphQL API to fetch repository labels with optional limit.async listLabels(data: { limit?: number; }): Promise<Array<{ id: string; name: string; color: string; description: string }>> { try { const limit = data.limit || 100; const query = ` query($owner: String!, $repo: String!, $limit: Int!) { repository(owner: $owner, name: $repo) { labels(first: $limit) { nodes { id name color description } } } } `; interface ListLabelsResponse { repository: { labels: { nodes: Array<{ id: string; name: string; color: string; description: string; }> } } } const response = await this.factory.graphql<ListLabelsResponse>(query, { owner: this.factory.getConfig().owner, repo: this.factory.getConfig().repo, limit }); if (!response.repository?.labels?.nodes) { return []; } return response.repository.labels.nodes; } catch (error) { throw this.mapErrorToMCPError(error); } }
- Zod schema definition for list_labels tool input validation, defining optional limit parameter.// Schema for list_labels tool export const listLabelsSchema = z.object({ limit: z.number().int().positive().default(100).optional(), }); export type ListLabelsArgs = z.infer<typeof listLabelsSchema>;
- src/infrastructure/tools/ToolRegistry.ts:189-189 (registration)Registers the listLabelsTool in the central ToolRegistry singleton.this.registerTool(listLabelsTool);
- src/index.ts:317-318 (registration)MCP server request handler dispatches call_tool requests for list_labels to the ProjectManagementService.listLabels method.case "list_labels": return await this.service.listLabels(args);
- ToolDefinition export including name, description, schema reference, and usage examples for list_labels.export const listLabelsTool: ToolDefinition<ListLabelsArgs> = { name: "list_labels", description: "List all GitHub labels", schema: listLabelsSchema as unknown as ToolSchema<ListLabelsArgs>, examples: [ { name: "List all labels", description: "Get all repository labels", args: { limit: 50 } } ] };