get-label
Retrieve specific Trello label details by ID to access color, name, and board information for project organization.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| labelId | Yes | ID of the label to retrieve | |
| fields | No | Comma-separated list of fields to include |
Implementation Reference
- src/tools/labels.ts:214-255 (handler)The handler function for the 'get-label' tool. It retrieves a specific Trello label by its ID using the Trello API, with optional fields parameter, handles credentials check, makes a GET request, and returns the JSON data or error.async ({ labelId, fields }) => { try { if (!credentials.apiKey || !credentials.apiToken) { return { content: [ { type: 'text', text: 'Trello API credentials are not configured', }, ], isError: true, }; } const url = new URL(`https://api.trello.com/1/labels/${labelId}`); url.searchParams.append('key', credentials.apiKey); url.searchParams.append('token', credentials.apiToken); if (fields) url.searchParams.append('fields', fields); const response = await fetch(url.toString()); const data = await response.json(); return { content: [ { type: 'text', text: JSON.stringify(data), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error getting label: ${error}`, }, ], isError: true, }; } }
- src/tools/labels.ts:210-213 (schema)Zod input schema for 'get-label' tool: labelId (string, required), fields (string, optional).{ labelId: z.string().describe('ID of the label to retrieve'), fields: z.string().optional().describe('Comma-separated list of fields to include') },
- src/tools/labels.ts:208-256 (registration)Registration of the 'get-label' tool using server.tool(), including the tool name, schema, and handler function.server.tool( 'get-label', { labelId: z.string().describe('ID of the label to retrieve'), fields: z.string().optional().describe('Comma-separated list of fields to include') }, async ({ labelId, fields }) => { try { if (!credentials.apiKey || !credentials.apiToken) { return { content: [ { type: 'text', text: 'Trello API credentials are not configured', }, ], isError: true, }; } const url = new URL(`https://api.trello.com/1/labels/${labelId}`); url.searchParams.append('key', credentials.apiKey); url.searchParams.append('token', credentials.apiToken); if (fields) url.searchParams.append('fields', fields); const response = await fetch(url.toString()); const data = await response.json(); return { content: [ { type: 'text', text: JSON.stringify(data), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error getting label: ${error}`, }, ], isError: true, }; } } );