Skip to main content
Glama
devashish234073

my-mcp-server

calculate

Evaluate math expressions directly using the tool on my-mcp-server. Input any valid equation like '2 + 2' to get instant results for basic calculations.

Instructions

Perform basic math calculations

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
expressionYesMath expression to evaluate (e.g., '2 + 2')

Implementation Reference

  • The handler for the 'calculate' tool. It sanitizes the input math expression by removing disallowed characters, evaluates it using eval(), and returns the result or an error message in the tool response format.
    case "calculate":
      try {
        // Simple math evaluation (sanitized)
        const sanitized = args.expression.replace(/[^0-9+\-*/().\s]/g, "");
        const result = eval(sanitized);
        return {
          content: [
            {
              type: "text",
              text: `${args.expression} = ${result}`,
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error calculating "${args.expression}": ${error.message}`,
            },
          ],
          isError: true,
        };
      }
  • server1.js:40-53 (registration)
    Registration of the 'calculate' tool in the ListToolsRequestSchema handler, including its name, description, and input schema.
    {
      name: "calculate",
      description: "Perform basic math calculations",
      inputSchema: {
        type: "object",
        properties: {
          expression: {
            type: "string",
            description: "Math expression to evaluate (e.g., '2 + 2')",
          },
        },
        required: ["expression"],
      },
    },
  • Input schema definition for the 'calculate' tool, specifying an object with a required 'expression' string property.
    inputSchema: {
      type: "object",
      properties: {
        expression: {
          type: "string",
          description: "Math expression to evaluate (e.g., '2 + 2')",
        },
      },
      required: ["expression"],
    },
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states 'perform basic math calculations' but doesn't disclose behavioral traits like error handling, supported operations, precision limits, or output format. This leaves significant gaps for an agent to understand how the tool behaves beyond its basic purpose.

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 a single, efficient sentence with zero wasted words. It's appropriately sized for a simple tool and front-loads the core purpose without unnecessary elaboration.

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 tool's complexity (low), lack of annotations, and no output schema, the description is incomplete. It doesn't explain what 'basic math' includes, how results are returned, or any limitations. For a tool with no structured behavioral data, the description should provide more context to be fully helpful.

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?

Schema description coverage is 100%, with the parameter 'expression' well-documented in the schema as 'Math expression to evaluate (e.g., '2 + 2')'. The description adds no additional parameter semantics beyond what the schema provides, so it meets the baseline of 3 for high schema coverage.

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 with a specific verb ('perform') and resource ('basic math calculations'), making it immediately understandable. It doesn't differentiate from sibling tools (greet, weather_info), but those are unrelated domains, so differentiation isn't needed here.

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 any prerequisites, limitations, or scenarios where other tools might be more appropriate. The sibling tools are unrelated, so no explicit comparison is needed, but general usage context is missing.

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

Related 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/devashish234073/my-mcps'

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