Skip to main content

python License AI--Assisted

Calculator MCP Server

calculator-mcp is a Streamable HTTP MCP (Model Context Protocol) server that exposes 16 arithmetic operations as callable tools for an AI LLM (Large Language Model) to consume. It contains no math of its own — every tool is a thin synchronous wrapper that logs its arguments and delegates to the open-source calculator-lib-rubens PyPI package.

Features

16 calculator tools available via MCP based on JSON-RPC 2.0 messages:

Two-operand operations: add, subtract, multiply, divide, power, nth_root, modulo, floor_divide

Single-operand operations: sqrt, absolute, floor, ceil, log10, ln, exp

Rounding: round_number (with configurable decimal places)

AI Disclaimer

This project includes code and documentation created with the assistance of AI tools. For details on usage, limits, and review practices, please see the AI Disclaimer.

Installation

Prerequisites

  • UNIX OS (e.g., macOS, Linux)
  • curl 8.7+
  • pip 26.2+
  • poetry 2.4+
  • python 3.14+

PyPI Package Installation

IMPORTANT: release versioning was recently reset to start again at version 0.0.1. Uninstall any previously installed version first.

  1. Uninstall any previously installed release
pip uninstall calculator-mcp-rubens
# purging the cache is recommended as well
pip cache purge
  1. Install into the user's home environment
# install "calculator-mcp" and dependencies into user local pip environment
# NOTE: use --no-cache-dir to avoid issues with an earlier cached version
pip --no-cache-dir install -U --user calculator-mcp-rubens --verbose
  1. Confirm the installed version matches the latest GitHub release at calculator-mcp/releases
# show the installed version
pip show calculator-mcp-rubens

Git Clone Installation

  1. git clone and install local project package using poetry
# use local `dev` folder to install the project
mkdir -p ~/dev || exit; cd ~/dev
git clone https://github.com/rubensgomes-org/calculator-mcp.git
# change to project git local directory
cd calculator-mcp
# ensure we are at the project git local root folder
cd $(git rev-parse --show-toplevel) || exit
poetry install

Usage

Configuration

The server ships with a default config.yaml bundled inside the PyPI package. To override it, set the CALCULATOR_MCP_CONFIG environment variable to the absolute path of your custom configuration file:

# assumming config_local.yaml placed in my home folder
export CALCULATOR_MCP_CONFIG="${HOME}/cfg/calculator-mcp/config_local.yaml"

Running Using PyPI Package

NOTE: requires prior installation using pip install -U --user calculator-mcp-rubens.

  1. Make a copy of config_local.yaml to a local home directory (e.g., ${HOME}/cfg/calculator-mcp/config_local.yaml).

  2. Launch the PyPI-installed calculator-mcp package:

# config_local.yaml placed in my home folder
export CALCULATOR_MCP_CONFIG="${HOME}/cfg/calculator-mcp/config_local.yaml"
# using installed package from PyPI:
calculator-mcp
  1. Health check
# ensure config_local.yaml port is 8080
curl -v http://localhost:8080/health
# Expect: OK

Running Using Git Cloned Project

NOTE: requires prior cloning of the project using git.

  1. Make a copy of config_local.yaml to a local home directory (e.g., ${HOME}/cfg/calculator-mcp/config_local.yaml).

  2. Launch calculator-mcp from the local Git repo folder

# On my machine the project is installed here:
pushd ~/github/rubens/dev/python/calculator-mcp/
# ensure we are at the project git local root folder
cd $(git rev-parse --show-toplevel) || exit
# config_local.yaml placed in my home folder
export CALCULATOR_MCP_CONFIG="${HOME}/cfg/calculator-mcp/config_local.yaml"
poetry run calculator-mcp
  1. Health check
# ensure config_local.yaml port is 8080
curl -v http://localhost:8080/health
# Expect: OK
  1. To stop, go to the running terminal and press Ctrl+C

Integration Test Using Git Cloned Project

NOTE: requires prior cloning of the project using git.

  1. Launch calculator-mcp locally from the local Git repo folder
