Skip to main content
Glama
small-tou

MCP Test Server

by small-tou

calculate

Perform mathematical calculations on the MCP Test Server by entering expressions or selecting operations like add, subtract, multiply, or divide with specific numbers.

Instructions

执行数学计算

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
aNo第一个数字
bNo第二个数字
expressionNo数学表达式,如 '2 + 3 * 4'
operationNo基本运算操作

Implementation Reference

  • The main execution handler for the 'calculate' tool. It evaluates mathematical expressions safely or performs basic arithmetic operations (add, subtract, multiply, divide) based on input parameters, handles errors, logs the operation, and returns the result in MCP content format.
    }, async (args) => {
      let result: number;
      let operation: string;
      
      if (args.expression) {
        // 简单的表达式求值(仅支持基本运算)
        try {
          // 安全的数学表达式求值
          const sanitized = args.expression.replace(/[^0-9+\-*/().\s]/g, '');
          result = Function(`"use strict"; return (${sanitized})`)();
          operation = args.expression;
        } catch (error) {
          return {
            content: [{
              type: "text",
              text: `❌ 无效的数学表达式: ${args.expression}`
            }]
          };
        }
      } else if (args.operation && args.a !== undefined && args.b !== undefined) {
        const { operation: op, a, b } = args;
        switch (op) {
          case "add":
            result = a + b;
            operation = `${a} + ${b}`;
            break;
          case "subtract":
            result = a - b;
            operation = `${a} - ${b}`;
            break;
          case "multiply":
            result = a * b;
            operation = `${a} * ${b}`;
            break;
          case "divide":
            if (b === 0) {
              return {
                content: [{
                  type: "text",
                  text: "❌ 错误: 除数不能为零"
                }]
              };
            }
            result = a / b;
            operation = `${a} / ${b}`;
            break;
          default:
            return {
              content: [{
                type: "text",
                text: `❌ 未知的运算操作: ${op}`
              }]
            };
        }
      } else {
        return {
          content: [{
            type: "text",
            text: "❌ 请提供数学表达式或运算操作参数"
          }]
        };
      }
      
      testData.logs.push(`计算: ${operation} = ${result}`);
      
      return {
        content: [{
          type: "text",
          text: `🧮 计算结果: ${operation} = ${result}`
        }]
      };
    });
  • Zod input schema defining optional parameters for the calculate tool: expression (string), operation (enum: add/subtract/multiply/divide), a and b (numbers).
    expression: z.string().optional().describe("数学表达式,如 '2 + 3 * 4'"),
    operation: z.enum(["add", "subtract", "multiply", "divide"]).optional().describe("基本运算操作"),
    a: z.number().optional().describe("第一个数字"),
    b: z.number().optional().describe("第二个数字")
  • src/index.ts:181-181 (registration)
    Registers the 'calculate' tool with the MCP server, specifying name, description, input schema, and handler function.
    server.tool("calculate", "执行数学计算", {
Behavior1/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. The description '执行数学计算' doesn't reveal any behavioral traits such as side effects, error handling, performance characteristics, or output format. It's a minimal statement that fails to inform the agent about how the tool behaves beyond its basic function.

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 extremely concise with a single phrase '执行数学计算', which is front-loaded and wastes no words. It efficiently states the purpose without unnecessary elaboration, making it easy to parse quickly.

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 (4 parameters, no annotations, no output schema), the description is incomplete. It doesn't address how parameters interact (e.g., using 'expression' vs. 'operation' with 'a' and 'b'), what the tool returns, or any error conditions. For a tool with multiple input options and no structured output, more context is needed to guide effective use.

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 input schema has 100% description coverage, with clear parameter descriptions (e.g., '第一个数字' for 'a', '数学表达式' for 'expression'). The description adds no additional meaning beyond what the schema provides, as it doesn't explain parameter relationships, constraints, or usage examples. Baseline score of 3 is appropriate since the schema does the heavy lifting.

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

Purpose3/5

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

The description '执行数学计算' (perform mathematical calculation) states a general purpose but is vague. It doesn't specify what kind of calculations, what resources are involved, or how it differs from potential alternatives. While it indicates the domain (mathematics), it lacks specificity about scope or method.

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?

No guidance is provided on when to use this tool versus alternatives. The description doesn't mention prerequisites, constraints, or comparison with sibling tools (e.g., add_user, create_todo, search_users), which are unrelated but highlight the lack of context. Usage is implied only by the general purpose.

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/small-tou/mcp-test'

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