Skip to main content
Glama
calculator-mcp-server

calculator-mcp-server

by Amankhan1009
README.md
# Calculator MCP Server

A Model Context Protocol server exposing calculator operations,
built as a learning project.

## Tools

- add(a, b)
- subtract(a, b)
- multiply(a, b)
- divide(a, b)
- power(base, exponent)
- square_root(number)
- modulus(a, b)

## Run

    uv run mcp dev src/calculator_mcp/server.py

## Test

    uv run pytest tests/ -v

## Architecture

- `operations.py` — pure calculator logic, no MCP dependency
- `server.py` — FastMCP tool registration, thin wrappers over operations.py
- `exceptions.py` — custom exception hierarchy (CalculatorError base)
- `tests/` — pytest unit tests, independent of the MCP layer

## Connect to Claude Desktop

Add this to `claude_desktop_config.json`:

    {
      "mcpServers": {
        "calculator": {
          "command": "uv",
          "args": ["run", "--directory", "/path/to/calculator-mcp-server", "mcp", "run", "src/calculator_mcp/server.py"]
        }
      }
    }

This structure generalizes to any MCP server: keep domain logic
separate from protocol code, use typed exceptions per failure mode,
annotate tools honestly (readOnly/idempotent/destructive/openWorld),
and test the logic layer without needing a live server.

TDQS

A4.4/5.0

Scored across 7 tools

Disambiguation5/5

Each tool performs a distinct mathematical operation: add, subtract, multiply, divide, modulus, square_root, and power. There is no overlap or ambiguity between them, so an agent will never have to guess which tool to use for a given operation.

Naming Consistency4/5

The names are clear and short, but not perfectly uniform: add, subtract, multiply, divide, and power are verbs, while modulus and square_root are nouns. However, this is a common and readable convention for math operations, and the intent is obvious.

Tool Count5/5

With 7 tools, the server is well-scoped for a calculator. It covers basic arithmetic plus modulus, square root, and power, which is a reasonable and expected set for the purpose without unnecessary bloat.

Completeness4/5

The core arithmetic and common math operations are present, providing good coverage for a calculator server. Minor omissions like absolute value or factorial exist, but they are not essential for the primary purpose and agents can typically work around them.

Maintenance

ActivityInactive
ResponsivenessNo recent community issues