delete_txn
Delete a specific transaction by its ID to recalculate subsequent positions and average cost. Requires explicit user confirmation.
Instructions
Delete a single transaction by its id. The user must confirm — never call this without explicit instruction (e.g. "delete transaction #42"). Removing a transaction recalculates all subsequent positions/avg cost since holdings are derived from the log.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes |
Implementation Reference
- apps/mcp/src/tools/mutate.ts:75-85 (handler)The actual MCP tool handler for 'delete_txn'. It registers a server.tool with Zod schema (id: z.number().int().positive()), deletes from the transactions table using Drizzle ORM, and returns the deleted id or an error if not found.
server.tool( 'delete_txn', 'Delete a single transaction by its id. The user must confirm — never call this without explicit instruction (e.g. "delete transaction #42"). Removing a transaction recalculates all subsequent positions/avg cost since holdings are derived from the log.', { id: z.number().int().positive() }, async ({ id }) => { const db = getDb(); const res = db.delete(transactions).where(eq(transactions.id, id)).run(); if (res.changes === 0) return err(`Transaction #${id} not found`); return ok({ deleted: id }); }, ); - apps/mcp/src/tools/mutate.ts:75-85 (registration)The tool is registered via server.tool('delete_txn', ...) in the registerMutateTools function within mutate.ts.
server.tool( 'delete_txn', 'Delete a single transaction by its id. The user must confirm — never call this without explicit instruction (e.g. "delete transaction #42"). Removing a transaction recalculates all subsequent positions/avg cost since holdings are derived from the log.', { id: z.number().int().positive() }, async ({ id }) => { const db = getDb(); const res = db.delete(transactions).where(eq(transactions.id, id)).run(); if (res.changes === 0) return err(`Transaction #${id} not found`); return ok({ deleted: id }); }, ); - apps/mcp/src/tools/mutate.ts:77-78 (schema)The input schema for delete_txn: a single required parameter 'id' of type z.number().int().positive().
'Delete a single transaction by its id. The user must confirm — never call this without explicit instruction (e.g. "delete transaction #42"). Removing a transaction recalculates all subsequent positions/avg cost since holdings are derived from the log.', { id: z.number().int().positive() },