BC Calculator

MCP Server for the Unix bc calculator
  • python

0

GitHub Stars

python

Language

7 months ago

First Indexed

3 months ago

Catalog Refreshed

Documentation & install

Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.

Installation

Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "cthunter01-mcpcalculator": {
      "command": "node",
      "args": [
        "/home/travis/.local/share/Roo-Code/MCP/bc-calculator/build/index.js"
      ]
    }
  }
}

You can run a dedicated MCP server that uses the Unix bc calculator to perform high-precision arithmetic, advanced math functions, and scripted computations. It exposes a simple, reliable interface for evaluating expressions and executing BC scripts, with built-in security, concurrency, and MCP protocol support to handle multiple requests efficiently.

How to use

You communicate with the server using an MCP client to request calculations. Start with a basic expression to evaluate arithmetic or use the advanced calculator tool for BC scripts. You can set the default precision for results and reuse the same server for related calculations to take advantage of the internal process pool for faster responses. When you submit a calculation, the server validates inputs, sanitizes them, and returns either the numeric result or a detailed error describing validation, runtime, or timeout issues.

How to install

Prerequisites you need before installation include Node.js 18 or higher and bc, which is typically installed by default on Unix systems.

Verify bc is installed on your system.

> which bc
> bc --version

If bc is not installed, install it using your system package manager.

> # Ubuntu/Debian
> sudo apt-get install bc

> # macOS
> brew install bc

> # Fedora/RHEL
> sudo dnf install bc

Set up the MCP server directory and project structure. You have two options: bootstrap with a helper tool or create the structure manually.

> cd /home/travis/.local/share/Roo-Code/MCP

> npx @modelcontextprotocol/create-server bc-calculator
> cd bc-calculator

# Or manually
> mkdir -p bc-calculator/src
> cd bc-calculator

Install dependencies and build the server.

> npm install
> npm run build

Configure MCP settings so your client knows how to start the server. The following config uses a stdio (local) MCP setup with Node executing the built server entry point.

> cat << 'JSON' > ~/.config/Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/mcp_settings.json
{
  "mcpServers": {
    "bc-calculator": {
      "command": "node",
      "args": ["/home/travis/.local/share/Roo-Code/MCP/bc-calculator/build/index.js"]
    }
  }
}
JSON

Additional setup and notes

The server uses a pool of BC processes to handle multiple calculations concurrently, with fallbacks and safeguards in place to prevent long-running or unsafe computations. The standard calculation timeout is 30 seconds, and the default precision is 20 decimal places. You can increase pool size or timeout by editing the internal configuration if your workload requires it.

Configuration and security

Security is built into input handling and process management to prevent command injection and resource abuse. The server validates and sanitizes inputs, avoids shell execution, and enforces a maximum expression length. If a calculation times out or a BC runtime error occurs, you receive a structured error message detailing the issue.

Troubleshooting and tips

If you encounter issues starting the server, ensure the build index is executable and the path in the MCP settings matches your environment. Common problems include missing bc, permission errors, or timeouts due to complex expressions. For timeouts, increase the calculation timeout or pool size. If you see a pool exhaustion, consider increasing the pool size in your internal configuration.

Performance tips include reusing the same server for related calculations, leveraging calculate_advanced for multi-step BC scripts, and tuning precision to balance accuracy with speed.

Examples of usage patterns

Basic arithmetic and functions can be evaluated directly through the MCP client, while advanced scripts can perform loops, variables, and custom functions within BC.

Example outcomes show results and the exact expression that produced them, with the configured precision applied to the final value.

Available tools

calculate

Evaluate basic mathematical expressions with configurable precision through a simple MCP tool interface.

calculate_advanced

Run advanced BC scripts with variables, functions, and control flow to perform multi-step calculations.

set_precision

Set the default calculation precision for subsequent operations.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational
BC Calculator MCP Server - cthunter01/mcpcalculator | VeilStrat