add-comment
Add comments to Trello cards using a structured input format with card ID and text, enabling precise communication and task updates within project workflows.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cardId | Yes | ID of the card to comment on | |
| text | Yes | Comment text |
Implementation Reference
- src/tools/cards.ts:245-292 (handler)Executes the 'add-comment' tool by posting a comment to the Trello card API endpoint using the provided credentials.async ({ cardId, text }) => { try { if (!credentials.apiKey || !credentials.apiToken) { return { content: [ { type: 'text', text: 'Trello API credentials are not configured', }, ], isError: true, }; } const response = await fetch( `https://api.trello.com/1/cards/${cardId}/actions/comments?key=${credentials.apiKey}&token=${credentials.apiToken}`, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ text, }), } ); const data = await response.json(); return { content: [ { type: 'text', text: JSON.stringify(data), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error adding comment: ${error}`, }, ], isError: true, }; } } );
- src/tools/cards.ts:241-244 (schema)Zod schema defining the input parameters: cardId (string) and text (string) for the 'add-comment' tool.{ cardId: z.string().describe('ID of the card to comment on'), text: z.string().describe('Comment text'), },
- src/tools/cards.ts:239-293 (registration)Registers the 'add-comment' tool on the MCP server with its schema and handler function.server.tool( 'add-comment', { cardId: z.string().describe('ID of the card to comment on'), text: z.string().describe('Comment text'), }, async ({ cardId, text }) => { try { if (!credentials.apiKey || !credentials.apiToken) { return { content: [ { type: 'text', text: 'Trello API credentials are not configured', }, ], isError: true, }; } const response = await fetch( `https://api.trello.com/1/cards/${cardId}/actions/comments?key=${credentials.apiKey}&token=${credentials.apiToken}`, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ text, }), } ); const data = await response.json(); return { content: [ { type: 'text', text: JSON.stringify(data), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error adding comment: ${error}`, }, ], isError: true, }; } } );