A Rust port of calc (Landon Curt Noll's arbitrary-precision calculator)

by carlomagnoglobal

210 downloads Not rated yet
GitHub

About

A Rust port of calc (Landon Curt Noll's arbitrary-precision calculator) that works as:

Explore

- ✅ User-defined functions (define name(params) = expr)
- ✅ Control flow (if/else, while, for loops)
- ✅ Variables and scoping
- ✅ Lists and indexing (0-based, negative indices supported)
- ✅ Complex numbers with full arithmetic
- ✅ String literals and operations
- ✅ Base conversion (2-36, input and output)
- ✅ Arbitrary-precision arithmetic (exact rationals)
- ✅ File loading (-f filename)
- ✅ REPL, pipe mode, quiet mode

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name A Rust port of calc (Landon Curt Noll's arbitrary-precision calculator)
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

rcalc '2^100'                 # 1267650600228229401496703205376
rcalc '1/3 + 1/6'            # 0.5
rcalc -m frac '1/3 + 1/6'    # 1/2
rcalc 'gcd(462,1071)'        # 21
rcalc 'fact(30)'            # 265252859812191058636308480000000
rcalc 'sqrt(2)'             # 1.4142135623730950488
rcalc 'isprime(1000003)' 'nextprime(1000003)'   # 1 \n 1000033
echo '3*4' | rcalc -p        # pipe mode
rcalc                        # interactive REPL (Ctrl-D to exit)

Flags: -p pipe mode, -q quiet, -m real|frac|int, -v version, -h help.
Several classic calc flags (-c -C -d -e -i -O -s -u) are accepted and ignored.

cargo build --release
./target/release/rcalc-web

sh
toRustCalcMCP --mcp # speak JSON-RPC 2.0 over stdio
``

Handshake → initialize, then tools/list, then tools/call. See
docs/MCP_TOOL_SCHEMA.json for the authoritative,
server-emitted schema and
examples/mcp-config.json`
for a client registration snippet.

calc_eval

evaluate an expression

calc_config

get/set session precision & display

calc_functions

list builtins

| tool | purpose | key args |
|------|---------|----------|
| calc_eval | evaluate an expression | expression (req), mode, digits, epsilon |
| calc_config | get/set session precision & display | action (get/set), mode, digits, epsilon |
| calc_functions | list builtins | filter (optional substring) |

calc_eval's mode/digits/epsilon are per-call overrides; calc_config set
changes them for the session.

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "a rust port of calc (landon curt noll's arbitrary-precision calculator)": {
            "toRustCalcMCP": {
                "command": "docker",
                "args": [
                    "run",
                    "-i",
                    "--rm",
                    "ghcr.io/carlomagnoglobal/torustcalcmcp:latest"
                ]
            }
        }
    }
}

McpServers

{
    "toRustCalcMCP": {
        "command": "docker",
        "args": [
            "run",
            "-i",
            "--rm",
            "ghcr.io/carlomagnoglobal/torustcalcmcp:latest"
        ]
    }
}

toRustCalcMCP

A Rust port of calc (Landon Curt Noll's
arbitrary-precision calculator) that works as:

- rcalc — a calc-compatible command-line calculator
- Web REPL — browser-based interactive calculator
- MCP server — JSON-RPC 2.0 over stdio for LLM/agent integration

Three interfaces, one engine. The numeric core uses exact rational arithmetic
(num-rational over num-bigint), which is the same model calc uses natively —
so 1/3 * 3 is exactly 1, and 2^256 is computed to the last digit.

👉 Getting Started in 2 minutes — new to rcalc? Start here.
👉 Install as Claude Desktop MCP — integrate with Claude Desktop.

Build

```sh
cargo build --release

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.