Skip to main content
Glama
tech-sushant

Calculator MCP Server

by tech-sushant

Calculator MCP Server

A simple Model Context Protocol (MCP) server that provides basic calculator functionality through MCP tools.

Features

This MCP server provides the following calculator tools:

  • add: Add two numbers together

  • subtract: Subtract second number from first number

  • multiply: Multiply two numbers together

  • divide: Divide first number by second number (with zero-division protection)

  • power: Raise first number to the power of second number

  • sqrt: Calculate square root of a number (with negative number protection)

Related MCP server: calculator-mcp-server

Installation

  1. Install dependencies:

npm install
  1. Build the TypeScript code:

npm run build

Usage

Running the Server

Start the MCP server:

npm start

Or run in development mode:

npm run dev

MCP Client Configuration

To use this calculator MCP server with an MCP client (like Claude Desktop), add it to your MCP configuration:

{
  "mcpServers": {
    "calculator": {
      "command": "node",
      "args": ["/path/to/calculator-mcp/dist/index.js"],
      "env": {}
    }
  }
}

Available Tools

add

Adds two numbers together.

  • Parameters: a (number), b (number)

  • Example: add(5, 3) returns 5 + 3 = 8

subtract

Subtracts the second number from the first.

  • Parameters: a (number), b (number)

  • Example: subtract(10, 4) returns 10 - 4 = 6

multiply

Multiplies two numbers together.

  • Parameters: a (number), b (number)

  • Example: multiply(6, 7) returns 6 × 7 = 42

divide

Divides the first number by the second.

  • Parameters: a (number), b (number)

  • Example: divide(15, 3) returns 15 ÷ 3 = 5

  • Error handling: Returns error for division by zero

power

Raises the base to the power of the exponent.

  • Parameters: base (number), exponent (number)

  • Example: power(2, 8) returns 2^8 = 256

sqrt

Calculates the square root of a number.

  • Parameters: number (number)

  • Example: sqrt(16) returns √16 = 4

  • Error handling: Returns error for negative numbers

Development

Project Structure

calculator-mcp/
├── src/
│   └── index.ts          # Main MCP server implementation
├── dist/                 # Compiled JavaScript output
├── package.json          # Dependencies and scripts
├── tsconfig.json         # TypeScript configuration
└── README.md            # This file

Building

npm run build

Development Mode

npm run dev

Error Handling

The calculator includes proper error handling for:

  • Division by zero

  • Square root of negative numbers

  • Invalid tool names

  • General execution errors

All errors are returned with appropriate error messages and the isError flag set to true.

License

MIT

Available Tools

6 tools
addC

Add two numbers together

ParametersJSON Schema
NameRequiredDescriptionDefault
aYesFirst number to add
bYesSecond number to add

TDQS

C2.9/5.0
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 action ('add') but doesn't describe any behavioral traits such as error handling, performance characteristics, side effects, or output format. For a tool with no annotations, this is a significant gap in transparency.

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 ('Add two numbers together')—a single sentence with zero waste. It's front-loaded with the core purpose, making it easy for an agent to parse quickly. Every word earns its place by directly conveying the tool's function.

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 simplicity (2 parameters, no annotations, no output schema), the description is incomplete. It lacks information on behavioral aspects (e.g., what happens with non-numeric inputs, overflow handling) and output expectations. While the schema covers parameters well, the description doesn't compensate for missing annotations or output details, leaving gaps for agent understanding.

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 ('First number to add', 'Second number to add'). The description adds no additional meaning beyond what the schema provides, as it only restates the tool's purpose without detailing parameter usage or constraints. Baseline 3 is appropriate given 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 'Add two numbers together' clearly states the tool's function with a specific verb ('add') and resource ('two numbers'). It distinguishes from sibling tools like 'calculate' (which might do more complex operations) and 'greet' (which is unrelated). However, it doesn't explicitly differentiate from potential sibling arithmetic tools beyond naming the operation.

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 sibling tools like 'calculate' or specify use cases (e.g., for simple addition only). There's no context about prerequisites, limitations, or when not to use it, leaving the agent to infer usage from the tool name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

divideA

Divide first number by second number

ParametersJSON Schema
NameRequiredDescriptionDefault
aYesDividend (number to be divided)
bYesDivisor (number to divide by)

TDQS

A3.7/5.0
Behavior3/5

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

