CalculatorMcpServer

jamesburton/CalculatorMcpServer

3.2

If you are the rightful owner of CalculatorMcpServer and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

The Calculator MCP Server is a simple calculator implementation using the Model Context Protocol (MCP) built with .NET 9 and MCPSharp.

Tools
5
Resources
0
Prompts
0

Calculator MCP Server

A simple calculator implementation using the Model Context Protocol (MCP) built with .NET 9 and MCPSharp.

Build and Release License: MIT

Features

This MCP server provides the following calculator 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 division by zero protection)
  • square: Squares a number

Installation

Option 1: Download Pre-built Binaries

Download the latest release for your platform from the Releases page:

  • Windows: CalculatorMcpServer-win-x64.zip or CalculatorMcpServer-win-arm64.zip
  • Linux: CalculatorMcpServer-linux-x64.tar.gz or CalculatorMcpServer-linux-arm64.tar.gz
  • macOS: CalculatorMcpServer-osx-x64.tar.gz or CalculatorMcpServer-osx-arm64.tar.gz

Extract the archive and run the executable directly - no .NET runtime installation required!

Option 2: Docker Container

Pull and run the latest Docker image:

# Pull from GitHub Container Registry
docker pull ghcr.io/jamesburton/calculatormcpserver:latest

# Run the container
docker run -it ghcr.io/jamesburton/calculatormcpserver:latest

Option 3: Build from Source

Requirements:

  • .NET 9.0 SDK or later
git clone https://github.com/jamesburton/CalculatorMcpServer.git
cd CalculatorMcpServer
dotnet build --configuration Release
dotnet run --project CalculatorMcpServer

Usage

Basic Usage

Run the calculator MCP server:

# From extracted binary
./CalculatorMcpServer

# From Docker
docker run -it ghcr.io/jamesburton/calculatormcpserver:latest

# From source
dotnet run --project CalculatorMcpServer

The server will start and listen for MCP connections. You'll see:

Calculator MCP Server is running. Press Enter to exit.

MCP Client Integration

Claude Desktop Configuration

Add the following to your Claude Desktop configuration file:

Windows: %APPDATA%\Claude\claude_desktop_config.json macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Linux: ~/.config/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "calculator": {
      "command": "/path/to/CalculatorMcpServer",
      "args": []
    }
  }
}

Replace /path/to/CalculatorMcpServer with the actual path to your executable.

Docker Integration
{
  "mcpServers": {
    "calculator": {
      "command": "docker",
      "args": ["run", "-i", "ghcr.io/jamesburton/calculatormcpserver:latest"]
    }
  }
}

Available Tools

Once connected, you can use these calculator functions:

  1. add(a, b) - Add two numbers

    add(5, 3) → 8
    
  2. subtract(a, b) - Subtract b from a

    subtract(10, 4) → 6
    
  3. multiply(a, b) - Multiply two numbers

    multiply(6, 7) → 42
    
  4. divide(a, b) - Divide a by b

    divide(15, 3) → 5.0
    
  5. square(a) - Square a number

    square(4) → 16
    

Development

Project Structure

CalculatorMcpServer/
ā”œā”€ā”€ CalculatorMcpServer/          # Main project
│   ā”œā”€ā”€ Calculator.cs             # Calculator implementation
│   ā”œā”€ā”€ Program.cs               # Entry point
│   └── CalculatorMcpServer.csproj
ā”œā”€ā”€ CalculatorMcpServer.Tests/    # Unit tests
│   ā”œā”€ā”€ CalculatorTests.cs       # Test cases
│   └── CalculatorMcpServer.Tests.csproj
ā”œā”€ā”€ .github/workflows/           # CI/CD pipelines
ā”œā”€ā”€ Dockerfile                   # Container definition
└── README.md                   # This file

Building

# Build the solution
dotnet build

# Run tests
dotnet test

# Create a release build
dotnet publish --configuration Release --runtime win-x64 --self-contained

Testing

The project includes comprehensive unit tests:

# Run all tests
dotnet test

# Run tests with coverage
dotnet test --collect:"XPlat Code Coverage"

Docker Development

# Build the Docker image
docker build -t calculator-mcp-server .

# Run the container
docker run -it calculator-mcp-server

Cross-Platform Support

This project supports the following platforms:

  • Windows: x64, ARM64
  • Linux: x64, ARM64
  • macOS: x64, ARM64 (Apple Silicon)

All builds are available as self-contained executables that don't require .NET runtime installation.

CI/CD Pipeline

The project uses GitHub Actions for automated:

  • Testing: Runs unit tests on every push and PR
  • Cross-platform builds: Creates binaries for all supported platforms
  • Docker builds: Multi-architecture container images (AMD64, ARM64)
  • Releases: Automatic releases with binaries and container images on version tags

Container Registry

Docker images are published to GitHub Container Registry:

  • ghcr.io/jamesburton/calculatormcpserver:latest - Latest from main branch
  • ghcr.io/jamesburton/calculatormcpserver:v1.0.0 - Specific version tags

Note: The CI/CD pipeline uses the built-in GITHUB_TOKEN for authentication to GitHub Container Registry.

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Please ensure your code:

  • Includes appropriate unit tests
  • Follows the existing code style
  • Has clear commit messages

License

This project is licensed under the MIT License - see the file for details.

Dependencies

Support

Changelog

See for version history and changes.