Skip to main content
Glama

calculate

Run math expression batches with variables, constants, and seeded RNG — no ComfyUI connection or eval required. Provides exact results for ASCII-safe arithmetic.

Instructions

Evaluate a batch of math expressions exactly — no ComfyUI connection needed, so it works even in cloud mode or when ComfyUI is down. A safe, zero-dependency expression evaluator (no eval): numbers only, no strings/arrays/property access. Handy for the arithmetic agents get wrong token-by-token.

Each line is one expression. name = expr assigns a variable that persists into later lines. Lines are separated by newlines or semicolons ONLY — commas are argument separators (e.g. min(a, b)), never expression separators.

Operators: + - * / // (floor div) % (modulo) ** (power, right-assoc), comparisons < <= > >= == != (return 1/0), unary minus. Constants: pi, e, tau. Functions: abs round min max pow sqrt floor ceil sin cos tan asin acos atan atan2 sinh cosh tanh exp log log10 log2 hypot radians degrees sign trunc clamp(x,lo,hi), plus seeded RNG rand() random() uniform(a,b) randint(a,b) (inclusive). Pass seed for reproducible RNG; it is echoed back when omitted.

Examples: • SDXL-legal resolution from an aspect ratio, snapped to /64: variables={ar: 1.5}; spec="w = floor(sqrt(10241024ar)/64)64\nh = floor(sqrt(10241024/ar)/64)64" • Reproducible seed batch (one 32-bit seed per line): spec="randint(0, 232-1)\nrandint(0, 232-1)\nrandint(0, 2**32-1)", seed=42 • CFG sweep: spec="3 + 00.5\n3 + 10.5\n3 + 20.5\n3 + 3*0.5"

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
seedNoSeed for rand()/uniform(a,b)/randint(a,b). Same seed => identical sequence (mulberry32). Omit for a random seed (echoed in the result).
specYesExpressions to evaluate, separated by newlines/semicolons (string) or one per array item. `name = expr` assigns; assignments persist across subsequent lines. NOTE: comma is an argument separator (min(a,b)), NOT an expression separator.
variablesNoInitial variable environment, e.g. {"w": 1024, "ar": 1.5}.
Behavior5/5

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

With no annotations, the description fully discloses behavior: safe zero-dependency evaluator (no eval), numbers-only restriction, batch semantics, variable assignment persistence, separator rules (including the comma caveat), full operator/function list, and RNG seeding behavior (seed echoed back). This goes far beyond basic disclosure.

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?

The description is long but every section earns its place: purpose, safety, syntax, operators/functions, and three practical examples. It is front-loaded with the core purpose and uses clear formatting (paragraphs, ells, code blocks) to remain scannable despite its length.

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?

The description richly covers the input side—syntax, operators, functions, seeds, variables—and mentions seed echoing. However, it never explicitly states the output format/return shape (e.g., a list of results). For a calculator tool this is mostly inferable, but a one-sentence note on the return structure would fully close the gap.

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?

Schema coverage is 100% and each parameter has a description, but the description adds significant semantic value: it explains the spec syntax (newline/semicolon separation, assignment, comma-as-argument-separator), provides examples, and details the RNG seed behavior and variable environment. This meaningfully exceeds what the schema alone provides.

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 verb+resource: 'Evaluate a batch of math expressions exactly.' It clearly distinguishes the tool from all sibling tools (workflow/image/ComfyUI operations) and clarifies it works without ComfyUI. The scope is precisely defined.

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

Usage Guidelines4/5

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

The description clearly states when to use it: 'works even in cloud mode or when ComfyUI is down' and notes it's 'handy for the arithmetic agents get wrong token-by-token.' It implies it is the go-to for safe arithmetic evaluation, though it does not explicitly name alternatives or say 'when not to use.'

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/artokun/comfyui-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server