# Calculate Mcp

> A high-precision calculation & binary data MCP server with chained batch execution (batch_calc), bitwise logic, IEEE 754, crypto, and math.

- **Type:** MCP server
- **Install:** `agentstack add mcp-konghuansmart-calculate-mcp`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [KonghuanSmart](https://agentstack.voostack.com/s/konghuansmart)
- **Installs:** 0
- **Category:** [AI & ML](https://agentstack.voostack.com/c/ai-and-ml)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [KonghuanSmart](https://github.com/KonghuanSmart)
- **Source:** https://github.com/KonghuanSmart/calculate-mcp

## Install

```sh
agentstack add mcp-konghuansmart-calculate-mcp
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# calculate-mcp

[English](https://github.com/KonghuanSmart/calculate-mcp/blob/main/README.md) | [简体中文](https://github.com/KonghuanSmart/calculate-mcp/blob/main/README_CN.md)

[](https://www.npmjs.com/package/calculate-mcp)
[](https://opensource.org/licenses/MIT)
[](https://nodejs.org/)
[](https://modelcontextprotocol.io)

A comprehensive [Model Context Protocol (MCP)](https://modelcontextprotocol.io) server providing precision numerical calculations, low-level binary data operations, IEEE 754 float decomposition, cryptographic utilities, data codecs, and an intelligent **chained batch execution engine (`batch_calc`)** designed to eliminate multi-turn round-trip overhead for Large Language Models.

---

## 🌟 Highlights

- ⚡ **29 Specialized Tools**: Covers arbitrary-precision integer conversions, bitwise logic, endianness swapping, IEEE 754 floating-point layouts, modular arithmetic, cryptography, statistics, and trigonometry.
- 🔗 **Zero-Round-Trip Chained Execution (`batch_calc`)**: Run multiple operations in a single tool call with step-to-step dependency referencing (`{"$step": 0, "field": "resultHex"}`), reducing LLM latency and token consumption.
- 🔢 **Arbitrary-Precision & Native Bit-Widths**: Powered by native `BigInt` — zero precision loss for 64-bit/128-bit+ integers with full 8/16/32/64-bit signed and unsigned two's complement representations.
- 🛡️ **Zero Bloat**: Built purely with TypeScript, Node.js standard libraries, and Zod. No heavy native bindings or fragile dependencies.

---

## 📦 Installation & Configuration

### Option A: Using `npx` (Recommended)
```json
{
  "mcpServers": {
    "calculate-mcp": {
      "command": "npx",
      "args": ["-y", "calculate-mcp"]
    }
  }
}
```

### Option B: From Source (Clone & Run Locally)

1. Clone and build the server:
```bash
git clone https://github.com/KonghuanSmart/calculate-mcp.git
cd calculate-mcp
npm install
npm run build
```

2. Add to your MCP client config (e.g. `claude_desktop_config.json` or `mcp.json`):
```json
{
  "mcpServers": {
    "calculate-mcp": {
      "command": "node",
      "args": ["/path/to/calculate-mcp/build/index.js"]
    }
  }
}
```

---

## 🛠️ Tool Catalog (29 Tools)

### 1. Pipeline & Batch Execution (1 Tool)
| Tool | Description |
| :--- | :--- |
| `batch_calc` | Executes multiple calculation steps in a single call. Steps can reference earlier results using `{"$step": index, "field": "..."}`. |

### 2. Number Systems & Binary Data (6 Tools)
| Tool | Description |
| :--- | :--- |
| `int_convert` | Converts integers across Hex, Dec, Bin, Oct, 8/16/32/64-bit signed/unsigned, Little-Endian, and ASCII. Supports batch arrays. |
| `bitwise` | Bitwise operations (`and`, `or`, `xor`, `not`, `shl`, `shr`, `sar`, `rol`, `ror`) with configurable 8/16/32/64-bit width. |
| `endian_swap` | Swaps endianness (Big-Endian  Little-Endian) for numbers, hex values, or arbitrary byte streams. |
| `ieee754_convert` | Decomposes Single-precision (Float32) and Double-precision (Float64) IEEE 754 representations (Sign, Exponent, Mantissa, classification). |
| `crypto_calc` | Standard hashes (`md5`, `sha1`, `sha256`), checksums (`crc32`, `crc16-ccitt`, `crc16-modbus`), and BigInt modular math (`mod_pow`, `mod_inverse`, `gcd`). |
| `data_codec` | Encoders and decoders for Base64 (standard & URL-safe), Hex  UTF-8 text, and URL encoding/decoding. |

### 3. Basic Arithmetic & Rounding (9 Tools)
| Tool | Description |
| :--- | :--- |
| `add` | Adds two numbers. |
| `subtract` | Subtracts the second number from the first. |
| `multiply` | Multiplies two numbers. |
| `division` | Divides numerator by denominator. |
| `sum` | Computes the sum of an array of numbers. |
| `modulo` | Returns the division remainder. |
| `floor` | Rounds down to the nearest integer. |
| `ceiling` | Rounds up to the nearest integer. |
| `round` | Rounds to the nearest integer. |

### 4. Statistics (5 Tools)
| Tool | Description |
| :--- | :--- |
| `mean` | Calculates the arithmetic mean. |
| `median` | Finds the median value. |
| `mode` | Determines the most frequent entry/entries. |
| `min` | Finds the minimum value. |
| `max` | Finds the maximum value. |

### 5. Trigonometry & Conversions (8 Tools)
| Tool | Description |
| :--- | :--- |
| `sin`, `cos`, `tan` | Sine, cosine, and tangent (in radians). |
| `arcsin`, `arccos`, `arctan` | Inverse trigonometric functions (in radians). |
| `degreesToRadians` | Converts degrees to radians. |
| `radiansToDegrees` | Converts radians to degrees. |

---

## 💡 Practical Examples

### Example 1: Multi-Step Chained Calculation (`batch_calc`)
In a single prompt, decode a packet header, swap endianness, mask flags, and calculate a checksum without round-trip delay:

```json
{
  "steps": [
    { "op": "data_codec", "args": { "action": "from_base64", "input": "c2VjcmV0", "format": "hex" } },
    { "op": "endian_swap", "args": { "value": "0x78563412", "widthBytes": 4 } },
    { "op": "bitwise", "args": { "operation": "xor", "a": { "$step": 1, "field": "bigEndianHex" }, "b": "0xDEADBEEF", "bitWidth": 32 } },
    { "op": "crypto_calc", "args": { "action": "crc32", "data": { "$step": 0, "field": "decoded" }, "inputFormat": "hex" } }
  ]
}
```

### Example 2: Modular Arithmetic & RSA Private Exponent
Solve $d \equiv e^{-1} \pmod{\phi(n)}$ for $e=65537$ and $\phi(n)=10000000000000000051$:

```json
{
  "action": "mod_inverse",
  "a": "65537",
  "modulus": "10000000000000000051"
}
```

### Example 3: IEEE 754 Floating-Point Decomposition
Decompose machine code `0x3f800000` into float components:

```json
{
  "value": "0x3f800000",
  "precision": "float32"
}
```
**Output:**
```json
{
  "value": 1,
  "sign": "+",
  "rawExponentDec": 127,
  "biasedExponent": 0,
  "mantissaHex": "0x000000",
  "type": "normal"
}
```

---

## 💻 Development

```bash
# Clone the repository
git clone https://github.com/KonghuanSmart/calculate-mcp.git
cd calculate-mcp

# Install dependencies
npm install

# Build TypeScript to build/
npm run build

# Run locally in stdio mode
npm start
```

---

## 🤖 Companion Agent Skill (Prompt & Tool Guidance)

To prevent AI coding agents (such as Pi, Claude Code, Cursor, etc.) from suffering "mental calculation hallucinations" when dealing with arithmetic, radix conversions, bitwise logic, endianness swapping, and cryptographic hashing, this repository provides a ready-to-use companion Skill specification in `skills/calculate-mcp` (`SKILL.md`).

### Installation

Copy or symlink `skills/calculate-mcp` into your agent's skills directory:

**For Pi Agent / Universal Agent Harnesses:**
```powershell
# Windows (PowerShell):
Copy-Item -Recurse -Force "skills/calculate-mcp" "$HOME/.agents/skills/"
```

```bash
# Linux / macOS:
cp -r skills/calculate-mcp ~/.agents/skills/
```

Once installed, the agent will automatically trigger and prioritize calling `calculate-mcp` tools whenever precise arithmetic, radix conversions (Hex/Bin/Dec/Oct), bitwise operations (AND/OR/XOR), endianness swaps, or hash/encoding tasks are requested.

---

## 📄 License

[MIT License](https://github.com/KonghuanSmart/calculate-mcp/blob/main/LICENSE) © 2026

## Source & license

This open-source MCP server is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [KonghuanSmart](https://github.com/KonghuanSmart)
- **Source:** [KonghuanSmart/calculate-mcp](https://github.com/KonghuanSmart/calculate-mcp)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/mcp-konghuansmart-calculate-mcp
- Seller: https://agentstack.voostack.com/s/konghuansmart
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
