Skip to main content
Glama

calculate_expression

Read-onlyIdempotent

Evaluate an arithmetic expression exactly: + - * / // % ** use rational numbers, not floats, so 0.1 + 0.2 = 0.3, and money strings like "$1,200.50" read as numbers. Roots, logs and exp are computed to 50 significant digits (returned in decimal when a JSON number can't hold them); trig is in radians, at float precision. Use this instead of doing math in your head; use calculate_date for anything with dates or times, and run_op("stats") to summarize a column of data. Pure computation: no network, same answer every time. Unknown names, syntax errors and results over 5,000 digits are refused with a suggested fix. Example: expr="price * qty * (1 + tax/100)", vars={"price": "$19.99", "qty": 3, "tax": 8.25}, places=2 gives 64.92.

Input Schema

NameRequiredDescriptionDefault
exprYesPython-style arithmetic; ** is power (^ is refused). Functions: pct(p, x) = p% of x, pct_change(old, new) = (new - old) / old * 100, round(x, places) half-up, floor, ceil, int, abs, sqrt, exp, ln, log(x) natural or log(x, base), log10, log2, pow, factorial, gcd, lcm, comb(n, k), perm(n, k), sin, cos, tan, asin, acos, atan, atan2(y, x), sum, mean, median, min, max. Constants: pi, e, tau, true, false.
varsNoValues for the names used in expr: numbers or numeric strings like "$1,200.50". Any name in expr must be here.
placesNoRound the result to this many decimals, half-up.

Output Schema

NameRequiredDescriptionDefault
exactNoEvery digit of an integer too large for a JSON number.
valueYesThe result: a number, or true/false for comparisons.
decimalNoUp to 50 significant digits, when value (a JSON number) holds fewer.
fractionNoThe exact fraction of a repeating decimal, like 1/3.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Added

TDQS

A4.8/5.0
Behavior5/5

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

Annotations already cover the safety profile (readOnly, idempotent, non-destructive, closed-world), so the description is free to add the traits that actually matter here: exact-vs-float semantics, 50-significant-digit precision for roots/logs/exp with decimal fallback, radians for trig at float precision, deterministic/pure execution, and the three refusal conditions (unknown names, syntax errors, >5,000 digit results) each returning a suggested fix.

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?

Front-loaded with purpose and numeric semantics, then routing, then safety, then error behavior, then a worked example — a sound information hierarchy. It is dense (roughly 120 words) and duplicates a few details the schema already carries, such as the money-string coercion and the function catalogue, but every sentence contributes something.

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?

An output schema exists, so return formatting need not be explained; the description instead covers the gaps that schema cannot: numeric representation (rational vs float vs decimal string), precision bounds, units for trig, error/refusal behavior, and determinism. Nothing an agent needs to call this correctly is missing.

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 extra by disambiguating parameter interaction rather than restating fields: it states that every name in expr must appear in vars, that money strings like "$1,200.50" are coerced to numbers, and it supplies a worked example tying expr + vars + places together into a concrete result.

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+resource ('Evaluate an arithmetic expression exactly') and immediately pins the semantic regime: exact rational arithmetic, not floating point. It names its neighbors (calculate_date, run_op) explicitly, so an agent can route without opening any 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 positive usage ('use this instead of doing math in your head') and explicit exclusions with the alternative for each: calculate_date for anything with dates/times, run_op("stats") to summarize a column of data. This is exactly the when/when-not/alternatives pattern.

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.

Resources