Skip to main content
Glama

calculate

Evaluate batch math expressions exactly with variables, functions, and seeded random numbers. Works offline without ComfyUI connection.

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}.
Behavior4/5

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

The description discloses key behavioral traits: it's a safe evaluator (no eval, numbers only), variable persistence across lines, comma vs semicolon distinction, supported operators/functions. It does not mention error handling or return format, but overall provides rich behavioral context beyond annotations (which are absent).

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 description is well-structured with a clear overview, syntax rules, operator list, and examples. It front-loads the key purpose and safety. While somewhat lengthy, every section serves a purpose, and the examples are helpful. Minor redundancy (e.g., reiterating separators) but overall efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no output schema, the description should explain the return value format, but it does not. It implies results per line via examples but does not explicitly state the structure (e.g., array of numbers or object with results/errors). For a tool with 3 params and simple output, this is a moderate 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 description coverage is 100%, yet the description adds significant value: it explains the syntax for 'spec', the reproducibility mechanism and mulberry32 for 'seed', and gives an example for 'variables'. This enriches agent understanding beyond the schema's brief descriptions.

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 clearly states it evaluates math expressions, with specific verb 'evaluate' and resource 'math expressions'. It distinguishes from siblings by noting it works independently of ComfyUI, which is unique among the listed tools (none others do pure math).

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 provides context on when to use it: 'no ComfyUI connection needed' and 'handy for arithmetic agents get wrong'. It includes concrete examples showing use cases (resolution, seed batch, CFG sweep). However, it lacks explicit when-not-to-use or alternatives, though siblings make this clear.

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