add-labels
Add labels to Trello cards to organize and categorize tasks. Specify card and label IDs to apply visual markers for tracking work status or priorities.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| items | Yes |
Implementation Reference
- src/index.ts:601-640 (handler)Handler function that adds specified labels to Trello cards using the Trello API by making POST requests for each item.async ({ items }) => { try { const results = await Promise.all( items.map(async (item) => { const response = await fetch( `https://api.trello.com/1/cards/${item.cardId}/idLabels?key=${trelloApiKey}&token=${trelloApiToken}`, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ value: item.labelId, }), } ); return await response.json(); }) ); return { content: [ { type: 'text', text: JSON.stringify(results), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error adding labels to cards: ${error}`, }, ], isError: true, }; } } );
- src/index.ts:593-600 (schema)Zod schema defining the input as an array of objects containing cardId and labelId for the add-labels tool.{ items: z.array( z.object({ cardId: z.string().describe('ID of the card to add the label to'), labelId: z.string().describe('ID of the label to add'), }) ), },
- src/index.ts:591-641 (registration)Registers the 'add-labels' MCP tool using server.tool(), including inline schema and handler.server.tool( 'add-labels', { items: z.array( z.object({ cardId: z.string().describe('ID of the card to add the label to'), labelId: z.string().describe('ID of the label to add'), }) ), }, async ({ items }) => { try { const results = await Promise.all( items.map(async (item) => { const response = await fetch( `https://api.trello.com/1/cards/${item.cardId}/idLabels?key=${trelloApiKey}&token=${trelloApiToken}`, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ value: item.labelId, }), } ); return await response.json(); }) ); return { content: [ { type: 'text', text: JSON.stringify(results), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error adding labels to cards: ${error}`, }, ], isError: true, }; } } );