MCP Calculator Server
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
MCP Calculator Server
A simple Model Context Protocol (MCP) server written in Python that exposes basic calculator operations as tools. It works with Claude Desktop and any other MCP-compatible client (Claude Code, Cursor, VS Code, MCP Inspector, etc.).
It is intentionally small, which makes it a good starting point for learning how MCP servers are built.
Features
The server exposes the following tools:
Tool | Arguments | Description |
|
| Returns |
|
| Returns |
|
| Returns |
|
| Returns |
|
| Returns |
|
| Square root (errors if |
|
| Returns |
Related MCP server: MCP Calculator Server
Requirements
Python 3.10 or newer
The official MCP Python SDK (both v1.x and v2.x are supported)
Installation
Option A: using uv (recommended)
git clone https://github.com/<your-username>/mcp-calculator-server.git
cd mcp-calculator-server
uv sync # creates .venv and installs dependencies from pyproject.tomlIf you are starting from scratch instead of cloning, the equivalent is:
uv init mcp-calculator-server
cd mcp-calculator-server
uv add "mcp[cli]"Option B: using pip
git clone https://github.com/<your-username>/mcp-calculator-server.git
cd mcp-calculator-server
# (recommended) create a virtual environment
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txtRunning and testing
The server uses the stdio transport, so normally an MCP client launches it for you. To test it interactively with the MCP Inspector:
uv run mcp dev calculator_server.py # with uv
mcp dev calculator_server.py # with pip / activated venvThis opens a web UI where you can list the tools and call them with different inputs.
You can also run the server directly (it will wait for MCP messages on stdin):
uv run calculator_server.py # with uv
python calculator_server.py # with pip / activated venvConnecting to Claude Desktop
Open Claude Desktop and go to Settings → Developer → Edit Config. This opens
claude_desktop_config.json:Windows:
%APPDATA%\Claude\claude_desktop_config.jsonmacOS:
~/Library/Application Support/Claude/claude_desktop_config.json
Add the server (see
claude_desktop_config.example.json).With uv (recommended):
{ "mcpServers": { "calculator": { "command": "uv", "args": [ "--directory", "/absolute/path/to/mcp-calculator-server", "run", "calculator_server.py" ] } } }--directorymust point to the project folder (the one containingpyproject.toml). On Windows, use forward slashes or double the backslashes (D:\\projects\\mcp-calculator-server).If Claude Desktop cannot find
uv, use its full path ascommand. Find it withwhere uv(Windows) orwhich uv(macOS/Linux), e.g.C:\\Users\\<you>\\.local\\bin\\uv.exe.
With plain Python instead:
{ "mcpServers": { "calculator": { "command": "/path/to/venv/bin/python", "args": ["/absolute/path/to/mcp-calculator-server/calculator_server.py"] } } }Fully quit and restart Claude Desktop.
Click the tools icon in the chat box. You should see
calculatorlisted.Try a prompt such as: "Use the calculator to multiply 127 by 43, then take the square root of the result."
Using with VS Code (GitHub Copilot)
This repo includes .vscode/mcp.json, so VS Code picks the server up automatically when you open the project folder:
{
"servers": {
"calculator": {
"type": "stdio",
"command": "uv",
"args": ["--directory", "${workspaceFolder}", "run", "calculator_server.py"]
}
}
}Open the project folder in VS Code (
uv syncfirst so dependencies are installed).Open
.vscode/mcp.jsonand click Start above thecalculatorentry (or run MCP: List Servers from the Command Palette).Open Copilot Chat and switch the mode to Agent.
Click the tools icon and make sure the
calculatortools are ticked.Ask: "Use the calculator tools to multiply 127 by 43, then take the square root." and click Allow when asked.
Note that VS Code uses a top-level servers key, while Claude Desktop uses mcpServers.
Using with other MCP clients
Because this is a standard stdio server, any client that can launch a local command can use it.
Claude Code:
claude mcp add calculator -- uv --directory /absolute/path/to/mcp-calculator-server run calculator_server.pyOther clients (Cursor, VS Code, etc.): add a server entry with python as the command and the path to calculator_server.py as the argument. Check your client's docs for the exact config file.
Optional: HTTP transport
To serve over HTTP instead of stdio, change the last line of calculator_server.py to:
mcp.run(transport="streamable-http")Troubleshooting
Server doesn't show up in Claude Desktop: check
claude_desktop_config.jsonfor JSON syntax errors, then fully restart the app. Logs are in%APPDATA%\Claude\logs\(Windows) or~/Library/Logs/Claude/(macOS); look formcp-server-calculator.log.No module named 'mcp': the Python used by Claude Desktop is not the one where you installed the package. Use the uv config above, or pointcommandat the exact interpreter you used withpip install.spawn uv ENOENToruvnot found: Claude Desktop can't seeuvon its PATH. Use the full path touvascommand.Connection errors or garbled output: never use
print()in a stdio server, since stdout carries the protocol. Uselogging(stderr) instead.
Notes on MCP SDK versions
In MCP Python SDK v2, FastMCP was renamed to MCPServer (mcp.server.mcpserver). This project imports MCPServer and automatically falls back to mcp.server.fastmcp.FastMCP on v1, so it runs on either version. The error No module named 'mcp.server.fastmcp' means you are on v2 and are running an older copy of this code; update calculator_server.py or pin mcp<2. See the v1 to v2 migration guide.
Project structure
mcp-calculator-server/
├── calculator_server.py # The MCP server
├── pyproject.toml # Project metadata and dependencies (uv)
├── requirements.txt # Dependencies for pip users
├── claude_desktop_config.example.json # Example Claude Desktop config
├── .vscode/mcp.json # VS Code / GitHub Copilot MCP config
├── .gitignore
├── LICENSE
└── README.mdExtending the server
Adding a new tool takes a few lines. Decorate a typed function with a docstring:
@mcp.tool()
def absolute(x: float) -> float:
"""Return the absolute value of x."""
return abs(x)The type hints and docstring are used to generate the tool's schema and description, which is what the AI model sees when deciding how to call it.
Contributing
Issues and pull requests are welcome. Feel free to open an issue for bugs or feature ideas.
License
Released under the MIT License.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
This MCP server enables users to perform scientific computations regarding linear algebra and vect…
Educational MCP server with 17 math/stats tools, visualizations, and persistent workspace
Unofficial Math.js MCP — wraps the mathjs.org API (free, no auth)
All 20 YourAITools agent APIs in one MCP server. Most tools free; pay with credits or x402.
Related MCP Servers
- FlicenseAqualityDmaintenanceProvides basic arithmetic operations (add, subtract, multiply, divide) through MCP, enabling AI clients to perform calculations via natural language.4-
- FlicenseNot gradedqualityDmaintenanceExposes calculator operations (add, subtract, multiply, divide, power) as MCP tools, allowing users to perform arithmetic calculations through natural language in MCP-compatible clients like Cursor.-
- FlicenseNot gradedqualityCmaintenanceEnables AI agents to perform arithmetic operations such as addition, subtraction, multiplication, and division through standardized MCP tools.1-
- FlicenseAqualityCmaintenanceEnables MCP clients such as Claude Desktop to perform basic arithmetic operations—addition, subtraction, multiplication, division, exponentiation, and square root—through exposed tools.6-