create-label
Create custom labels on Trello boards to categorize and organize cards using specified names and colors for improved project management.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| boardId | Yes | ID of the board to create the label in | |
| name | Yes | Name of the label | |
| color | Yes | Color of the label |
Implementation Reference
- src/tools/labels.ts:18-54 (handler)Handler function that sends a POST request to the Trello API to create a new label on the specified board with given name and color.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 for the create-label tool using Zod validation.{ 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/types/common.ts:22-33 (schema)Zod enum schema defining valid Trello label colors, referenced in create-label tool schema.export const TrelloColorEnum = z.enum([ 'yellow', 'purple', 'blue', 'red', 'green', 'orange', 'black', 'sky', 'pink', 'lime', ]);
- src/tools/labels.ts:12-55 (registration)Registration of the 'create-label' tool on the MCP server within registerLabelsTools function.'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 which registers the create-label tool among others.registerLabelsTools(server, credentials);