Skip to main content
Glama

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

TableJSON Schema
NameRequiredDescriptionDefault
periodYesYYYY-MM
typeNoRequired when category is provided
sub_typeNoRequired when category is provided
categoryNoSpecific category — if omitted, deletes all entries for the period

Implementation Reference

  • 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 });
      },
    );
  • 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'),
    },
  • Registration of the 'delete_balance' tool using server.tool() inside registerMutateTools(), with the description shown to the LLM.
    server.tool(
      'delete_balance',
  • 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}.`);
    };
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description explains the conditional deletion behavior but does not disclose that deletion is irreversible, what permissions are required, or what happens if the period has no entries. With no annotations, the description carries the full burden, and while it covers the core behavior, it lacks depth on consequences.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, well-structured sentence. It front-loads the purpose and then adds the conditional logic efficiently. Every word serves a purpose with no redundancy or fluff.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description adequately explains the input behavior for a delete operation. However, it does not mention what the tool returns (e.g., success message, count of deleted items) or any error conditions. Without an output schema, this information would be helpful for completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema already has 100% coverage for all parameter descriptions. The description reinforces the conditional logic but does not add substantial new information beyond what the schema provides. The explanation of category omission is already in the schema's description field.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb (delete) and resource (balance entries), specifies the period context, and distinguishes from sibling delete tools by focusing on balance entries. It also explains the conditional behavior with category.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear guidance on when to include or omit the category parameter, effectively telling the agent how to delete a single entry vs all entries for a period. However, it does not explicitly mention when not to use the tool or suggest alternatives, though the deletion context is implicit from the tool name and siblings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/evan-moon/firma'

If you have feedback or need assistance with the MCP directory API, please join our Discord server