DEV Community

JEFFERSON ROSAS CHAMBILLA
JEFFERSON ROSAS CHAMBILLA

Posted on

Math & Calculator MCP Server

A powerful Model Context Protocol (MCP) Server that provides advanced mathematical utilities and calculator tools for AI assistants like Claude and other MCP-compatible clients.

πŸ“– About

This MCP server exposes mathematical tools that AI assistants can use to perform calculations, statistical analysis, unit conversions, and more. Built with the Model Context Protocol SDK, it seamlessly integrates with Claude Desktop, VSCode, and other MCP clients.

Author: Jefferson Rosas Chambilla

Repository: https://github.com/Ankluna72/Math-Calculator-MCP-Server-

✨ Features

πŸ”’ Basic Calculator

  • Addition, subtraction, multiplication, division
  • Power, square root, modulo operations
  • Error handling (division by zero, invalid operations)

πŸ“Š Statistical Analysis

  • Mean, median, mode
  • Standard deviation and variance
  • Complete statistical summaries

πŸ”„ Unit Conversions

  • Length: meters, kilometers, miles, feet, inches
  • Weight: kilograms, grams, pounds, ounces
  • Temperature: Celsius, Fahrenheit, Kelvin

πŸ“ Equation Solver

  • Quadratic equation solver (axΒ² + bx + c = 0)
  • Handles real and complex solutions
  • Discriminant analysis

πŸ’― Percentage Calculator

  • Percentage of a number
  • Percentage increase/decrease
  • "What percentage is X of Y?"

πŸ“ Trigonometry

  • Sin, cos, tan (and inverse functions)
  • Angle calculations in degrees
  • Precise floating-point results

πŸš€ Installation

Prerequisites

  • Node.js >= 18.0.0
  • npm or yarn

Clone and Install

git clone https://github.com/Ankluna72/Math-Calculator-MCP-Server-.git
cd Math-Calculator-MCP-Server-
npm install
npm run build
Enter fullscreen mode Exit fullscreen mode

βš™οΈ Configuration

For Claude Desktop

Add to your Claude Desktop config file (claude_desktop_config.json):

Windows: %APPDATA%\Claude\claude_desktop_config.json

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

Linux: ~/.config/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "math-calculator": {
      "command": "node",
      "args": [
        "C:\\path\\to\\Math-Calculator-MCP-Server-\\dist\\index.js"
      ]
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

For VSCode with Cline Extension

Add to VSCode settings (.vscode/settings.json or User Settings):

{
  "mcp.servers": {
    "math-calculator": {
      "command": "node",
      "args": [
        "C:\\path\\to\\Math-Calculator-MCP-Server-\\dist\\index.js"
      ]
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

πŸ“š Usage Examples

Once configured, your AI assistant can use these tools automatically. Here are some example requests:

Basic Calculations

"Calculate 25 * 4"
"What is the square root of 144?"
"Divide 100 by 7"
Enter fullscreen mode Exit fullscreen mode

Statistics

"Calculate the mean of [10, 20, 30, 40, 50]"
"Find median and mode for these numbers: [5, 3, 5, 2, 8, 5]"
"Give me all statistics for [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]"
Enter fullscreen mode Exit fullscreen mode

Unit Conversions

"Convert 100 kilometers to miles"
"How many pounds is 75 kilograms?"
"Convert 32 Fahrenheit to Celsius"
Enter fullscreen mode Exit fullscreen mode

Solve Equations

"Solve xΒ² - 5x + 6 = 0"
"Find solutions for 2xΒ² + 3x - 2 = 0"
Enter fullscreen mode Exit fullscreen mode

Percentages

"What is 15% of 200?"
"Increase 50 by 20%"
"What percentage is 25 of 200?"
Enter fullscreen mode Exit fullscreen mode

Trigonometry

"Calculate sin(30Β°)"
"What is cos(45Β°)?"
"Find tan(60Β°)"
Enter fullscreen mode Exit fullscreen mode

πŸ› οΈ Available Tools

Tool Description
calculate Basic arithmetic operations
statistics Statistical analysis of number arrays
convert_units Convert between different units
solve_equation Solve quadratic equations
percentage Percentage calculations
trigonometry Trigonometric functions

πŸ“ Project Structure

Math-Calculator-MCP-Server-/
β”œβ”€β”€ src/
β”‚   └── index.ts          # Main MCP server implementation
β”œβ”€β”€ dist/                 # Compiled JavaScript (after build)
β”œβ”€β”€ package.json          # Project dependencies
β”œβ”€β”€ tsconfig.json         # TypeScript configuration
β”œβ”€β”€ .gitignore
└── README.md
Enter fullscreen mode Exit fullscreen mode

πŸ”§ Development

# Install dependencies
npm install

# Build the project
npm run build

# Development mode (watch for changes)
npm run dev

# Start the server
npm start
Enter fullscreen mode Exit fullscreen mode

πŸ§ͺ Testing

You can test the server manually using stdio communication:

npm start
Enter fullscreen mode Exit fullscreen mode

Then send MCP protocol messages via stdin to test tool execution.

πŸ“ License

MIT License - see LICENSE file for details

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

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

πŸ“§ Contact

Jefferson Rosas Chambilla

🌟 Acknowledgments

  • Built with the Model Context Protocol SDK
  • Inspired by the need for mathematical tools in AI assistants
  • Thanks to Anthropic for developing the MCP standard

Top comments (0)