How to build an MCP server - Calculator Example
@simonberner
About How to build an MCP server - Calculator Example
Example project showing how to build a simple MCP Server (and having it on Smithery!)
Config
Add this server to your MCP-compatible client using the configuration below.
{
"mcpServers": {
"mcp-server-calculator-simonberner": {
"command": "npx",
"args": [
"-y",
"@smithery/cli",
"install",
"@simonberner/mcp-server-calculator",
"--client",
"claude"
]
}
}
}Tools
No tools detected
Fetch the live tool list by running this server in a temporary sandbox using the button above.
Overview
What is How to build an MCP server - Calculator Example?
This is a simple example MCP server that provides basic math operations (addition, subtraction, multiplication, division) to an MCP client. It demonstrates how to build an MCP server from scratch using Python and the MCP SDK, intended for developers learning the Model Context Protocol.
How to use How to build an MCP server - Calculator Example?
Install automatically via Smithery (npx -y @smithery/cli install @simonberner/mcp-server-calculator --client claude), or set up the development environment using Nix/direnv or manually with uv. Run locally with mcp dev src/mcp_server_calculator/calculator.py and test using MCP Inspector. Integrate with an MCP host by adding the server configuration to the host's mcp config file (e.g., for Claude Desktop).
Key features of How to build an MCP server - Calculator Example
- Provides basic math operations: add, subtract, multiply, divide.
- Built with Python 3 and the MCP SDK.
- Supports installation via Smithery, Nix, or uv.
- Testable via MCP Inspector web interface.
- Includes unit tests with pytest.
Use cases of How to build an MCP server - Calculator Example
- Learning how to build an MCP server from scratch.
- Prototyping a simple math tool for AI agents.
- Testing MCP client-server interactions locally.
FAQ from How to build an MCP server - Calculator Example
What is MCP?
Model Context Protocol (MCP) is a protocol that enables LLMs to access custom tools and services. An MCP client can make requests to MCP servers to access tools they provide.
How do I install this server?
You can install it via Smithery, use the Nix development environment with direnv, or set it up manually with uv. For hosts like Claude Desktop, add the server configuration to your mcp config.
What dependencies are required?
Python 3, the MCP SDK, the MCP CLI, and pytest. Optionally Nix (or Lix) for a reproducible environment.
How do I test the server locally without an LLM?
Run mcp dev src/mcp_server_calculator/calculator.py and open MCP Inspector at http://localhost:5173 to test the server via a GUI.
Where does server data live?
The server is stateless; all math operations are computed in memory and no data is persisted.
What transport does it use?
The server runs as a Python script over stdio, configured locally in the MCP host’s configuration file. It is not a remote server.
Frequently asked questions
What is MCP?
Model Context Protocol (MCP) is a protocol that enables LLMs to access custom tools and services. An MCP client can make requests to MCP servers to access tools they provide.
How do I install this server?
You can install it via Smithery, use the Nix development environment with direnv, or set it up manually with `uv`. For hosts like Claude Desktop, add the server configuration to your mcp config.
What dependencies are required?
Python 3, the MCP SDK, the MCP CLI, and pytest. Optionally Nix (or Lix) for a reproducible environment.
How do I test the server locally without an LLM?
Run `mcp dev src/mcp_server_calculator/calculator.py` and open MCP Inspector at http://localhost:5173 to test the server via a GUI.
Where does server data live?
The server is stateless; all math operations are computed in memory and no data is persisted.
What transport does it use?
The server runs as a Python script over stdio, configured locally in the MCP host’s configuration file. It is not a remote server.
Basic information
More Developer Tools MCP servers

TaskerArmy Agent
TaskerArmyAsk Claude or ChatGPT what Shopify theme optimization tasks are pending on your store, a remote MCP server for TaskerArmy Agent accounts.
TranscriptFetch MCP Server
TranscriptFetchModel Context Protocol (MCP) server for TranscriptFetch: fetch YouTube transcripts, search, channels, and playlists from any MCP client.
Hello World MCP Server (Reference Extension)
anthropicsDesktop Extensions: One-click local MCP server installation in desktop apps
Unity MCP (Server + Plugin)
IvanMurzakAI Skills, MCP Tools, and CLI for Unity Engine. Full AI develop and test loop. Use cli for quick setup. Efficient token usage, advanced tools. Any C# method may be turned into a tool by a single line. Works with Claude Code, Gemini, Copilot, Cursor and any other absolutely for fr

PuzzleTide Puzzle Generator
Caravaca-LabsWord search generator, crossword generator, and sudoku generator + solver as a local-first MCP server. 15 deterministic tools: printable PDF puzzle worksheets, themed word banks, and verifiable LLM evals. From the makers
Comments