home / mcp / calculator mcp server

Calculator MCP Server

Provides a simple MCP calculator with add, subtract, multiply, divide, power, sqrt, and percentage operations.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "anshika1109-calculator-mcp-server": {
      "command": "uvx",
      "args": [
        "--from",
        "/Users/anshikagupta/calculator",
        "--with",
        "mcp",
        "python",
        "calculator_mcp_server.py"
      ]
    }
  }
}

You can run a Calculator MCP Server that exposes a simple set of arithmetic operations through the Model Context Protocol (MCP). It lets you perform common calculations remotely by sending requests for operations like add, subtract, multiply, divide, power, sqrt, and percentage, making it easy to integrate math capabilities into your MCP client workflows.

How to use

You will connect to the Calculator MCP Server using an MCP client. Once the server is running, you can invoke its operations by calling the corresponding tools (add, subtract, multiply, divide, power, sqrt, percentage) from your MCP client workflow. Each tool receives the required numeric parameters and returns the computed result. Use the tools to build more complex calculations by combining multiple operations in sequence.

How to install

Prerequisites you need before running the server: a Python runtime and a working MCP client setup. You may also use a helper runtime to host the MCP server if desired.

# Test the server directly
export PATH="$HOME/.local/bin:$PATH"
uvx --from . --with mcp calculator-mcp-server
```

```
# Create virtual environment
python -m venv venv
source venv/bin/activate

# Install dependencies
pip install git+https://github.com/modelcontextprotocol/python-sdk.git

# Run the server
python calculator_mcp_server.py

Configuration

You can configure the MCP client to discover and start the server using a configuration file. The following example shows how to register the Calculator MCP Server so your MCP client can manage it.

{
  "mcpServers": {
    "calculator": {
      "command": "/Users/anshikagupta/.local/bin/uvx",
      "args": ["--from", "/Users/anshikagupta/calculator", "--with", "mcp", "python", "calculator_mcp_server.py"],
      "disabled": false,
      "autoApprove": ["add", "subtract", "multiply", "divide", "power", "sqrt", "percentage"]
    }
  }
}

Usage notes

After configuring, you can perform calculations through your MCP client by calling the available tools. Examples of operations you can perform include adding two numbers, dividing numbers, raising a number to a power, calculating square roots, and computing percentages of a value. The server documents the exact parameters for each tool below.

Tools overview

The server provides a concise set of arithmetic operations you can call through MCP requests. Each operation takes numeric inputs and returns the computed result.

Available tools

add

Add two numbers together. Parameters: a (number), b (number). Returns the sum.

subtract

Subtract the second number from the first. Parameters: a (number), b (number). Returns the difference.

multiply

Multiply two numbers. Parameters: a (number), b (number). Returns the product.

divide

Divide the first number by the second. Parameters: a (number), b (number). Returns the quotient, with appropriate handling for division by zero.

power

Raise a base to an exponent. Parameters: base (number), exponent (number). Returns base raised to the exponent.

sqrt

Calculate the square root of a non-negative number. Parameters: number (non-negative). Returns the square root.

percentage

Calculate a percentage of a number. Parameters: number (number), percent (number). Returns the specified percentage of the number.