Skip to main content
Glama

calculate

Evaluate mathematical expressions to perform calculations within the Algorand blockchain environment.

Instructions

Perform basic mathematical calculations

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
expressionYesMathematical expression to evaluate (e.g., "2 + 2", "10 * 5")

Implementation Reference

  • The handler logic for the 'calculate' tool. Parses input arguments using Zod schema, evaluates the mathematical expression with eval(), and returns the result or an error response.
    case 'calculate': { const parsed = CalculateArgsSchema.parse(args); try { // Simple math evaluation (in production, use a safer math library) const result = eval(parsed.expression); return { content: [ { type: 'text', text: `Result: ${parsed.expression} = ${result}`, }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error: Invalid mathematical expression - ${error}`, }, ], isError: true, }; } }
  • Zod schema used for input validation in the calculate tool handler, defining the 'expression' parameter.
    const CalculateArgsSchema = z.object({ expression: z.string(), });
  • src/index.ts:114-127 (registration)
    Tool registration in the TOOLS array, defining name, description, and input schema for MCP protocol compliance.
    { name: 'calculate', description: 'Perform basic mathematical calculations', inputSchema: { type: 'object', properties: { expression: { type: 'string', description: 'Mathematical expression to evaluate (e.g., "2 + 2", "10 * 5")', }, }, required: ['expression'], }, },
  • Input schema defined in the tool registration for MCP tool listing and validation.
    inputSchema: { type: 'object', properties: { expression: { type: 'string', description: 'Mathematical expression to evaluate (e.g., "2 + 2", "10 * 5")', }, }, required: ['expression'], }, },

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/Jake-loranger/algorand-mcp-server'

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