Skip to main content
Glama
Calculator MCP Server

Calculator MCP Server

Calculator MCP Server (Python)

A feature-rich Model Context Protocol (MCP) server for mathematical calculations, scientific functions, unit conversions, financial metrics, and statistical analysis.

Built with Python 3.10+, the official mcp SDK (FastMCP), and sympy. Supports both stdio (Claude Desktop) and sse (Claude Web / Remote HTTP Connectors) transport modes.


🚀 Features & Exposed Tools

  • evaluate_math_expression: Evaluates custom mathematical expressions safely using SymPy (e.g. 2 * (3 + 4), sqrt(144) + sin(pi / 2), log(100, 10), 5^3).

  • perform_arithmetic: Basic arithmetic (add, subtract, multiply, divide) on arrays of numbers.

  • scientific_calculation: Powers, roots (sqrt, cbrt), factorials, logarithms (log, ln), and trigonometric functions (sin, cos, tan).

  • convert_unit: Physical unit conversions (Length, Mass/Weight, Temperature, Volume, Time).

  • financial_calculator: Simple interest, Compound interest, Loan EMI calculations, and Percentages.

  • calculate_statistics: Summary statistics (mean, median, mode, variance, stdev, summary).


Related MCP server: MCP Mathematics

📦 Installation & Setup

  1. Install Dependencies:

    pip install -r requirements.txt
    pip install -e .
  2. Run Automated Unit Tests:

    pytest

💻 1. Connecting to Claude Desktop (Stdio Mode)

Your claude_desktop_config.json has been automatically created at: C:\Users\ADMIN\AppData\Roaming\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "calculator": {
      "command": "C:\\Users\\ADMIN\\AppData\\Local\\Programs\\Python\\Python312\\python.exe",
      "args": [
        "-m",
        "calculator_mcp.server"
      ],
      "env": {
        "PYTHONPATH": "E:/mcp tutorials"
      }
    }
  }
}

Usage in Claude Desktop:

  1. Fully exit and restart Claude Desktop.

  2. Open a chat and look for the 🔨 (hammer/tools icon) at the bottom right of the message bar.

  3. Ask Claude: "What is sqrt(144) + sin(pi / 2)?" or "Convert 100 degC to degF".


🌐 2. Connecting to Claude Web & Remote Web Clients (SSE HTTP Mode)

To run the Calculator MCP as a web HTTP service (for web-based platforms, web connectors, or remote AI agents):

  1. Start the SSE Web Server:

    python -m calculator_mcp.server --transport sse --port 8000
  2. Web Client Configuration:

    {
      "mcpServers": {
        "calculator-web": {
          "serverUrl": "http://localhost:8000/sse"
        }
      }
    }
  3. Public Tunneling for Remote Web Apps (Optional): If your web client (like remote Claude Web) is hosted outside your local network, expose port 8000 using ngrok or localtunnel:

    npx localtunnel --port 8000
    # Or using ngrok:
    ngrok http 8000

    Then use the generated public HTTPS URL: https://<your-subdomain>.loca.lt/sse in your Web MCP connector configuration.


🔍 Interactive Testing via Web Interface (MCP Inspector)

You can launch the official Model Context Protocol interactive Web Inspector UI to visually test all tools in your browser:

mcp dev calculator_mcp/server.py

Or via Node:

npx @modelcontextprotocol/inspector@0.4.1 python -m calculator_mcp.server

Available Tools

6 tools
calculate_statisticsA
Read-onlyIdempotent

Calculate statistical summaries for a dataset of numbers.

Args: operation: 'mean', 'median', 'mode', 'variance', 'stdev', or 'summary' data: List of numerical observations

Inputs: data (required), operation (required). Returns: result

convert_unitA
Read-onlyIdempotent

Convert quantities between physical units (length, weight/mass, temperature, volume, time).

Examples:

  • convert_unit(100, "degC", "degF") -> Fahrenheit

  • convert_unit(5, "km", "miles") -> Miles

  • convert_unit(2, "hours", "sec") -> Seconds

