Skip to main content
Glama

add-labels

Add labels to Trello cards to organize and categorize tasks for better project management workflow.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
itemsYes

Implementation Reference

  • Handler function that batch adds labels to multiple cards by iterating over 'items' array, calling Trello API POST /cards/{cardId}/idLabels for each, collecting results with Promise.all, and returning JSON stringified response or error.
    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=${credentials.apiKey}&token=${credentials.apiToken}`, { 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 with 'cardId' (string) and 'labelId' (string).
    { 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'), }) ), },
  • Direct registration of the 'add-labels' tool using server.tool(), providing name, input schema, and handler function within the registerLabelsTools 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=${credentials.apiKey}&token=${credentials.apiToken}`, { 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:91-91 (registration)
    Top-level call to registerLabelsTools in the main MCP server setup, which in turn registers the 'add-labels' tool among others.
    registerLabelsTools(server, credentials);

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/adriangrahldev/advanced-trello-mcp-server'

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