Skip to main content
Glama
bakcoder

TypeScript MCP Server Boilerplate

by bakcoder

calc

Perform basic arithmetic operations (addition, subtraction, multiplication, division) on two numbers using this calculator tool.

Instructions

두 숫자와 연산자(+,-,*,/)를 입력받아 사칙연산 결과를 반환합니다.

Input Schema

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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes계산 결과값
contentYes

Implementation Reference

  • The "calc" tool is registered and implemented in src/index.ts. It takes two numbers and an operator, performs the arithmetic calculation, and returns the result.
    server.registerTool(
        'calc',
        {
            description:
                '두 숫자와 연산자(+,-,*,/)를 입력받아 사칙연산 결과를 반환합니다.',
            inputSchema: z.object({
                left: z.number().describe('첫 번째 숫자'),
                operator: z
                    .enum(['+', '-', '*', '/'])
                    .describe('연산자 (+, -, *, /)'),
                right: z.number().describe('두 번째 숫자')
            }),
            outputSchema: z.object({
                content: z.array(
                    z.object({
                        type: z.literal('text'),
                        text: z.string().describe('계산 결과 메시지')
                    })
                ),
                result: z.number().describe('계산 결과값')
            })
        },
        async ({ left, operator, right }) => {
            if (operator === '/' && right === 0) {
                throw new Error('0으로 나눌 수 없습니다.')
            }
    
            const result =
                operator === '+'
                    ? left + right
                    : operator === '-'
                    ? left - right
                    : operator === '*'
                    ? left * right
                    : left / right
            const message = `${left} ${operator} ${right} = ${result}`
    
            return {
                content: [
                    {
                        type: 'text' as const,
                        text: message
                    }
                ],
                structuredContent: {
                    content: [
                        {
                            type: 'text' as const,
                            text: message
                        }
                    ],
                    result
                }
            }
        }
    )
Behavior3/5

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

Without annotations, the description carries the full disclosure burden. It states that the tool returns calculation results, implying a pure function. However, it omits critical behavioral details like division-by-zero handling, numeric precision, or whether the operation is read-only (though implied by 'returns').

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?

Single sentence, zero waste. Front-loaded with inputs (두 숫자와 연산자), operation type (사칭연산), and output (반환합니다). Every element earns its place with no redundancies.

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 simplicity (3 primitive parameters, 100% schema coverage) and presence of an output schema, the description provides sufficient context. It adequately covers the happy path behavior, though it could mention edge cases like division by zero for full completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema has 100% description coverage (baseline 3). The description adds value by explicitly listing the operator symbols (+,-,*,/) in prose, reinforcing the enum constraints and providing a complete summary of required inputs (two numbers and an operator) even though the schema documents individual fields.

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 performs four arithmetic operations (사칭연산) on two numbers using an operator, specifying the exact supported operators (+,-,*,/). It clearly distinguishes from siblings like generate-image, geocode, and get-weather which handle completely different domains.

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?

The description implies usage through functional definition (use for arithmetic calculations), but lacks explicit when-to-use guidance or exclusions. Given siblings are unrelated (weather, images, etc.), the context is clear, but no explicit alternatives or limitations are stated.

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

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