Skip to main content
Glama
Beankeeper

Beankeeper

Official

rule_apply

Applies one or all active categorization rules to posted lines on a suspense or category account; dry run first, then commit atomic, audited, undoable moves.

Instructions

Apply one rule, or every active rule in priority order, to lines already posted on a category or suspense account within from and to. Rules are not applied to asset or liability accounts: those return RULE_STATEMENT_ACCOUNT; use txn_bulk_recategorize for lines sitting on one. A direction condition holds only for a line on the opposite side of the transaction's single bank-side line. Each line moves to the first firing rule's account through the audited recategorize path, then gets the rule's counterparty and project; lines already on the rule's account get only missing actions (actions_only). Lines a guard refuses, such as reconciled or closed-period lines, are left out and listed in blocked. Call with dry_run first and pass its selection_token, which covers each line's rule version, destination and actions. Applies atomically up to 500 selected lines. A move is dated on the line's date, or on the day the line's last move was undone when later (effect.move_date). receipt_id is the first move's receipt, which audit_undo reverses as a unit; with no move there is no batch receipt and no_batch_receipt is actions_only. Undo never removes counterparty links: it lists those made on moved lines in remaining_counterparty_links, not those on actions-only lines; change a link with counterparty_associate. A rule with actions needs counterparty and project access. Propose-only credentials return one pending proposal that freezes the planned moves.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "company": "<company>",
      "account": "<account>"
    },
    "name": "rule_apply"
  }
}

Input Schema

NameRequiredDescriptionDefault
toNoLast transaction date to match (inclusive).
fromNoFirst transaction date to match (inclusive).
ruleNoApply only this rule. Defaults to every active rule in priority order.
accountYesAccount holding the lines to categorize, usually suspense.
companyYes
dry_runNoValidate the batch and return the matched count, totals and a sample without writing.
on_conflictNo
selection_tokenNoThe `selection_token` from a dry run. If a line, its rule version, destination or actions changed, nothing is written and `SELECTION_CHANGED` is returned.
posting_referenceNoIdempotency reference for the batch. Use `on_conflict` "skip" for an exact retry.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv1.2.0

TDQS

A4.6/5.0
Behavior4/5

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

With only readOnlyHint=false supplied, the description carries the behavioral load and does so well: atomicity cap of 500 lines, blocked-line handling for reconciled/closed-period lines, move dating rules, receipt/undo semantics, remaining_counterparty_links, and propose-only pending proposals. The one gap is that on_conflict/posting_reference idempotency is only lightly covered, but the mutation behavior itself is richly disclosed.

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

Conciseness4/5

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

The core purpose is front-loaded and every sentence conveys substantive behavior rather than filler. It is a dense single block with many edge cases in sequence, so it is slightly harder to scan than an ideally structured definition, but nothing is wasteful.

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

Completeness5/5

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

For a complex 9-parameter mutation tool with no output schema, the description covers return semantics (blocked, receipt_id, no_batch_receipt, SELECTION_CHANGED), undo behavior, and permission requirements. An agent has what it needs to call it correctly.

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

Parameters4/5

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

At 78% schema coverage the baseline is 3, and the description adds genuine meaning: dry_run should precede the call and its selection_token captures rule version, destination and actions per line, and from/to bound the lines. on_conflict is left to the schema, keeping it just short of a 5.

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?

Opens with a specific verb and resource plus the exact scope: 'Apply one rule, or every active rule in priority order, to lines already posted on a category or suspense account within from and to.' It then explicitly distinguishes itself from txn_bulk_recategorize for the asset/liability case, so an agent can route without inspecting either schema.

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

Usage Guidelines5/5

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

Gives explicit alternatives and conditions: asset/liability accounts return RULE_STATEMENT_ACCOUNT and should use txn_bulk_recategorize instead, and it mandates calling with dry_run first then passing selection_token. It also points to counterparty_associate for changing links, covering when-not and sibling routing.

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

Deploy Server

Other Tools