Skip to main content
Glama
ciel240
by ciel240

calculator

Perform basic arithmetic operations on two numbers including addition, subtraction, multiplication, and division to solve mathematical calculations.

Instructions

두 숫자에 대한 사칙연산을 수행하는 계산기 도구

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
num1Yes첫 번째 숫자
num2Yes두 번째 숫자
operationYes연산자

Implementation Reference

  • Handles the 'calculator' tool execution: parses input arguments using CalculatorToolSchema, calls the calculate helper function, formats the result with operation symbol, and returns it as text content. Includes error handling.
    if (request.params.name === 'calculator') {
        try {
            const { num1, num2, operation } = CalculatorToolSchema.parse(request.params.arguments)
            
            const result = calculate(num1, num2, operation)
            const operationSymbols = {
                add: '+',
                subtract: '-',
                multiply: '*',
                divide: '/'
            }
            const symbol = operationSymbols[operation]
            const message = `${num1} ${symbol} ${num2} = ${result}`
            
            return {
                content: [
                    {
                        type: 'text',
                        text: message
                    }
                ]
            }
        } catch (error) {
            return {
                content: [
                    {
                        type: 'text',
                        text: `계산 오류: ${error instanceof Error ? error.message : '알 수 없는 오류'}`
                    }
                ],
                isError: true
            }
        }
  • Zod schema defining the input structure for the calculator tool: num1 and num2 as numbers, operation as enum of 'add', 'subtract', 'multiply', 'divide'.
    const CalculatorToolSchema = z.object({
        num1: z.number().describe('첫 번째 숫자'),
        num2: z.number().describe('두 번째 숫자'),
        operation: z.enum(['add', 'subtract', 'multiply', 'divide']).describe('연산자 (add: 덧셈, subtract: 뺄셈, multiply: 곱셈, divide: 나눗셈)')
    })
  • src/index.ts:334-356 (registration)
    Registers the 'calculator' tool in the ListToolsResponse, providing name, description, and inputSchema matching the Zod schema.
    {
        name: 'calculator',
        description: '두 숫자에 대한 사칙연산을 수행하는 계산기 도구',
        inputSchema: {
            type: 'object',
            properties: {
                num1: {
                    type: 'number',
                    description: '첫 번째 숫자'
                },
                num2: {
                    type: 'number',
                    description: '두 번째 숫자'
                },
                operation: {
                    type: 'string',
                    description: '연산자',
                    enum: ['add', 'subtract', 'multiply', 'divide']
                }
            },
            required: ['num1', 'num2', 'operation']
        }
    },
  • Helper function that performs the arithmetic calculation based on the operation enum: add (+), subtract (-), multiply (*), divide (/). Handles division by zero and invalid operations with errors.
    const calculate = (num1: number, num2: number, operation: string): number => {
        switch (operation) {
            case 'add':
                return num1 + num2
            case 'subtract':
                return num1 - num2
            case 'multiply':
                return num1 * num2
            case 'divide':
                if (num2 === 0) {
                    throw new Error('0으로 나눌 수 없습니다')
                }
                return num1 / num2
            default:
                throw new Error('지원하지 않는 연산입니다')
        }
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool performs arithmetic operations but doesn't mention error handling (e.g., division by zero), output format, or any behavioral traits like rate limits or side effects. This is a significant gap for a tool with no annotation coverage.

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 in Korean that directly states the tool's function without unnecessary words. It is appropriately sized and front-loaded, with zero waste, making it highly concise and well-structured.

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 (a calculator with 3 parameters) and no annotations or output schema, the description is incomplete. It lacks details on behavioral aspects, error handling, and return values, which are crucial for an AI agent to use the tool correctly. The description does not compensate for the absence of structured data.

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 schema description coverage is 100%, with clear descriptions for all parameters (num1, num2, operation with enum values). The description adds no additional meaning beyond the schema, such as explaining parameter interactions or constraints. Baseline 3 is appropriate when the schema does the heavy lifting.

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: performing four basic arithmetic operations on two numbers. It uses specific verbs ('사칙연산을 수행하는') and identifies the resource ('두 숫자'). However, it doesn't differentiate from sibling tools like 'code_review' or 'generate_image', which are unrelated, so it doesn't need sibling differentiation for a 5.

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 context, exclusions, or prerequisites. While sibling tools are unrelated, the description lacks any usage instructions, such as when arithmetic calculations are needed over other tools.

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/ciel240/class_study'

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