With no annotations, the description must carry the behavioral burden; it clearly indicates the core operation and argument order. However, it does not disclose edge-case behavior such as division by zero or the shape of the return value, and no output schema is provided.

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?

One short sentence with no filler; every word earns its place and the core action plus operand order are front-loaded.

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

Completeness3/5

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

The tool is simple and the schema fully covers parameters, so little extra is required. Still, without an output schema or mention of zero-divisor/error behavior, the agent must assume the return format and failure semantics.

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 already documents both parameters at 100% coverage with descriptions 'Dividend' and 'Divisor'. The description's 'first number'/'second number' wording reinforces order but adds no semantic detail beyond the schema.

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 states a specific verb and resource: divide two numbers, with explicit operand order. The operation is immediately distinguishable from sibling tools add, subtract, and multiply.

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 intended use is implied by the name and the verb 'divide', but there is no explicit statement of when to choose this over add/subtract/multiply or any exclusions. For a basic arithmetic tool this is adequate but not explicit.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

multiplyB

Multiply two numbers together

ParametersJSON Schema
NameRequiredDescriptionDefault
aYesFirst number to multiply
bYesSecond number to multiply

TDQS

B3.1/5.0
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 action ('multiply') but doesn't describe any behavioral traits such as error handling (e.g., for non-numeric inputs), performance characteristics, or side effects. For a mathematical operation tool with zero annotation coverage, this leaves significant gaps in understanding how the tool behaves beyond the 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 a single, efficient sentence ('Multiply two numbers together') that directly states the tool's purpose with zero waste. It is appropriately sized for a simple tool and front-loaded, making it easy for an agent to parse quickly.

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

Completeness3/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 (a basic arithmetic operation), 100% schema coverage, and no output schema, the description is minimally adequate. It states what the tool does but lacks details on usage guidelines, behavioral transparency, or output expectations. For such a simple tool, this might be sufficient, but it doesn't provide complete context for optimal agent invocation.

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 documentation for both parameters ('a' and 'b'). The description adds no additional meaning beyond what the schema provides—it merely restates that two numbers are multiplied. According to the rules, when schema_description_coverage is high (>80%), the baseline is 3 even with no param info in the description, which applies here.

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 as 'Multiply two numbers together', which is a specific verb (multiply) applied to resources (two numbers). It distinguishes from siblings like 'add' or 'divide' by specifying the multiplication operation. However, it doesn't explicitly differentiate from all siblings (e.g., 'power' could also involve multiplication), so it doesn't reach the highest score.

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 like 'add', 'divide', 'power', 'sqrt', or 'subtract'. It doesn't mention any context, prerequisites, or exclusions for usage. The agent must infer usage based on the tool name alone, which is insufficient for optimal selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

powerB

Raise first number to the power of second number

ParametersJSON Schema
NameRequiredDescriptionDefault
baseYesBase number
exponentYesExponent

TDQS

B3.1/5.0
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states the mathematical operation but doesn't mention error handling (e.g., large exponents, decimal exponents), performance characteristics, or any limitations. For a mathematical tool with zero annotation coverage, this is a significant gap in behavioral context.

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 that directly states the tool's function with zero wasted words. It's appropriately sized for this simple mathematical operation and front-loads the essential information without unnecessary elaboration.

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

Completeness3/5

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

For a simple mathematical operation with 100% schema coverage and no output schema, the description is adequate but has clear gaps. It explains what the tool does but doesn't provide usage guidance relative to siblings, behavioral context, or output expectations. The description meets minimum requirements but could be more helpful for an AI agent.

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 both parameters clearly documented in the schema. The description adds minimal value beyond the schema by specifying which parameter is the base and which is the exponent, but doesn't provide additional context about valid ranges, special cases, or mathematical properties beyond what's already in the structured schema.

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 mathematical operation (raise to power) and identifies the two input numbers (first number as base, second as exponent). It distinguishes from siblings like add, subtract, multiply, and divide by specifying exponentiation, but doesn't explicitly differentiate from sqrt which is a related but distinct operation.

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 like sqrt (which calculates square roots) or other mathematical operations. It simply states what the tool does without context about appropriate use cases or comparisons to sibling tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

sqrtC

Calculate square root of a number

ParametersJSON Schema
NameRequiredDescriptionDefault
numberYesNumber to calculate square root of

TDQS

