Calculator MCP Server

Calculator MCP Server

A local MCP server providing basic arithmetic tools (add, subtract, multiply, divide, power, square root, percentage) and a recent-calculation history resource, designed for integration with Claude Desktop.

Category
Visit Server

README

My First MCP Server — Setup Journey

A step-by-step log of building and connecting my first Model Context Protocol server to Claude Desktop, using the official Python SDK. This README documents exactly what was done, in order, including the issues hit along the way.

Built on: macOS Monterey 12.7.6, Intel i5, 8GB RAM (2015 MacBook Pro).


What is MCP

MCP lets an app like Claude Desktop call out to a local program (a "server") for tools and live data, instead of relying only on the model's built-in knowledge. This project builds a simple calculator server and connects it to Claude Desktop as a working example.

SDK used: modelcontextprotocol/python-sdk


Steps followed

1. Install uv (Python package/project manager)

uv wasn't installed, so:

curl -LsSf https://astral.sh/uv/install.sh | sh
source $HOME/.local/bin/env
uv --version

2. Create the project

mkdir mcp-test && cd mcp-test
uv init
uv add "mcp[cli]"

Issue hit: uv init defaulted requires-python to >=3.14, a version with no prebuilt wheel for the cryptography dependency — uv add sat compiling it from source for a very long time.

Fix: pin the project to a more compatible Python version:

sed -i '' 's/requires-python = ">=3.14"/requires-python = ">=3.10"/' pyproject.toml
rm -rf .venv
uv venv --python 3.12
uv add "mcp[cli]"

This installed cleanly using a prebuilt wheel.

3. Write the server

Created calculator_server.py using mcp.server.MCPServer, exposing calculator functions as tools (add, subtract, multiply, divide, power, square_root, percentage) and a small in-memory calculation log as a resource (history://recent), so tool calls and resource reads could both be demonstrated.

4. Test locally with the MCP Inspector

uv run mcp dev calculator_server.py

Issue hit: npx not found — the Inspector needs Node.js, which wasn't installed.

Fix: installed Node via nvm (chosen over Homebrew, since Homebrew's latest Node bottle isn't well supported on macOS Monterey and risked a slow/failing source build):

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
source ~/.zshrc
nvm install 20
nvm use 20

Reran uv run mcp dev calculator_server.py — it started the Inspector proxy and printed a local URL with an auth token. Opened that URL in the browser and confirmed:

  • Tools tab → called multiply(6, 7) → got 42
  • Resources tab → opened history://recent → saw the call logged

5. Connect the server to Claude Desktop

In Claude Desktop: Settings → Developer → Local MCP servers → Edit Config.

Issue hit: manually opening claude_desktop_config.json via terminal initially showed an unrelated app-preferences file, not the MCP config — resolved by using the in-app Edit Config button instead of guessing the file path, since it opens the correct file for the installed build.

Added:

{
  "mcpServers": {
    "calculator": {
      "command": "/Users/<you>/.local/bin/uv",
      "args": [
        "--directory",
        "/Users/<you>/Documents/mcp-test",
        "run",
        "calculator_server.py"
      ]
    }
  }
}

Used the full path to uv (from which uv) since Claude Desktop's process doesn't inherit the terminal shell's PATH.

6. Verify it's actually working

In Settings → Developer, the calculator server showed status running.

In a chat, confirmed the calculator toggle was on under the "+" → connectors menu, then asked Claude a question it could only answer using the tool's live state:

"What's in my calculator history?"

First attempt returned no history — because the earlier questions asked ("what's 84 divided by 12") were simple enough that Claude just computed them mentally instead of calling the tool. Asking more explicitly:

"Use the calculator tool for 84 divided by 12, and 15% of 200."

produced a response tagged "used calculator integration" in the UI — confirming the tool call was real, not just model math.


Result

A working local MCP server with 7 tools and 1 resource, connected to Claude Desktop, verified end-to-end via real tool invocation (not just Claude's own arithmetic).

Project structure

mcp-test/
├── calculator_server.py   # the MCP server
├── pyproject.toml           # project + dependency config (Python >=3.10)
├── uv.lock                   # locked dependency versions
└── README.md                 # this file

Reference

  • SDK: https://github.com/modelcontextprotocol/python-sdk
  • Docs: https://py.sdk.modelcontextprotocol.io/

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured