Skip to main content
Glama

add-labels

Add labels to Trello cards using their IDs to organize and categorize tasks on your board.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
itemsYes

Implementation Reference

  • Handler function that batches adding labels to multiple Trello cards by making POST requests to the Trello API's /cards/{cardId}/idLabels endpoint for each item and returns the results.
    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, }; } }
  • Zod input schema defining an array of objects, each containing 'cardId' and 'labelId' for adding labels to cards.
    { 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-640 (registration)
    MCP server.tool registration for the 'add-labels' tool, specifying the name, input schema, and handler function.
    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, }; } } );

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/praveencs87/trello-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server