delete_balance
Remove balance entries for a given period. Optionally delete a single category entry by specifying type, sub_type, and category; otherwise, all entries for the period are removed.
Instructions
Delete balance entries for a period. If category is provided, only that single entry is removed; otherwise all entries for the period are deleted.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| period | Yes | YYYY-MM | |
| type | No | Required when category is provided | |
| sub_type | No | Required when category is provided | |
| category | No | Specific category — if omitted, deletes all entries for the period |
Implementation Reference
- apps/mcp/src/tools/mutate.ts:484-507 (handler)The main handler function for the 'delete_balance' MCP tool. It deletes balance entries from the database: if a 'category' is provided, it deletes a single entry matching period/type/sub_type/category; otherwise it deletes all entries for the given period. Returns the count of deleted rows.
async ({ period, type, sub_type, category }) => { const db = getDb(); if (category) { if (!type || !sub_type) return err('type and sub_type are required when category is provided'); const res = db .delete(balanceEntries) .where( and( eq(balanceEntries.period, period), eq(balanceEntries.type, type), eq(balanceEntries.sub_type, sub_type), eq(balanceEntries.category, category), ), ) .run(); if (res.changes === 0) return err(`No balance entry matched`); return ok({ deleted: res.changes, period, category }); } const res = db.delete(balanceEntries).where(eq(balanceEntries.period, period)).run(); if (res.changes === 0) return err(`No balance entries for ${period}`); return ok({ deleted: res.changes, period }); }, ); - apps/mcp/src/tools/mutate.ts:475-483 (schema)Zod schema defining the input parameters for delete_balance: period (required, YYYY-MM), type (optional 'asset'|'liability'), sub_type (optional string), category (optional string). type and sub_type are required when category is provided.
{ period: z.string().describe('YYYY-MM'), type: z.enum(['asset', 'liability']).optional().describe('Required when category is provided'), sub_type: z.string().optional().describe('Required when category is provided'), category: z .string() .optional() .describe('Specific category — if omitted, deletes all entries for the period'), }, - apps/mcp/src/tools/mutate.ts:472-473 (registration)Registration of the 'delete_balance' tool using server.tool() inside registerMutateTools(), with the description shown to the LLM.
server.tool( 'delete_balance', - apps/mcp/src/index.ts:21-21 (registration)Top-level registration: registerMutateTools(server) is called during server setup, which registers all mutate tools including delete_balance.
registerMutateTools(server); - CLI counterpart: deleteBalanceCommand in the CLI app. Interactively prompts the user to confirm deletion of all balance entries for a period, then calls repo.balance.deleteByPeriod(). This is not the MCP tool itself but a parallel implementation for the CLI.
export const deleteBalanceCommand = async (periodArg?: string) => { const repo = getRepository(); const periods = repo.balance.getPeriods(); const period = resolvePeriod(periodArg, periods, 'balance') ?? (await pickPeriod('Select period to delete', periods)); const entries = repo.balance.getByPeriod(period); const totalAssets = entries.filter((e) => e.type === 'asset').reduce((s, e) => s + e.amount, 0); const totalLiabilities = entries .filter((e) => e.type === 'liability') .reduce((s, e) => s + e.amount, 0); log.message( [ `${pc.dim('Period:')} ${period}`, `${pc.dim('Entries:')} ${entries.length}`, `${pc.dim('Assets:')} ${totalAssets.toLocaleString('en-US')} KRW`, `${pc.dim('Liabilities:')} ${totalLiabilities.toLocaleString('en-US')} KRW`, ].join('\n'), ); const ok = guard( await confirm({ message: `Delete all balance entries for ${period}?`, initialValue: false, }), ) as boolean; if (!ok) { cancel('Cancelled'); return; } const deleted = repo.balance.deleteByPeriod(period); log.success(`Deleted ${deleted} balance entr${deleted === 1 ? 'y' : 'ies'} for ${period}.`); };