Skip to main content
Glama

Calculator MCP Server

A simple calculator MCP (Model Context Protocol) server built with FastMCP. Exposes basic arithmetic tools that you can plug into any MCP client such as Claude Desktop.

Tools

Tool

Description

add

Add two numbers

subtract

Subtract b from a

multiply

Multiply two numbers

divide

Divide a by b (raises on zero divisor)

power

Raise base to the power of exponent

sqrt

Square root of a non-negative number

Related MCP server: Calculator MCP Server

Prerequisites

  • Python ≥ 3.12

  • uv — fast Python package/environment manager

Setup

# 1. Create a virtual environment
uv venv .venv

# 2. Install dependencies (reads pyproject.toml)
uv sync

# 3. (Optional) Activate the venv
source .venv/bin/activate

Run the server

# Runs over stdio (default)
uv run python main.py

Or use the FastMCP CLI:

uv run fastmcp dev main.py            # runs with auto-reload
uv run fastmcp list main.py           # list exposed tools
uv run fastmcp call --server-spec main.py --target add --input-json '{"a": 3, "b": 4}'

Claude Desktop Configuration

  1. Quit Claude Desktop completely.

  2. Open claude_desktop_config.json:

    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

    • Windows: %APPDATA%\Claude\claude_desktop_config.json

    • Linux: ~/.config/Claude/claude_desktop_config.json

  3. Add (or merge) the following mcpServers entry, replacing the project path with your local path:

{
  "mcpServers": {
    "calculator": {
      "command": "uv",
      "args": [
        "run",
        "--project",
        "/absolute/path/to/calculator",
        "--directory",
        "/absolute/path/to/calculator",
        "python",
        "/absolute/path/to/calculator/main.py"
      ]
    }
  }
}

Note: If uv is not on Claude Desktop's PATH (common for GUI apps), use the absolute path instead, e.g. "/Users/<you>/.local/bin/uv". Find yours with which uv.

  1. Relaunch Claude Desktop. You should see a calculator icon, and the 6 tools will be available to use in chat.

Project Layout

calculator/
├── main.py            # FastMCP server with all tools
├── pyproject.toml     # Project metadata + dependencies
├── uv.lock            # Lock file
└── README.md

Available Tools

6 tools
addAddB

Add two numbers.

Inputs: a (required), b (required). Returns: result

divideDivideA

Divide the first number by the second.

Inputs: a (required), b (required). Returns: result

multiplyMultiplyB

Multiply two numbers.

Inputs: a (required), b (required). Returns: result

powerPowerB

Raise a base to a given exponent.

Inputs: base (required), exponent (required). Returns: result

sqrtSqrtA

Return the (principal) square root of a non-negative number.

Inputs: value (required). Returns: result

subtractSubtractA

Subtract the second number from the first.

Inputs: a (required), b (required). Returns: result

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 6 tools

    Disambiguation5/5

    Each tool performs a single, clearly distinct arithmetic operation with no overlap or ambiguity. An agent can easily select the correct tool for a given mathematical need.

    Naming Consistency4/5

    Names are lowercase and concise, following a consistent operation-based convention. Minor deviation: add/subtract/multiply/divide are verbs while power/sqrt are noun-like, but still predictable.

    Tool Count5/5

    Six tools are well-scoped for a basic calculator, covering core arithmetic operations without bloat or obvious redundancy.

    Completeness4/5

    Core arithmetic operations (add, subtract, multiply, divide) and common extras (power, sqrt) are present. Minor gaps include modulo, absolute value, rounding, or logarithm, but agents can work around them for basic calculation tasks.

    Maintenance

    ActivityStale
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Provides basic mathematical calculation functionality through MCP tools including arithmetic operations, exponentiation, and square root calculations. Features proper error handling for edge cases like division by zero and negative square roots.
      6
      41 npm
      2
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      Provides basic calculator operations (add, subtract, multiply, divide) as MCP tools for use with Claude Desktop and other MCP clients.
      -
    • F
      license
      Not graded
      quality
      D
      maintenance
      Exposes calculator operations (add, subtract, multiply, divide, power) as MCP tools, allowing users to perform arithmetic calculations through natural language in MCP-compatible clients like Cursor.
      -
    • F
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents to perform arithmetic operations such as addition, subtraction, multiplication, and division through standardized MCP tools.
      1
      -