update-label
Modify Trello label properties such as name and color using the specified label ID, enabling precise label management in project workflows.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| color | No | New color for the label (use "null" to remove color) | |
| labelId | Yes | ID of the label to update | |
| name | No | New name for the label |
Implementation Reference
- src/tools/labels.ts:266-315 (handler)Handler function that performs a PUT request to the Trello Labels API endpoint to update the specified label's name and/or color. Handles credentials check, constructs update data, sends request, and returns response or error.async ({ labelId, name, color }) => { try { if (!credentials.apiKey || !credentials.apiToken) { return { content: [ { type: 'text', text: 'Trello API credentials are not configured', }, ], isError: true, }; } const updateData: any = {}; if (name !== undefined) updateData.name = name; if (color !== undefined) updateData.color = color === 'null' ? null : color; const response = await fetch( `https://api.trello.com/1/labels/${labelId}?key=${credentials.apiKey}&token=${credentials.apiToken}`, { method: 'PUT', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify(updateData), } ); const data = await response.json(); return { content: [ { type: 'text', text: JSON.stringify(data), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error updating label: ${error}`, }, ], isError: true, }; } }
- src/tools/labels.ts:261-265 (schema)Zod input schema for the 'update-label' tool, defining required labelId and optional name/color parameters. Uses TrelloColorWithNullEnum for color validation.{ labelId: z.string().describe('ID of the label to update'), name: z.string().optional().describe('New name for the label'), color: TrelloColorWithNullEnum.optional().describe('New color for the label (use "null" to remove color)') },
- src/tools/labels.ts:259-316 (registration)Registration of the 'update-label' tool within the registerLabelsTools function using server.tool(). This is called from src/index.ts.server.tool( 'update-label', { labelId: z.string().describe('ID of the label to update'), name: z.string().optional().describe('New name for the label'), color: TrelloColorWithNullEnum.optional().describe('New color for the label (use "null" to remove color)') }, async ({ labelId, name, color }) => { try { if (!credentials.apiKey || !credentials.apiToken) { return { content: [ { type: 'text', text: 'Trello API credentials are not configured', }, ], isError: true, }; } const updateData: any = {}; if (name !== undefined) updateData.name = name; if (color !== undefined) updateData.color = color === 'null' ? null : color; const response = await fetch( `https://api.trello.com/1/labels/${labelId}?key=${credentials.apiKey}&token=${credentials.apiToken}`, { method: 'PUT', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify(updateData), } ); const data = await response.json(); return { content: [ { type: 'text', text: JSON.stringify(data), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error updating label: ${error}`, }, ], isError: true, }; } } );