delete_invoice
Permanently delete an invoice and all associated billing data. This action cannot be undone.
Instructions
Delete an invoice permanently. This action cannot be undone and will remove all associated billing data.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| invoice_id | Yes | The ID of the invoice to delete |
Implementation Reference
- src/tools/invoices.ts:94-112 (handler)The DeleteInvoiceHandler class that executes the delete_invoice tool logic. It validates the invoice_id input, calls harvestClient.deleteInvoice(), and returns a success message.
class DeleteInvoiceHandler implements ToolHandler { constructor(private readonly config: BaseToolConfig) {} async execute(args: Record<string, any>): Promise<CallToolResult> { try { const inputSchema = z.object({ invoice_id: z.number().int().positive() }); const { invoice_id } = validateInput(inputSchema, args, 'delete invoice'); logger.info('Deleting invoice via Harvest API', { invoiceId: invoice_id }); await this.config.harvestClient.deleteInvoice(invoice_id); return { content: [{ type: 'text', text: JSON.stringify({ message: `Invoice ${invoice_id} deleted successfully` }, null, 2) }], }; } catch (error) { return handleMCPToolError(error, 'delete_invoice'); } } } - src/tools/invoices.ts:203-217 (registration)The tool registration entry for 'delete_invoice' that defines its name, description, inputSchema, and handler.
{ tool: { name: 'delete_invoice', description: 'Delete an invoice permanently. This action cannot be undone and will remove all associated billing data.', inputSchema: { type: 'object', properties: { invoice_id: { type: 'number', description: 'The ID of the invoice to delete' }, }, required: ['invoice_id'], additionalProperties: false, }, }, handler: new DeleteInvoiceHandler(config), }, - src/tools/invoices.ts:207-213 (schema)The input schema for the delete_invoice tool - requires a single invoice_id field of type number.
inputSchema: { type: 'object', properties: { invoice_id: { type: 'number', description: 'The ID of the invoice to delete' }, }, required: ['invoice_id'], additionalProperties: false, - The invoices client method that actually makes the HTTP DELETE request to the Harvest API at /invoices/{invoiceId}.
async deleteInvoice(invoiceId: number): Promise<void> { try { this.logger.debug('Deleting invoice', { invoiceId }); await this.client.delete(`/invoices/${invoiceId}`); this.logger.info('Successfully deleted invoice', { invoiceId }); } catch (error) { this.logger.error('Failed to delete invoice', { invoiceId, error: (error as Error).message }); throw error; } } - src/client/harvest-api.ts:255-257 (helper)The Harvest API wrapper method that delegates deleteInvoice to the invoices client.
async deleteInvoice(invoiceId: number): Promise<void> { return this.invoicesClient.deleteInvoice(invoiceId); }