get_labels
Fetch all test case labels for a project, returning their IDs and titles for use when creating or updating test cases.
Instructions
Get all available test case labels (sometimes called tags) for a project. Returns label IDs and titles that can be used when creating or updating test cases.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes | The ID of the project to retrieve labels for |
Implementation Reference
- src/tools/get_labels.ts:10-20 (handler)The get_labels tool definition containing the handler function that calls client.getLabels(project_id) and maps results through LabelSchema
export const getLabelsTool: ToolDefinition<typeof parameters, TestRailClient> = { name: "get_labels", description: "Get all available test case labels (sometimes called tags) for a project. Returns label IDs and titles that can be used when creating or updating test cases.", parameters, handler: async ({ project_id }, client) => { const labels = await client.getLabels(project_id); return { labels: labels.map(l => LabelSchema.parse(l)), }; }, }; - src/index.ts:75-75 (registration)Registration of getLabelsTool in the tools array used by the MCP server
getLabelsTool, - src/tools/get_labels.ts:6-8 (schema)Input parameter schema: project_id (number)
const parameters = { project_id: z.number().describe("The ID of the project to retrieve labels for"), }; - src/types/testrail.ts:32-37 (schema)LabelSchema Zod definition with id (number) and title (string), and Label type
export const LabelSchema = z.object({ id: z.number(), title: z.string(), }); export type Label = z.infer<typeof LabelSchema> - src/client/testrail.ts:167-170 (helper)Client method getLabels that calls the TestRail API endpoint /api/v2/get_labels/{projectId} and paginates results
async getLabels(projectId: number): Promise<Label[]> { const url = `${API_BASE_V2}/get_labels/${projectId}`; return this.paginateAll<Label>(url, 'labels'); }