trello_delete_card_attachment
Remove an attachment from a Trello card by providing the card ID and attachment ID.
Instructions
Delete an attachment from a Trello card.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| apiKey | No | Trello API key (optional if TRELLO_API_KEY env var is set) | |
| token | No | Trello API token (optional if TRELLO_TOKEN env var is set) | |
| cardId | Yes | ID or URL of the card (e.g. "abc123" or "https://trello.com/c/abc123/1-title") | |
| attachmentId | Yes | ID of the attachment to delete |
Implementation Reference
- src/tools/advanced.ts:1295-1335 (handler)The main handler function that executes the delete card attachment logic. Extracts credentials, validates params, calls TrelloClient.deleteCardAttachment(), and returns the result.
export async function handleTrelloDeleteCardAttachment(args: unknown) { try { const { credentials, params } = extractCredentials(args); const { cardId, attachmentId} = validateDeleteCardAttachment(params); const client = new TrelloClient(credentials); const response = await client.deleteCardAttachment(cardId, attachmentId); const result = { summary: `Deleted attachment ${attachmentId} from card ${cardId}`, cardId, attachmentId, rateLimit: response.rateLimit }; return { content: [ { type: 'text' as const, text: JSON.stringify(result, null, 2) } ] }; } catch (error) { const errorMessage = error instanceof z.ZodError ? formatValidationError(error) : error instanceof Error ? error.message : 'Unknown error occurred'; return { content: [ { type: 'text' as const, text: `Error deleting attachment: ${errorMessage}` } ], isError: true }; } } - src/tools/advanced.ts:85-93 (schema)Validation schema for the delete card attachment input using Zod. Validates cardId (Trello ID) and attachmentId (string).
const validateDeleteCardAttachment = (args: unknown) => { const schema = z.object({ cardId: trelloIdSchema, attachmentId: z.string().min(1, 'Attachment ID is required') }); return schema.parse(args); }; - src/tools/advanced.ts:1268-1293 (registration)Tool definition/registration object with name 'trello_delete_card_attachment', description, and inputSchema.
export const trelloDeleteCardAttachmentTool: Tool = { name: 'trello_delete_card_attachment', description: 'Delete an attachment from a Trello card.', inputSchema: { type: 'object', properties: { apiKey: { type: 'string', description: 'Trello API key (optional if TRELLO_API_KEY env var is set)' }, token: { type: 'string', description: 'Trello API token (optional if TRELLO_TOKEN env var is set)' }, cardId: { type: 'string', description: 'ID or URL of the card (e.g. "abc123" or "https://trello.com/c/abc123/1-title")' }, attachmentId: { type: 'string', description: 'ID of the attachment to delete' } }, required: ['cardId', 'attachmentId'] } }; - src/trello/client.ts:667-673 (helper)TrelloClient method that makes the actual DELETE API request to /cards/{cardId}/attachments/{attachmentId}.
async deleteCardAttachment(cardId: string, attachmentId: string): Promise<TrelloApiResponse<void>> { return this.makeRequest<void>( `/cards/${cardId}/attachments/${attachmentId}`, { method: 'DELETE' }, `Delete attachment ${attachmentId} from card ${cardId}` ); } - src/server.ts:110-120 (registration)Server registration: 'trello_delete_card_attachment' is listed in the WRITE_TOOL_NAMES set as a write tool.
const WRITE_TOOL_NAMES = new Set([ 'create_card', 'update_card', 'move_card', 'trello_archive_card', 'trello_add_comment', 'trello_create_list', 'trello_create_label', 'trello_update_label', 'trello_delete_label', 'trello_add_label_to_card', 'trello_remove_label_from_card', 'trello_add_member_to_card', 'trello_remove_member_from_card', 'trello_create_checklist', 'trello_update_checklist', 'trello_delete_checklist', 'trello_update_checklist_field', 'trello_create_check_item', 'trello_delete_check_item', 'trello_update_check_item', 'trello_create_card_attachment', 'trello_delete_card_attachment' ]);