# On my machine the project is installed here:
pushd ~/github/rubens/dev/python/calculator-mcp/
# ensure we are at the project git local root folder
cd $(git rev-parse --show-toplevel) || exit
# config_local.yaml placed in my home folder
export CALCULATOR_MCP_CONFIG="${HOME}/cfg/calculator-mcp/config_local.yaml"
poetry run calculator-mcp
  1. Integration test using local MCP server
# On my machine the project is installed here:
pushd ~/github/rubens/dev/python/calculator-mcp/
# ensure we are at the project git local root folder
cd $(git rev-parse --show-toplevel) || exit
# config_local.yaml placed in my home folder
export CALCULATOR_MCP_CONFIG="${HOME}/cfg/calculator-mcp/config_local.yaml"
poetry run python tests/integration/client.py
  1. Integration test using remote MCP server

NOTE: Requires OAuth authentication which currently only Rubens is able to authorize using his personal GitHub account.

# On my machine the project is installed here:
pushd ~/github/rubens/dev/python/calculator-mcp/
# ensure we are at the project git local root folder
cd $(git rev-parse --show-toplevel) || exit
# config_remote.yaml placed in my home folder
export CALCULATOR_MCP_CONFIG="${HOME}/cfg/calculator-mcp/config_remote.yaml"
poetry run python tests/integration/client.py

Modern MCP (Version: 2026-07-28)

The "Modern Era MCP" server is stateless which is the default configuration in this project configuration file. Each tools/call is a single request; no handshake is needed.

  1. Launch calculator-mcp locally
# On my machine the project is installed here:
pushd ~/github/rubens/dev/python/calculator-mcp/
# ensure we are at the project git local root folder
cd $(git rev-parse --show-toplevel) || exit
# config_local.yaml placed in my home folder
export CALCULATOR_MCP_CONFIG="${HOME}/cfg/calculator-mcp/config_local.yaml"
poetry run calculator-mcp
  1. Retrieve the MCP server identity server/discover
curl -sS -X POST http://localhost:8080/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "Mcp-Protocol-Version: 2026-07-28" \
  -H "Mcp-Method: server/discover" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "server/discover",
    "params": {
      "_meta": {
        "io.modelcontextprotocol/protocolVersion": "2026-07-28",
        "io.modelcontextprotocol/clientInfo": {"name": "curl", "version": "1.0"},
        "io.modelcontextprotocol/clientCapabilities": {}
      }
    }
  }' | jq .
  1. List tools tools/list
curl -sS -X POST http://localhost:8080/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "Mcp-Protocol-Version: 2026-07-28" \
  -H "Mcp-Method: tools/list" \
  -d '{
    "jsonrpc": "2.0",
    "id": 2,
    "method": "tools/list",
    "params": {
      "_meta": {
        "io.modelcontextprotocol/protocolVersion": "2026-07-28",
        "io.modelcontextprotocol/clientInfo": {"name": "curl", "version": "1.0"},
        "io.modelcontextprotocol/clientCapabilities": {}
      }
    }
  }' | jq .
  1. Add two numbers tools/call
curl -sS -X POST http://localhost:8080/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "Mcp-Protocol-Version: 2026-07-28" \
  -H "Mcp-Method: tools/call" \
  -H "Mcp-Name: add" \
  -d '{
    "jsonrpc": "2.0",
    "id": 3,
    "method": "tools/call",
    "params": {
      "name": "add",
      "arguments": {"a": 2, "b": 2},
      "_meta": {
        "io.modelcontextprotocol/protocolVersion": "2026-07-28",
        "io.modelcontextprotocol/clientInfo": {"name": "curl", "version": "1.0"},
        "io.modelcontextprotocol/clientCapabilities": {}
      }
    }
  }' | jq .

Legacy MCP (Version: 2025-06-18)

The Legacy Era MCP server is based on a stateful session that requires a connection setup handshake using initialize / initialized JSON-RPC messages.

NOTE: To run the "Legacy MCP" protocol, set server.stateless to false in config.yaml.

  1. Launch calculator-mcp locally in "stateful" mode
# On my machine the project is installed here:
pushd ~/github/rubens/dev/python/calculator-mcp/
# ensure we are at the project git local root folder
cd $(git rev-parse --show-toplevel) || exit
# config_local_stateful.yaml placed in my home folder
export CALCULATOR_MCP_CONFIG="${HOME}/cfg/calculator-mcp/config_local_stateful.yaml"
poetry run calculator-mcp
  1. Initialize MCP session initialize. Grab the value of mcp-session-id from the response headers.
