Skip to main content
Glama
devantage

MCP Calculator

by devantage
README.md
![Logo](https://s3.devantage.com.br/devantage-public/logo-100x100.png)

# MCP Calculator

A modern [Model Context Protocol](https://modelcontextprotocol.io) server for
mathematical calculations.
Exposes 13 tools (6 core + 7 specialized) with high-precision arithmetic, a safe expression evaluator, statistics, unit conversion, and financial math.

## Requirements

- Python 3.10+
- [uv](https://github.com/astral-sh/uv) (or Docker, for the containerized setup)

## Installation

```bash
uv venv

uv pip install -e ".[dev]"
```

## Running

The server supports two transports, selected via the `MCP_TRANSPORT` environment variable (see [Configuration](#configuration)).

### STDIO

The server speaks MCP over **stdio** by default (the transport used by most MCP
clients such as Claude Desktop and Claude Code):

```bash
source .venv/bin/activate

mcp-calculator
```

### Streamable HTTP

To serve over **streamable HTTP** instead:

```bash
source .venv/bin/activate

MCP_TRANSPORT=http mcp-calculator
```

The HTTP endpoint is then available at `http://0.0.0.0:8080/mcp/`.

### Docker

Build the image and run it in HTTP mode (the image defaults to HTTP on port 8080):

```bash
docker build -t mcp-calculator .

docker run --rm -p 8080:8080 mcp-calculator
```

Override any setting at runtime with `-e`, e.g. a different port:

```bash
docker run --rm -p 9000:9000 -e MCP_PORT=9000 mcp-calculator
```

## Configuration

| Variable        | Default   | Description                                                         |
| --------------- | --------- | ------------------------------------------------------------------- |
| `MCP_TRANSPORT` | `stdio`   | Transport to use: `stdio` or `http` (streamable HTTP).              |
| `MCP_HOST`      | `0.0.0.0` | Host/interface to bind when using HTTP. Use `0.0.0.0` to expose it. |
| `MCP_PORT`      | `8080`    | Port to listen on when using HTTP.                                  |

## Available Tools

### Core

| Tool                  | Description                                                                           |
| --------------------- | ------------------------------------------------------------------------------------- |
| `basic_math`          | add / subtract / multiply / divide with decimal precision (0-15)                      |
| `advanced_math`       | trig, inverse trig, log/ln, sqrt, abs, factorial, exp, pow                            |
| `expression_eval`     | evaluate expressions with variables, constants, and functions                         |
| `statistics_analysis` | mean, median, mode, std_dev, variance, percentile, range, skewness, kurtosis, summary |
| `unit_conversion`     | length, weight, temperature, volume, area                                             |
| `financial_calc`      | simple/compound interest, loan payment, ROI, present/future value                     |

### Specialized

| Tool                   | Description                                      |
| ---------------------- | ------------------------------------------------ |
| `stats_summary`        | full statistical overview of a dataset           |
| `percentile`           | a specific percentile (0-100) of a dataset       |
| `batch_conversion`     | convert many values between units at once        |
| `npv`                  | Net Present Value of cash flows                  |
| `irr`                  | Internal Rate of Return (Newton-Raphson)         |
| `loan_comparison`      | compare loans, return the lowest monthly payment |
| `investment_scenarios` | compare investments, return the highest return   |

## Development

### Testing

Run the test suite with:

```bash
pytest
```

## License

[MIT](./LICENSE)

TDQS

B3.4/5.0

Scored across 13 tools

Disambiguation3/5

Statistics has three overlapping tools (statistics_analysis, stats_summary, percentile) which could confuse an agent. Financial_calc overlaps with loan_comparison and investment_scenarios, though the comparative tools are distinct. Other tools are clearly separated.

Naming Consistency3/5

Most tools use noun_noun or adjective_noun patterns, but npv and irr are acronyms that break the pattern. expression_eval is verb-last while others are noun-first. Still readable but not fully consistent.

Tool Count5/5

With 13 tools, the server covers math, statistics, conversions, and finance without exceeding a manageable count. Each tool has a clear domain, though some redundancy exists in stats.

Completeness4/5

The server covers basic and advanced math, expression evaluation, statistics, unit conversions, and financial calculations, including comparative tools. Missing features like complex numbers or regression analysis are minor for a calculator.

Maintenance

ActivityStale
ResponsivenessNo issues