Skip to main content
Glama
JamaalDavis

Calculator MCP Server

by JamaalDavis

Calculator MCP Server

A Model Context Protocol (MCP) server built with FastMCP that exposes a calculator as a set of tools, resources, and prompts for use by an LLM client.

Tools

  • Basic: add, subtract, multiply, divide

  • Advanced: power, square_root, percentage

Each tool validates its inputs (division by zero, negative square roots, undefined powers, zero-denominator percentages) and returns a formatted string, and logs every successful calculation to an in-memory history.

Resources

  • constants://math — pi, e, the golden ratio, and tau

  • history://calculations — a chronological log of every calculation made during the current session

Prompts

  • solve_equation(problem) — walks a word problem step by step, directing the model to use the calculator tools for arithmetic

  • calculation_help(topic) — explains which tools/resources are relevant to a topic, with a worked example

Running it

uv sync
uv run python calculator_server.py

Point an MCP client (e.g. Claude Desktop, or an MCP inspector) at that command over stdio.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/JamaalDavis/calculator-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server