delete_snapshot
Remove all portfolio snapshot records for a specific date. Use this to delete an incorrect or unwanted snapshot from the asset tracker.
Instructions
Delete all portfolio snapshot rows for a given date (YYYY-MM-DD). Use only when the user explicitly asks to remove a bad snapshot — destructive.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| date | Yes | Snapshot date (YYYY-MM-DD) |
Implementation Reference
- apps/mcp/src/tools/snapshot.ts:63-73 (handler)The handler/execution logic for the 'delete_snapshot' tool. It accepts a date string, deletes all portfolio snapshot rows for that date from the database using drizzle-orm, and returns the count of deleted rows.
server.tool( 'delete_snapshot', 'Delete all portfolio snapshot rows for a given date (YYYY-MM-DD). Use only when the user explicitly asks to remove a bad snapshot — destructive.', { date: z.string().describe('Snapshot date (YYYY-MM-DD)') }, async ({ date }) => { const db = getDb(); const res = db.delete(portfolioSnapshots).where(eq(portfolioSnapshots.date, date)).run(); if (res.changes === 0) return err(`No snapshot found for ${date}`); return ok({ deleted: res.changes, date }); }, ); - apps/mcp/src/tools/snapshot.ts:65-66 (schema)Input schema for delete_snapshot: requires a single 'date' string parameter (YYYY-MM-DD format), validated with Zod.
'Delete all portfolio snapshot rows for a given date (YYYY-MM-DD). Use only when the user explicitly asks to remove a bad snapshot — destructive.', { date: z.string().describe('Snapshot date (YYYY-MM-DD)') }, - apps/mcp/src/index.ts:22-22 (registration)Registration of the registerSnapshotTools function which registers all snapshot tools including delete_snapshot on the MCP server.
registerSnapshotTools(server); - apps/mcp/src/tools/snapshot.ts:8-8 (registration)The registerSnapshotTools function that registers delete_snapshot (along with other snapshot tools) on the McpServer via server.tool().
export function registerSnapshotTools(server: McpServer): void { - The CLI-side deleteSnapshotCommand (separate from the MCP tool) which provides an interactive prompt for deleting a snapshot. Not the MCP tool implementation but a related command-line version.
export const deleteSnapshotCommand = async (dateArg?: string) => { const repo = getRepository(); const dates = repo.snapshots.getDates(); if (dates.length === 0) { log.warn('No snapshots to delete.'); return; } let date: string; if (dateArg) { if (!/^\d{4}-\d{2}-\d{2}$/.test(dateArg)) { log.error(`Invalid date "${dateArg}". Use YYYY-MM-DD format.`); process.exit(1); } if (!dates.includes(dateArg)) { log.error(`No snapshot for ${dateArg}.`); process.exit(1); } date = dateArg; } else { date = guard( await select({ message: 'Select snapshot date to delete', options: dates.map((d) => ({ value: d, label: d })), }), ) as string; } const entries = repo.snapshots.getByDate(date); const totalMV = entries.reduce((s, e) => s + e.current_price * e.shares, 0); log.message( [ `${pc.dim('Date:')} ${date}`, `${pc.dim('Holdings:')} ${entries.length}`, `${pc.dim('Total MV:')} $${totalMV.toFixed(2)}`, ].join('\n'), ); const ok = guard( await confirm({ message: `Delete all ${entries.length} snapshot entries for ${date}?`, initialValue: false, }), ) as boolean; if (!ok) { cancel('Cancelled'); return; } const deleted = repo.snapshots.deleteByDate(date); log.success(`Deleted ${deleted} snapshot entr${deleted === 1 ? 'y' : 'ies'} for ${date}.`); };