C2.9/5.0
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. It states the basic operation but does not disclose behavioral traits such as error handling for negative inputs, performance characteristics, or output format. This leaves gaps in understanding how the tool behaves beyond the core 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 a single, efficient sentence with zero waste. It is front-loaded and directly conveys the tool's purpose without unnecessary details, making it easy for an AI agent 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 lack of annotations and output schema, the description is incomplete. It does not address error cases, return values, or usage context, which are important for a mathematical operation tool. This reduces its effectiveness in guiding an AI agent fully.

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 the parameter 'number' clearly documented. The description adds no additional meaning beyond the schema, such as constraints or examples. Since the schema does the heavy lifting, the baseline score of 3 is appropriate.

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 'Calculate square root of a number' clearly states the verb ('calculate') and resource ('square root of a number'), making the purpose unambiguous. However, it does not explicitly differentiate from sibling tools like 'power' (which could also compute roots), so it falls short of a perfect score.

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. For example, it does not mention using 'power' for other root calculations or specify that this is for non-negative numbers (though implied by the operation). This lack of context reduces its utility for an AI agent.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

subtractA

Subtract second number from first number

ParametersJSON Schema
NameRequiredDescriptionDefault
aYesNumber to subtract from
bYesNumber to subtract

TDQS

A3.5/5.0
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 operation but lacks details on error handling (e.g., for non-numeric inputs), performance characteristics, or output format. 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 that directly states the tool's purpose with zero waste. It is appropriately sized and front-loaded, making it easy to understand at a glance.

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

Completeness3/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 (simple arithmetic), no annotations, no output schema, and high schema coverage, the description is minimally adequate. It covers the basic operation but lacks context on output values, error conditions, or behavioral traits, which could be helpful for an AI agent.

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 clear parameter descriptions in the schema (e.g., 'a' as 'Number to subtract from', 'b' as 'Number to subtract'). The description adds no additional meaning beyond what the schema provides, such as examples or edge cases, so it meets the baseline 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 'Subtract second number from first number' clearly states the specific mathematical operation (subtract) and identifies the resources (numbers). It distinguishes from sibling tools like 'add', 'divide', 'multiply', 'power', and 'sqrt' by specifying the exact arithmetic operation.

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 for subtraction operations but provides no explicit guidance on when to use this tool versus alternatives like 'add' or 'divide'. No context about mathematical scenarios or exclusions is mentioned, leaving usage to inference from the tool name and description.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 6 tool updates
    • First observedadd
    • First observeddivide
    • First observedmultiply
    • First observedpower
    • First observedsqrt
    • First observedsubtract

TDQS

A3.7/5.0

Scored across 6 tools

Disambiguation5/5

Each tool has a clearly distinct mathematical operation with no overlap in purpose. The descriptions are precise and unambiguous, making it easy for an agent to select the correct tool for addition, subtraction, multiplication, division, exponentiation, or square root calculation.

Naming Consistency5/5

All tool names follow a consistent verb-based pattern (add, divide, multiply, power, sqrt, subtract) that directly describes the mathematical operation. There are no deviations in naming conventions, and the pattern is predictable and readable throughout the set.

Tool Count5/5

With 6 tools, this server is well-scoped for a calculator domain, covering essential arithmetic operations (add, subtract, multiply, divide) and common advanced functions (power, sqrt). Each tool earns its place without redundancy, and the count is appropriate for the purpose.

Completeness5/5

The tool set provides complete coverage for a basic calculator domain, including all core arithmetic operations and key mathematical functions. There are no obvious gaps, such as missing operations like modulo or trigonometric functions, which are not essential for this scope, and agents can perform typical calculations without dead ends.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    C
    maintenance
    Provides mathematical operation tools including basic arithmetic (add, subtract, multiply, divide), power and square root calculations, and safe evaluation of mathematical expressions.
    -
  • A
    license
    Not graded
    quality
    D
    maintenance
    Provides a comprehensive set of mathematical functions as MCP tools, enabling language models to perform calculations including arithmetic, trigonometry, logarithms, and more.
    6 npm
    1
    MIT
  • F
    license
    Not graded
    quality
    C
    maintenance
    Provides basic calculator operations (add, subtract, multiply, divide) as MCP tools for use with Claude Desktop and other MCP clients.
    -
  • A
    license
    A
    quality
    B
    maintenance
    Provides basic arithmetic operations (add, subtract, multiply, divide) through MCP, enabling AI clients to perform calculations via natural language.
    4
    6 npm
    MIT