create-label
Create custom labels in Trello boards by specifying board ID, label name, and color. Enhance organization and categorization of tasks within your Trello projects.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| boardId | Yes | ID of the board to create the label in | |
| color | Yes | Color of the label | |
| name | Yes | Name of the label |
Implementation Reference
- src/tools/labels.ts:18-54 (handler)Handler function that executes the logic for creating a Trello label via API POST request.async ({ boardId, name, color }) => { try { const response = await fetch( `https://api.trello.com/1/labels?key=${credentials.apiKey}&token=${credentials.apiToken}`, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ name, color, idBoard: boardId, }), } ); const data = await response.json(); return { content: [ { type: 'text', text: JSON.stringify(data), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error creating label: ${error}`, }, ], isError: true, }; } }
- src/tools/labels.ts:13-17 (schema)Input schema using Zod for validating boardId, name, and color parameters.{ boardId: z.string().describe('ID of the board to create the label in'), name: z.string().describe('Name of the label'), color: TrelloColorEnum.describe('Color of the label'), },
- src/tools/labels.ts:12-55 (registration)Direct registration of the 'create-label' tool using server.tool() within registerLabelsTools.'create-label', { boardId: z.string().describe('ID of the board to create the label in'), name: z.string().describe('Name of the label'), color: TrelloColorEnum.describe('Color of the label'), }, async ({ boardId, name, color }) => { try { const response = await fetch( `https://api.trello.com/1/labels?key=${credentials.apiKey}&token=${credentials.apiToken}`, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ name, color, idBoard: boardId, }), } ); const data = await response.json(); return { content: [ { type: 'text', text: JSON.stringify(data), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error creating label: ${error}`, }, ], isError: true, }; } } );
- src/index.ts:91-91 (registration)Invocation of registerLabelsTools in the main index file, which registers all label tools including 'create-label'.registerLabelsTools(server, credentials);