Skip to main content
Glama
Chetto983

Mathematical Calculator MCP Server

by Chetto983

calculate

Evaluates mathematical expressions and returns the computed result. Supports basic operators, functions, and constants for safe calculations.

Instructions

Evaluates a mathematical expression and returns the result.

Supports basic operators (+, -, *, /, **, %, ^), mathematical functions (sin, cos, tan, exp, log, log10, sqrt), and constants (pi, e). Uses an AST whitelist for safe execution.

Args: expression: The mathematical expression to evaluate as a string. Examples: "2 + 2", "sin(pi/4)", "sqrt(16) * 2", "log(100, 10)"

Returns: On success: {"result": } On error: {"error": }

Examples: >>> calculate("2 * 3 + 4") {'result': 10} >>> calculate("sin(pi/2)") {'result': 1.0} >>> calculate("sqrt(16)") {'result': 4.0} >>> calculate("(2 + 3)^2") {'result': 25}

Notes: - Use 'x' as the variable (e.g., x2, not x^2) - Multiplication must be explicitly indicated with * (e.g., 2*x, not 2x) - Powers can be represented with ** or ^ (e.g., x2 or x^2)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
expressionYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.1.1

TDQS

A4.1/5.0
Behavior4/5

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

With no annotations, the description carries the full burden and does well: it discloses the safe-execution mechanism ('Uses an AST whitelist'), documents both success and error return shapes, and warns about syntax pitfalls (implicit multiplication, 'x' as the variable, ** vs ^). It does not discuss limits on expression size or complexity, but for a pure read-only evaluator this is solid disclosure.

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?

Content is front-loaded (one-line purpose, then supported syntax, then I/O, then examples), and the sections are skimmable. It runs somewhat long — four doctest examples plus a Notes block that partly restates the power-notation point already shown in an example — so a little redundancy keeps it from a 5.

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?

There is no output schema and no annotations, so the description must supply return values, error shape, and safety context itself — and it does all three, plus syntax caveats. An agent has everything needed to call this tool correctly on the first try.

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 0%, so the description must compensate, and it does: it defines the single parameter as a string expression, supplies four concrete examples, and adds non-obvious syntax rules (variable 'x', mandatory explicit '*', power notation). This is meaning well beyond what the bare schema provides.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a precise verb+resource ('Evaluates a mathematical expression and returns the result') and enumerates the supported operators, functions, and constants, so the agent knows exactly what class of input is accepted. It stops short of explicitly differentiating itself from symbolic siblings like factorize, expand, or solve_equation, so it is clear but not sibling-aware.

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 implied by the capability list — an agent can infer this is for numeric evaluation rather than symbolic manipulation — but there is no explicit when-to-use statement and no alternatives (e.g., solve_equation, differentiate) named as the better choice for other tasks. Minimum viable guidance.

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