create-labels
Generate and manage custom labels in Trello boards to improve task organization. Define label names and colors for enhanced project tracking and categorization.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| labels | Yes |
Implementation Reference
- src/tools/labels.ts:113-153 (handler)The handler function for the 'create-labels' tool, which batch-creates labels on Trello boards by making concurrent POST requests to the Trello API for each label in the input array.async ({ labels }) => { try { const results = await Promise.all( labels.map(async (label) => { 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: label.name, color: label.color, idBoard: label.boardId, }), } ); return await response.json(); }) ); return { content: [ { type: 'text', text: JSON.stringify(results), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error creating labels: ${error}`, }, ], isError: true, }; } }
- src/tools/labels.ts:104-112 (schema)The Zod input schema for the 'create-labels' tool, accepting an array of objects each containing boardId, name, and color for the labels to create.{ labels: z.array( z.object({ 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:102-154 (registration)The MCP server.tool() call that registers the 'create-labels' tool, specifying its name, input schema, and handler function.server.tool( 'create-labels', { labels: z.array( z.object({ 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 ({ labels }) => { try { const results = await Promise.all( labels.map(async (label) => { 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: label.name, color: label.color, idBoard: label.boardId, }), } ); return await response.json(); }) ); return { content: [ { type: 'text', text: JSON.stringify(results), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error creating labels: ${error}`, }, ], isError: true, }; } } );
- src/index.ts:91-91 (registration)Invocation of registerLabelsTools in the main server setup, which includes registration of the 'create-labels' tool among others.registerLabelsTools(server, credentials);