Skip to main content
Glama

cal

Evaluate mathematical expressions with support for basic operations and constants like PI and E using the expr-eval library.

Instructions

Use the expr-eval library to evaluate the input mathematical expression and return the result.

Constant Description E The value of Math.E from your JavaScript runtime PI The value of Math.PI from your JavaScript runtime true Logical true value false Logical false value

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
expYes

Implementation Reference

  • index.ts:21-23 (handler)
    The execute handler for the 'cal' tool, which evaluates the mathematical expression by calling the calculate helper function.
    execute: async (args) => {
        return String(calculate(args.exp));
    },
  • Input schema for the 'cal' tool, defining the 'exp' parameter as a string.
    parameters: z.object({
        exp: z.string(),
    }),
  • index.ts:10-24 (registration)
    Registration of the 'cal' tool with FastMCP server, including name, description, schema, and handler.
    server.addTool({
        name: "cal",
        description: "Use the expr-eval library to evaluate the input mathematical expression and return the result." +
            "\n\nConstant \tDescription\n" +
            "E \tThe value of Math.E from your JavaScript runtime\n" +
            "PI \tThe value of Math.PI from your JavaScript runtime\n" +
            "true \tLogical true value\n" +
            "false \tLogical false value",
        parameters: z.object({
            exp: z.string(),
        }),
        execute: async (args) => {
            return String(calculate(args.exp));
        },
    });
  • Helper function that parses and evaluates the mathematical expression using expr-eval's Parser.
    function calculate(expression: string): number {
        const parser = new Parser();
        return parser.evaluate(expression);
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions the expr-eval library and lists available constants (E, PI, true, false), but doesn't describe important behavioral traits like error handling, supported operators, performance characteristics, or whether it's a read-only operation. For a tool with zero annotation coverage, this leaves significant gaps in understanding how the tool behaves.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is reasonably concise with two sentences, but the constant table feels appended rather than integrated. The first sentence clearly states the purpose, but the table of constants could be more efficiently integrated. The structure is adequate but could be improved with better flow between the main description and the constant details.

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

Completeness2/5

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

Given the complexity of a mathematical evaluation tool with no annotations, no output schema, and only 0% schema description coverage, the description is incomplete. It doesn't explain what types of expressions are supported, error conditions, return format, or limitations. For a tool that could have significant behavioral complexity, this description leaves too many questions unanswered.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds some meaning beyond the input schema, which has 0% description coverage. It clarifies that the 'exp' parameter should be a 'mathematical expression' and mentions available constants. However, it doesn't fully compensate for the schema coverage gap by explaining expression syntax, operator support, or validation rules. The baseline is 3 since the description provides some parameter context but not comprehensive documentation.

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 clearly states the tool's purpose: 'evaluate the input mathematical expression and return the result' using the expr-eval library. It specifies the verb (evaluate), resource (mathematical expression), and mechanism (expr-eval library). However, it doesn't explicitly differentiate from sibling tools like batchGetDateByTimestamp, which handle date calculations rather than general math expressions.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools or suggest scenarios where this mathematical evaluator would be preferred over date-related tools. The only implicit usage context is for mathematical expressions, but no explicit when/when-not or alternative recommendations are provided.

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/pwh-pwh/cal-mcp'

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