add-comment
Add comments to Trello cards using card ID and text to provide updates, feedback, or notes directly within your Trello board.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cardId | Yes | ID of the card to comment on | |
| text | Yes | Comment text |
Implementation Reference
- src/index.ts:292-326 (handler)The handler function that adds a comment to a specified Trello card by posting to the Trello API endpoint /cards/{cardId}/actions/comments, handling errors and returning JSON response.async ({ cardId, text }) => { try { const response = await fetch( `https://api.trello.com/1/cards/${cardId}/actions/comments?key=${trelloApiKey}&token=${trelloApiToken}`, { 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/index.ts:288-291 (schema)Zod input schema defining parameters: cardId (string, ID of the card) and text (string, comment text).{ cardId: z.string().describe('ID of the card to comment on'), text: z.string().describe('Comment text'), },
- src/index.ts:286-327 (registration)Registers the 'add-comment' tool on the MCP server, specifying the tool name, input 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 { const response = await fetch( `https://api.trello.com/1/cards/${cardId}/actions/comments?key=${trelloApiKey}&token=${trelloApiToken}`, { 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, }; } } );