Calculator MCP Server
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Calculator MCP Serverwhat is 15 times 7?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Calculator MCP Server
A simple Model Context Protocol (MCP) server that provides basic calculator operations as tools for Claude Desktop and other MCP clients.
Features
Add: Sum two numbers
Subtract: Find the difference between two numbers
Multiply: Calculate the product of two numbers
Divide: Divide numbers with proper zero-division handling
All operations support integers, floating-point numbers, and negative numbers.
Related MCP server: Math Operations MCP Server
Installation
Prerequisites
Python 3.10 or higher
pip (Python package manager)
Steps
Clone or download this repository
git clone https://github.com/snedea/calc-mcp-server.git
cd calc-mcp-serverInstall dependencies
pip install -r requirements.txtThis installs:
fastmcp>=2.0.0- MCP frameworkpytest>=7.0.0- Testing framework
Usage
Testing the Server
Run the server standalone to verify it works:
python3 calc_server.pyYou should see:
🧮 Calculator MCP Server Starting
📋 Available tools:
- add(a, b): Add two numbers
- subtract(a, b): Subtract b from a
- multiply(a, b): Multiply two numbers
- divide(a, b): Divide a by b (handles zero)
💡 Configure in Claude Desktop to use these tools!Press Ctrl+C to stop the server.
Configuring in Claude Desktop
To use these calculator tools in Claude Desktop:
Locate your Claude Desktop config file:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.json
Edit the config file (create it if it doesn't exist):
{
"mcpServers": {
"calculator": {
"command": "python3",
"args": ["/absolute/path/to/calc-mcp-server/calc_server.py"]
}
}
}Important: Replace /absolute/path/to/calc-mcp-server/ with the actual full path to this directory.
Restart Claude Desktop
The calculator tools will now be available! Claude can use them automatically when you ask questions involving calculations.
Available Tools
add(a, b)
Add two numbers together.
Parameters:
a(float): First numberb(float): Second number
Returns: JSON with operation details and result
Example:
Input: add(5, 3)
Output: {
"operation": "add",
"a": 5,
"b": 3,
"result": 8
}subtract(a, b)
Subtract the second number from the first.
Parameters:
a(float): Number to subtract fromb(float): Number to subtract
Returns: JSON with operation details and result
Example:
Input: subtract(10, 3)
Output: {
"operation": "subtract",
"a": 10,
"b": 3,
"result": 7
}multiply(a, b)
Multiply two numbers together.
Parameters:
a(float): First numberb(float): Second number
Returns: JSON with operation details and result
Example:
Input: multiply(4, 5)
Output: {
"operation": "multiply",
"a": 4,
"b": 5,
"result": 20
}divide(a, b)
Divide the first number by the second.
Parameters:
a(float): Numeratorb(float): Denominator
Returns: JSON with operation details and result, or error if dividing by zero
Example:
Input: divide(10, 2)
Output: {
"operation": "divide",
"a": 10,
"b": 2,
"result": 5
}
Input: divide(10, 0)
Output: {
"error": "Cannot divide by zero"
}Testing
Run the test suite to verify all operations work correctly:
pytest tests/test_calculator.py -vExpected output:
tests/test_calculator.py::TestAddition::test_add_positive_numbers PASSED
tests/test_calculator.py::TestAddition::test_add_negative_numbers PASSED
... (30+ tests)
================================ 30 passed in 0.XX s ================================All tests should pass, covering:
Basic arithmetic operations
Edge cases (zero, negatives, decimals)
Error handling (division by zero)
JSON response format validation
Project Structure
calc-mcp-server/
├── calc_server.py # Main MCP server with calculator tools
├── requirements.txt # Python dependencies
├── tests/
│ └── test_calculator.py # Comprehensive unit tests
├── README.md # This file
└── .gitignore # Git exclusionsTroubleshooting
Tools don't appear in Claude Desktop
✅ Check that the config file path is correct for your OS
✅ Verify the
argspath is absolute (not relative)✅ Ensure Python 3.10+ is installed:
python3 --version✅ Confirm FastMCP is installed:
pip show fastmcp✅ Restart Claude Desktop completely
Import errors when running server
✅ Install dependencies:
pip install -r requirements.txt✅ Use Python 3.10 or higher
✅ Consider using a virtual environment:
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install -r requirements.txt
Tests failing
✅ Ensure pytest is installed:
pip install pytest✅ Run from the project root directory
✅ Check Python version is 3.10+
Technologies Used
Python 3.10+: Modern Python with type hints
FastMCP 2.0+: Official MCP framework for Python
pytest: Testing framework
How It Works
MCP (Model Context Protocol) is a standard for connecting AI assistants like Claude to external tools and data sources. This server:
Defines calculator operations as Python functions
Decorates them with
@mcp.tool()to expose them via MCPCommunicates with Claude Desktop using standard input/output (stdio transport)
Returns structured JSON responses for reliable parsing
Claude can then call these tools automatically when needed for calculations!
License
MIT
Contributing
Contributions welcome! Feel free to:
Report bugs
Suggest new calculator features
Improve documentation
Add more tests
Created By
🤖 Generated with Context Foundry - Autonomous Development Platform
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/snedea/calc-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server