Args: value: Numerical value to convert from_unit: Source unit string (e.g., 'km', 'miles', 'kg', 'lbs', 'degC', 'degF', 'hr', 'sec') to_unit: Target unit string

Inputs: value (required), to_unit (required), from_unit (required). Returns: result

evaluate_math_expressionA
Read-onlyIdempotent

Evaluate complex mathematical expressions safely.

Supports addition, subtraction, multiplication, division, exponents (^ or **), roots (sqrt, cbrt), trigonometric functions (sin, cos, tan), logarithms (log, log10, ln), and constants (pi, e).

Args: expression: The mathematical expression string (e.g., '2 * (3 + 4)', 'sqrt(144) + sin(pi / 2)', '5^3') precision: Number of decimal digits of precision for symbolic evaluation (default 10)

Inputs: expression (required), precision. Returns: result

financial_calculatorA
Read-onlyIdempotent

Calculate financial metrics like Simple Interest, Compound Interest, Loan EMI, and Percentages.

Args: calc_type: 'simple_interest', 'compound_interest', 'loan_emi', or 'percentage' principal: Principal loan/investment amount (or base value for percentage) rate: Annual interest rate in percent (e.g., 7.5 for 7.5%) time: Duration in years compounding_frequency: Times per year compounding occurs (1=annual, 4=quarterly, 12=monthly) amount: Optional secondary parameter

Inputs: calc_type (required), rate, time, amount, +2 more. Returns: result

perform_arithmeticB
Read-onlyIdempotent

Perform basic arithmetic on a list of numbers.

Args: operation: 'add', 'subtract', 'multiply', or 'divide' numbers: List of numbers to operate on in sequence

Inputs: numbers (required), operation (required). Returns: result

scientific_calculationA
Read-onlyIdempotent

Perform scientific mathematical calculations.

Args: operation: 'power', 'sqrt', 'cbrt', 'factorial', 'sin', 'cos', 'tan', 'log', 'ln' value: Primary number input (for trig functions, value is in degrees if secondary_value is 1, else radians) secondary_value: Exponent for power, base for log, or 1 to indicate degree mode for trig functions

Inputs: value (required), operation (required), secondary_value. Returns: result

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    B3.4/5.0

    Scored across 6 tools

    Disambiguation2/5

    There is significant overlap between evaluate_math_expression, perform_arithmetic, and scientific_calculation. An agent could compute the same result via multiple tools (e.g., sqrt via expression or scientific_calculation), making tool selection ambiguous. The boundaries between expression evaluation, basic arithmetic, and scientific operations are not clearly defined.

    Naming Consistency2/5

    Naming is inconsistent: some tools follow verb_noun (evaluate_math_expression, perform_arithmetic, convert_unit, calculate_statistics) while others are adjective_noun (scientific_calculation, financial_calculator). This mixed convention breaks predictability and could cause confusion about the tool's primary action.

    Tool Count5/5

    With 6 tools covering math expressions, arithmetic, scientific operations, unit conversion, finance, and statistics, the count is well-scoped for a comprehensive calculator server. Each tool addresses a distinct domain, and the number is neither too thin nor bloated.

    Completeness4/5

    The tool set covers a broad range of calculation needs, from basic arithmetic to scientific, financial, and statistical operations. Minor gaps exist (e.g., no modulus, percentile, or matrix support), but for a general-purpose calculator the surface is largely complete and usable.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      A comprehensive MCP server that enables file operations, mathematical calculations with unit conversions, and system information retrieval. Provides secure access to local file system, calculator functions with statistics, and system monitoring capabilities.
      8 npm
      ISC
    • A
      license
      C
      quality
      D
      maintenance
      A comprehensive MCP server that turns any AI assistant into a powerful mathematical computation engine, providing 52 advanced functions, 158 unit conversions, financial calculations, and secure AST-based evaluation.
      18
      16
      MIT
    • F
      license
      B
      quality
      D
      maintenance
      A comprehensive MCP server providing basic and advanced math operations (addition, subtraction, statistics, etc.) as well as smart prompts for multiplication tables, equation solving, financial calculations, geometry, unit conversion, loan amortization, probability, and fitness analytics.
      23
      1
      -