Skip to main content
Glama

Calculate Document Totals

calculate_totals
Read-onlyIdempotent

Compute subtotal, tax, discount, grand total, and balance due from document items. Stateless.

Example tool call

This call uses example arguments supplied in the tool’s input schema.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "document": {
        "items": [
          {
            "quantity": 2,
            "unit_price": 50,
            "description": "Service"
          }
        ]
      }
    },
    "name": "calculate_totals"
  }
}

Input Schema

NameRequiredDescriptionDefault
documentYesDocument JSON with items, tax_rate, discount_amount, and optional amount_paid.

Output Schema

NameRequiredDescriptionDefault
is_paidYesTrue when paid in full.
subtotalYesSubtotal before tax/discount.
tax_totalYesTax amount.
amount_paidYesAmount paid.
balance_dueYesRemaining balance due.
grand_totalYesPayable grand total.
discount_amountYesDiscount applied.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed9 schema fields changed
    • addedInput schema / examples
      Added value: +[
      +  {
      +    "document": {
      +      "items": [
      +        {
      +          "description": "Service",
      +          "quantity": 2,
      +          "unit_price": 50
      +        }
      +      ]
      +    }
      +  }
      +]
    • changedInput schema / properties / document / description
      Previous value: -"Input document JSON payload containing items, tax_rate, discount_amount, and optional amount_paid."New value: +"Document JSON with items, tax_rate, discount_amount, and optional amount_paid."
    • changedOutput schema / properties / amount_paid / description
      Previous value: -"Amount already paid toward the document."New value: +"Amount paid."
    • changedOutput schema / properties / balance_due / description
      Previous value: -"Remaining unpaid balance due."New value: +"Remaining balance due."
    • changedOutput schema / properties / discount_amount / description
      Previous value: -"Document-level discount applied."New value: +"Discount applied."
    • changedOutput schema / properties / grand_total / description
      Previous value: -"Total amount payable after tax and discount."New value: +"Payable grand total."
    • changedOutput schema / properties / is_paid / description
      Previous value: -"True when balance_due is zero."New value: +"True when paid in full."
    • changedOutput schema / properties / subtotal / description
      Previous value: -"Sum of line item amounts before tax and document discount."New value: +"Subtotal before tax/discount."
    • changedOutput schema / properties / tax_total / description
      Previous value: -"Calculated tax amount."New value: +"Tax amount."
  2. First observed

TDQS

A3.7/5.0
Behavior3/5

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

Annotations already declare readOnlyHint, idempotentHint, destructiveHint=false, and closed-world scope, so the safety profile is covered. The description adds "Stateless," which goes slightly beyond idempotency, but it says nothing about edge behavior — missing tax_rate or discount_amount, rounding/precision rules, or empty item lists.

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?

Two tight sentences with the computation described first and the statelessness caveat second. No filler, no restatement of the title.

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?

An output schema exists, so return values need no explanation, and the single nested parameter is documented. What's missing is handling policy for absent optional inputs (tax_rate, discount_amount) and numeric precision, which matter for a monetary calculator.

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?

Schema coverage is 100%, so the baseline is 3, but the description earns a step up by mapping computed outputs onto the document's inputs — tax from tax_rate, discount from discount_amount, balance due from amount_paid — giving the agent a semantic link the flat schema description alone does not make.

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

Purpose4/5

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

Names a specific verb (Compute) and enumerates the exact outputs (subtotal, tax, discount, grand total, balance due) from document items, so the agent knows precisely what it gets back. It does not, however, differentiate itself from siblings like preview_document or generate_document, which plausibly also surface totals.

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

Usage Guidelines3/5

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

"Stateless" implies the tool is a pure computation safe to call repeatedly and that nothing is persisted, which is useful usage context. But there is no explicit when-to-use vs. when-not, and no guidance on choosing it over preview_document or record_payment.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.