curl -sS -i -X POST http://localhost:8080/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "initialize",
    "params": {
      "protocolVersion": "2025-06-18",
      "capabilities": {},
      "clientInfo": {"name": "curl", "version": "1.0"}
    }
  }'
  1. Complete Session Handshake
pause() {
  printf "\nPress Return to continue..."
  read -r _
  printf "\n"
}

#
# 1) Initialize: grab mcp-session-id
#
export SID="$(
  curl -sS -i -X POST http://localhost:8080/mcp \
      -H "Content-Type: application/json" \
      -H "Accept: application/json, text/event-stream" \
      -d '{
        "jsonrpc": "2.0",
        "id": 1,
        "method": "initialize",
        "params": {
          "protocolVersion": "2025-06-18",
          "capabilities": {},
          "clientInfo": {"name": "curl", "version": "1.0"}
        }
      }' | awk -F': ' 'tolower($1)=="mcp-session-id" {print $2}' | tr -d '\r'
  )"

printf "\nSID=%s\n" "${SID}"
read -r _

#
# 2) Confirm session initialization
#

# Expect "202 Accepted" response
curl -q -s -o /dev/null -w "%{http_code}\n" http://localhost:8080/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "Mcp-Session-Id: ${SID}" \
  -d '{
    "jsonrpc":"2.0",
    "method":"notifications/initialized"
  }'
pause

#
# 3) List tools -- NOT JSON response !!!
#
curl -s http://localhost:8080/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "Mcp-Session-Id: $SID" \
  -d '{
    "jsonrpc":"2.0",
    "id":2,
    "method":"tools/list"
  }'
pause

#
# 4) List tools -- NEEDS to parse response to get tools data
#
printf "Parsing response to extract tools data...\n"

#curl -s http://localhost:8080/mcp \
#  -H "Content-Type: application/json" \
#  -H "Accept: application/json, text/event-stream" \
#  -H "Mcp-Session-Id: $SID" \
#  -d '{
#    "jsonrpc":"2.0",
#    "id":2,
#    "method":"tools/list"
#  }' | sed -n 's/^data://p' | jq .
  
#
# 5) Call a tool to add numbers `tools/call`
#

License

The project is licensed under MIT License.


Author: Rubens Gomes

Release files for calculator-mcp-rubens 0.0.22

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for calculator-mcp-rubens 0.0.22
File Size Uploaded
calculator_mcp_rubens-0.0.22.tar.gz 13.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for calculator-mcp-rubens 0.0.22
File Interpreter ABI Platform
calculator_mcp_rubens-0.0.22-py3-none-any.whl Python 3 none any Details

Total release size: 29.5 kB

Release files / calculator_mcp_rubens-0.0.22.tar.gz

Download URL calculator_mcp_rubens-0.0.22.tar.gz
Size 13.6 kB
Tags Source
SHA-256 checksum
How to use checksums
3894224d8891b88b07c403061dc67f65a12241067943076ba3dde9b3908bf6e9
BLAKE2b-256 checksum
How to use checksums
d3e460baf768b89c9f8f21ac6094edda5f74d241478e741daee662b7a8905e80
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.3 CPython/3.14.7 Linux/6.17.0-1022-azure

Release files / calculator_mcp_rubens-0.0.22-py3-none-any.whl

Download URL calculator_mcp_rubens-0.0.22-py3-none-any.whl
Size 16.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f155d330454337d136a2fcb40c51be65a8fdb41a3c86d2a0e0d02296957549aa
BLAKE2b-256 checksum
How to use checksums
68f211b33d9d127401fc2d3133093bb52aa56922fdab3c5836f96087353dfcc6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.3 CPython/3.14.7 Linux/6.17.0-1022-azure

Release history Release notifications | RSS feed

This release

0.0.22 This release

2 release files

0.0.21

2 release files

0.0.20

2 release files

0.0.19

2 release files

0.0.18

2 release files

0.0.17

2 release files

0.0.16

2 release files

0.0.15

2 release files

0.0.14

2 release files

0.0.13

2 release files

0.0.12

2 release files

0.0.11

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page