Skip to main content
Glama
devbrother2024

TypeScript MCP Server Boilerplate

calc

Perform basic arithmetic operations (addition, subtraction, multiplication, division) on two numbers using the TypeScript MCP Server Boilerplate tool.

Instructions

두 숫자와 연산자를 입력받아 사칙연산 결과를 반환합니다.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
aYes첫 번째 숫자
bYes두 번째 숫자
operatorYes연산자 (+, -, *, /)

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYes계산 결과

Implementation Reference

  • Handler implementation for the 'calc' tool, performing basic arithmetic operations.
    async ({ a, b, operator }) => {
        let result: number
    
        if (operator === '+') result = a + b
        else if (operator === '-') result = a - b
        else if (operator === '*') result = a * b
        else {
            if (b === 0) throw new Error('0으로 나눌 수 없습니다.')
            result = a / b
        }
    
        const text = `${a} ${operator} ${b} = ${result}`
    
        return {
            content: [{ type: 'text' as const, text }],
            structuredContent: {
                content: [{ type: 'text' as const, text }]
            }
        }
    }
  • src/index.ts:73-115 (registration)
    Registration of the 'calc' tool in the MCP server.
    server.registerTool(
        'calc',
        {
            description: '두 숫자와 연산자를 입력받아 사칙연산 결과를 반환합니다.',
            inputSchema: z.object({
                a: z.number().describe('첫 번째 숫자'),
                b: z.number().describe('두 번째 숫자'),
                operator: z
                    .enum(['+', '-', '*', '/'])
                    .describe('연산자 (+, -, *, /)')
            }),
            outputSchema: z.object({
                content: z
                    .array(
                        z.object({
                            type: z.literal('text'),
                            text: z.string().describe('계산 결과')
                        })
                    )
                    .describe('계산 결과')
            })
        },
        async ({ a, b, operator }) => {
            let result: number
    
            if (operator === '+') result = a + b
            else if (operator === '-') result = a - b
            else if (operator === '*') result = a * b
            else {
                if (b === 0) throw new Error('0으로 나눌 수 없습니다.')
                result = a / b
            }
    
            const text = `${a} ${operator} ${b} = ${result}`
    
            return {
                content: [{ type: 'text' as const, text }],
                structuredContent: {
                    content: [{ type: 'text' as const, text }]
                }
            }
        }
    )
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool returns a result but does not mention error handling (e.g., division by zero), side effects, or whether the operation is idempotent. For a simple calculator, this is minimally acceptable but lacks richness.

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, efficiently structured sentence that front-loads the essential information. Every element contributes to understanding the tool's function with no redundant or wasted words.

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

Completeness4/5

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

Given the tool's low complexity, complete parameter schema coverage, and existence of an output schema (mentioned in context signals), the description is appropriately complete. It successfully conveys the essential operation without needing to detail return values, though mentioning edge cases like division by zero would have improved completeness.

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 all three parameters (a, b, operator) fully documented in the schema. The description summarizes these as 'two numbers and an operator' but does not add syntax details, constraints, or semantic relationships beyond what the schema already provides. Baseline 3 is appropriate for high schema coverage.

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

Purpose5/5

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

The description clearly states the tool receives two numbers and an operator, returning arithmetic results. It specifically mentions '사칙연산' (four arithmetic operations), which distinguishes it clearly from image generation, weather, and other sibling tools.

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

Usage Guidelines3/5

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

While there are no explicit when-to-use instructions or named alternatives, the specific domain (mathematical calculation) makes the implied usage clear given the unrelated sibling tools (generate-image, geocode, etc.). However, it lacks explicit guidance on when to prefer this over manual calculation or error conditions like division by zero.

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/devbrother2024/my-mcp-server-260402'

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