mcp-arithmetic-utility
A simple Model Context Protocol service offering fundamental numerical computations like summing, differencing, product calculation, and quotient derivation for LLM augmentation.
Author

simonberner
Quick Info
Actions
Tags
Building an MCP Endpoint: Arithmetic Service Example
Overview
This repository presents a minimal demonstration of creating an MCP server capable of executing basic arithmetic procedures for an MCP client application.
What is MCP?
Model Context Protocol (MCP) defines a standardized mechanism enabling Large Language Models (LLMs) to invoke external, custom capabilities and services. An MCP client leverages this protocol to query registered MCP servers for specific functions. This artifact specifically implements a server providing elementary mathematical functions.
"MCP furnishes a unified, consistent interface for artificial intelligence systems to interface with external computational environments. Code written once becomes universally accessible across diverse AI frameworks." 1
"Servers form the essential infrastructure layer that enhances the contextual knowledge and external data access capabilities of LLMs." 2
Technical Foundation
- Python 3 Environment
- Pytest for verification
- MCP Software Development Kit (SDK)
- MCP Command Line Interface (CLI)
- Nix (Optional for environment management)
Deployment and Utilization Guide
Integration via Smithery
To seamlessly integrate mcp-arithmetic-utility with supported clients (e.g., Claude Desktop) using Smithery:
bash npx -y @smithery/cli install @simonberner/mcp-server-calculator --client claude
Local Development Setup
Due to the inclusion of Nix, this project ensures an isolated and repeatable development environment, negating the necessity for manual setup of Python or transitive dependencies. System prerequisites include installing Nix.
- Install the direnv utility (for environment loading).
- Install Lix (if using the Nix dependency management approach).
- Obtain the repository source code via cloning.
- Navigate into the project directory.
- Execute
direnv allowto activate the environment. - Run tests with
pytest.
Alternate Installation Path
Should the Smithery or Nix methodologies be unsuitable, standard package management tools like uv can be utilized for building and installing the package:
bash
Fetch and execute the uv installer (consult https://astral.sh/uv/getting-started/installation/ for latest)
curl -LsSf https://astral.sh/uv/install.sh | sh
Establish a virtual environment named .venv
uv venv
Activate the environment (example for bash/zsh shells)
source .venv/bin/activate
Proceed with installation or packaging
uv pip install -e .
OR create distribution wheels
uv pip wheel . -w dist
Server Execution and Verification
Testing your custom MCP service locally is simplified using the MCP Inspector, a graphical interface available at http://localhost:5173, which bypasses immediate LLM integration:
bash mcp dev src/mcp_server_calculator/calculator.py
Host Integration Configuration
To enable an MCP Host environment (like a local proxy) to communicate with this calculator service, update its configuration file with the following block:
{
"mcpServers": {
"calculator": {
"command": "python",
"args": [
"
Operational Notes
- When leveraging Windsurf IDE as the MCP Host, access to Cascade functionality (for MCP Client operations with servers) necessitates a Pro Plan.
Identified Challenges
Consult the Issues tracker for a roster of existing problems or to report novel incidents.
Supporting Documentation
- [1] MCP server: A step-by-step guide to building from scratch
- [2] What is Model Context Protocol (MCP)?
- Understanding MCP and how AI engineers can leverage it
- MCP SDK Documentation
- MCP CLI Documentation
- MCP Inspector Repository
- The largest catalog of published MCP Servers
- A Beginner's Guide to utilizing MCP
- Claude MCP has Revolutionized AI - Critical Insights
- Locating available MCP Services
- Rapidly construct your initial MCP service using TypeScript
- Model Context Protocol (MCP) Initial Primer
Acknowledgment
- The environment configuration scaffolding for Nix was adapted from the ical2json project.
Supplemental Knowledge
Nix Ecosystem
- Rationale for adopting Nix?
- Why utilize Lix?
- Search the Nix Package Repository
- Reference for the nix-shell command
