Skip to main content
Glama
rog0x

mcp-math-tools

by rog0x
README.md

# mcp-math-tools

Math and calculation tools for AI agents, exposed via the [Model Context Protocol (MCP)](https://modelcontextprotocol.io).

## Tools

### `calculate`
Evaluate math expressions safely (no `eval`). Supports arithmetic operators (`+`, `-`, `*`, `/`, `^`, `%`), parentheses, functions (`sqrt`, `abs`, `floor`, `ceil`, `round`, `log`, `ln`, `sin`, `cos`, `tan`, `min`, `max`, `pow`), constants (`pi`, `e`), and named variables.

### `convert_units`
Convert between units across six categories:
- **Length**: m, km, cm, mm, mi, yd, ft, in
- **Weight**: kg, g, mg, lb, oz, ton
- **Temperature**: C, F, K
- **Data**: B, KB, MB, GB, TB
- **Time**: s, min, h, d, week
- **Speed**: m/s, km/h, mph, knots

### `statistics`
Statistical analysis on datasets: mean, median, mode, variance, standard deviation, min, max, range, percentile, correlation between two arrays, and a full summary mode.

### `format_number`
Format numbers as: currency (`$1,234.56`), percentage, scientific notation, binary, octal, hexadecimal, significant figures, or with thousands separators.

### `percentage_calc`
Common percentage operations: X% of Y, what percent X is of Y, percentage change between two values, tip calculator, discount calculator, and markup calculator.

## Installation

```bash
npm install
npm run build
```

## Usage with Claude Desktop

Add to your `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "math-tools": {
      "command": "node",
      "args": ["path/to/mcp-math-tools/dist/index.js"]
    }
  }
}
```

## Examples

**Calculate**: `2 * (3 + 4) ^ 2` returns `98`

**Convert**: `100` from `km/h` to `mph` returns `62.137...`

**Statistics**: summary of `[1, 2, 3, 4, 5]` returns mean, median, mode, variance, etc.

**Format**: `1234567.89` as `currency` returns `$1,234,567.89`

**Percentage**: `15%` tip on `85.50` bill split 3 ways

## License

MIT

TDQS

A3.7/5.0

Scored across 5 tools

Disambiguation4/5

Each tool has a clearly defined primary purpose: expression evaluation, unit conversion, statistical analysis, number formatting, and percentage calculations. There is minor overlap where calculate can handle some percentage and min/max operations, but the descriptions make the intended use cases distinguishable.

Naming Consistency3/5

Tool names are all lowercase and snake_case, which is readable, but they mix verb-led names like convert_units and format_number with noun-led names like statistics and percentage_calc. The use of both 'calculate' and 'calc' for the same concept also breaks consistency.

Tool Count5/5

Five tools is well-scoped for a math-focused server. Each tool addresses a distinct common math need without unnecessary redundancy or excessive surface area.

Completeness4/5

The server covers core math operations, unit conversions, statistics, number formatting, and percent calculations, which are the most common use cases. It could be expanded with features like random number generation or matrix operations, but these are not obvious gaps for the stated purpose.

Maintenance

ActivityInactive
ResponsivenessNo issues