Skip to main content
Glama

Calc Exact

calc_exact
Read-onlyIdempotent

Perform exact arithmetic with rationals and arbitrary precision to avoid floating-point errors. Ideal for verifying thresholds, ratios, and comparisons like 0.1+0.2 == 0.3.

Instructions

Use calc_exact, not evaluate_expression, for a literal arithmetic expression with no symbols in it. EXACT arithmetic: 0.1 + 0.2 == 0.3 is True here (False in plain Python).

Everything is an exact rational, integers are arbitrary precision. Supports

      • / // % ** comparisons, bitwise ops (& | ^ << >> ~) on integers, and whitelisted math functions (sqrt, log, sin, ...) plus pi/e/tau. Use BEFORE asserting any computed number: thresholds, ratios, overflows, 'X is N% of Y'. Examples: '2**64 - 1', 'comb(52,5)', '0.1+0.2 == 0.3', '0xff & 0x0f'.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
exprYesLiteral arithmetic expression with no symbols, e.g. '2**64 - 1', 'comb(52,5)', '0.1+0.2 == 0.3'

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.12.0
    • addedInput schema / properties / expr / description
      Added value: +"Literal arithmetic expression with no symbols, e.g. '2**64 - 1', 'comb(52,5)', '0.1+0.2 == 0.3'"
  2. Changed1 schema field changedv0.11.0
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "additionalProperties": true,
      +  "title": "calc_exactDictOutput",
      +  "type": "object"
      +}
  3. Changed4 schema fields changedv0.2.0
    • removedInput schema / additionalProperties
      Removed value: -false
    • addedInput schema / properties / expr / title
      Added value: +"Expr"
    • addedInput schema / title
      Added value: +"calc_exactArguments"
    • changedOutput schema / (root)
      Previous value: -{
      -  "additionalProperties": true,
      -  "type": "object"
      -}New value: +null
  4. First observedv0.1.0

TDQS

A4.9/5.0
Behavior5/5

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

The description discloses key behavioral differences from plain Python: exact decimal arithmetic ('0.1 + 0.2 == 0.3' is True), arbitrary precision integers, supported operations, and math functions. These are not implied by the annotations (readOnlyHint: true, idempotentHint: true) and are essential for an agent to predict results correctly.

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 critical guidance is front-loaded with the 'not evaluate_expression' contrast, and the rest is dense but purposeful. The example list and supported-operator inventory are useful; only slight redundancy exists between 'EXACT arithmetic' and the later mention of exact rationals.

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?

The description fully equips an agent to use the tool correctly: it explains when to use it, what input restrictions apply, what arithmetic guarantees are provided, common use cases, and concrete examples. Combined with the output schema and safe read-only annotations, nothing essential is missing for correct invocation.

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

Parameters5/5

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

Although the schema already describes the expr parameter with example strings, the description significantly expands its semantics by defining what constitutes a valid expression ('literal expression with no symbols'), explaining exact rational behavior, and enumerating supported operators and functions. This goes well beyond the schema's baseline coverage.

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 opens with a specific directive: use calc_exact, not evaluate_expression, for a literal arithmetic expression with no symbols. It names the resource (literal arithmetic expressions), the verb (calculate exactly), and explicitly distinguishes itself from its sibling tool.

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?

The description explicitly contrasts calc_exact with evaluate_expression and specifies when to choose it: 'Use BEFORE asserting any computed number: thresholds, ratios, overflows, 'X is N% of Y''. This gives clear, actionable selection criteria beyond generic tool descriptions.

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