simple-calculator-mcp-server
This document provides a tutorial on building a simple MCP calculator server and connecting it to Claude for Desktop.
The Model Context Protocol (MCP) allows developers to extend AI assistants with custom tools and servers, providing them with additional functionalities. This tutorial guides you through building a simple MCP calculator server that exposes four tools: add, subtract, multiply, and divide. The server is then connected to an MCP host, specifically Claude for Desktop, to demonstrate its capabilities. MCP servers can provide resources, tools, and prompts, but this tutorial focuses on tools. The server is built using Python and requires the Python MCP SDK 1.2.0 or higher. The tutorial includes steps for setting up the environment, implementing tool execution, and running the server. It also provides instructions for configuring Claude for Desktop to use the MCP server.
Features
- Customizable MCP server for AI assistants
- Supports basic arithmetic operations: add, subtract, multiply, divide
- Integration with Claude for Desktop
- Python-based implementation
- Utilizes FastMCP for server setup
MCP Tools
- {'add': 'Adds two numbers.'}
- {'subtract': 'Subtracts the second number from the first.'}
- {'multiply': 'Multiplies two numbers.'}
- {'divide': 'Divides the first number by the second, with error handling for division by zero.'}
Usage with Different Platforms
MacOS/Linux
bash
curl -LsSf https://astral.sh/uv/install.sh | sh
uv init calculator
cd calculator
uv venv
source .venv/bin/activate
uv add "mcp[cli]"
touch calculator.py
Windows
powershell
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
uv init calculator
cd calculator
uv venv
.venv\Scripts\activate
uv add "mcp[cli]"
new-item calculator.py
Related MCP Servers
View all developer_tools servers →Sequential Thinking🏅
by modelcontextprotocol
An MCP server implementation that provides a tool for dynamic and reflective problem-solving through a structured thinking process.
context7
by upstash
Context7 MCP provides up-to-date, version-specific documentation and code examples directly into your prompt, enhancing the capabilities of LLMs by avoiding outdated or hallucinated information.
git-mcp
by idosal
GitMCP is a free, open-source, remote Model Context Protocol (MCP) server that transforms GitHub projects into documentation hubs, enabling AI tools to access up-to-date documentation and code.
Everything MCP Server
by modelcontextprotocol
The Everything MCP Server is a comprehensive test server designed to demonstrate the full capabilities of the Model Context Protocol (MCP). It is not intended for production use but serves as a valuable tool for developers building MCP clients.
exa-mcp-server
by exa-labs
A Model Context Protocol (MCP) server allows AI assistants to use the Exa AI Search API for real-time web searches in a secure manner.
repomix
by yamadashy
Repomix is a tool that packages your entire codebase into a single, AI-friendly file, making it easier to use with AI tools like LLMs.
Sequential Thinking MCP Server
by modelcontextprotocol
An MCP server implementation that provides a tool for dynamic and reflective problem-solving through a structured thinking process.