Skip to main content
Glama

Calculate

calculate
Read-only

Safely evaluate arithmetic expressions with +, -, *, /, //, %, **, and parentheses using an AST, without arbitrary code execution.

Instructions

Evaluate an arithmetic expression safely using abstract syntax tree (AST). Supports +, -, *, /, //, %, ** and parentheses. No arbitrary code execution.

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": {
      "expression": "<expression>"
    },
    "name": "calculate"
  }
}

Input Schema

NameRequiredDescriptionDefault
expressionYes

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A4.2/5.0
Behavior4/5

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

Annotations only declare readOnlyHint=true; the description adds the substantive behavioral fact that evaluation is AST-based and cannot execute arbitrary code, which is exactly the safety context an agent needs before passing user-supplied strings. It stops short of saying what happens on a malformed expression or a division by zero.

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 short sentences, zero filler, with the core action front-loaded and the supported-syntax constraint immediately after. Nothing repeats the schema or 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?

For a one-parameter tool with an output schema and readOnly annotation, the description covers purpose, safety profile, and accepted input grammar. Only edge-case behavior (invalid expression, overflow) is left unspecified, a minor gap.

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 0% and the single parameter is bare ('expression': string), so the description must carry the semantics — and it does, by defining the accepted grammar (+, -, *, /, //, %, **, parentheses). It adds no note on numeric formats or error returns, keeping it below 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?

Specific verb (evaluate) plus resource (arithmetic expression) plus mechanism (AST), and it enumerates the supported operator set and parentheses. No sibling in the catalog does arithmetic, so the tool is unmistakable from its first clause.

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?

Usage is only implied: an agent infers it should call this whenever arithmetic must be computed. There is no explicit when/when-not guidance and no named alternative, though the catalog offers no competing calculator to route away from.

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