# 📚 Usage Examples
This document provides practical examples of all available tools in the Math & Calculator MCP Server.
---
## 🔢 Calculator Tool
### Basic Operations
**Addition:**
```
User: "Calculate 25 + 17"
Tool: calculate
Args: { operation: "add", a: 25, b: 17 }
Result: 42
```
**Subtraction:**
```
User: "Subtract 50 from 100"
Tool: calculate
Args: { operation: "subtract", a: 100, b: 50 }
Result: 50
```
**Multiplication:**
```
User: "Multiply 7 by 8"
Tool: calculate
Args: { operation: "multiply", a: 7, b: 8 }
Result: 56
```
**Division:**
```
User: "Divide 100 by 4"
Tool: calculate
Args: { operation: "divide", a: 100, b: 4 }
Result: 25
```
**Power:**
```
User: "Calculate 2 to the power of 10"
Tool: calculate
Args: { operation: "power", a: 2, b: 10 }
Result: 1024
```
**Square Root:**
```
User: "What is the square root of 144?"
Tool: calculate
Args: { operation: "sqrt", a: 144 }
Result: 12
```
**Modulo:**
```
User: "What is 17 modulo 5?"
Tool: calculate
Args: { operation: "modulo", a: 17, b: 5 }
Result: 2
```
---
## 📊 Statistics Tool
**Mean (Average):**
```
User: "Calculate the mean of 10, 20, 30, 40, 50"
Tool: statistics
Args: { numbers: [10, 20, 30, 40, 50], operation: "mean" }
Result: { mean: 30 }
```
**Median:**
```
User: "Find the median of 3, 7, 2, 9, 5"
Tool: statistics
Args: { numbers: [3, 7, 2, 9, 5], operation: "median" }
Result: { median: 5 }
```
**Mode:**
```
User: "What's the mode of 1, 2, 2, 3, 3, 3, 4?"
Tool: statistics
Args: { numbers: [1, 2, 2, 3, 3, 3, 4], operation: "mode" }
Result: { mode: 3 }
```
**Standard Deviation:**
```
User: "Calculate standard deviation for 2, 4, 6, 8, 10"
Tool: statistics
Args: { numbers: [2, 4, 6, 8, 10], operation: "stddev" }
Result: { stddev: 2.8284271247461903 }
```
**All Statistics:**
```
User: "Give me all statistics for these numbers: 5, 10, 15, 20, 25"
Tool: statistics
Args: { numbers: [5, 10, 15, 20, 25], operation: "all" }
Result: {
mean: 15,
median: 15,
mode: 5,
variance: 50,
stddev: 7.0710678118654755
}
```
---
## 🔄 Unit Conversion Tool
### Length Conversions
**Kilometers to Miles:**
```
User: "Convert 100 kilometers to miles"
Tool: convert_units
Args: { value: 100, from: "kilometers", to: "miles" }
Result: {
original: "100 kilometers",
converted: "62.1371 miles",
value: 62.1371
}
```
**Feet to Meters:**
```
User: "How many meters is 10 feet?"
Tool: convert_units
Args: { value: 10, from: "feet", to: "meters" }
Result: {
original: "10 feet",
converted: "3.048 meters",
value: 3.048
}
```
### Weight Conversions
**Kilograms to Pounds:**
```
User: "Convert 75 kg to pounds"
Tool: convert_units
Args: { value: 75, from: "kg", to: "pounds" }
Result: {
original: "75 kg",
converted: "165.3465 pounds",
value: 165.3465
}
```
**Pounds to Kilograms:**
```
User: "How many kg is 150 pounds?"
Tool: convert_units
Args: { value: 150, from: "pounds", to: "kg" }
Result: {
original: "150 pounds",
converted: "68.0388 kg",
value: 68.0388
}
```
### Temperature Conversions
**Celsius to Fahrenheit:**
```
User: "Convert 25 Celsius to Fahrenheit"
Tool: convert_units
Args: { value: 25, from: "celsius", to: "fahrenheit" }
Result: {
original: "25 celsius",
converted: "77 fahrenheit",
value: 77
}
```
**Fahrenheit to Celsius:**
```
User: "What is 98.6°F in Celsius?"
Tool: convert_units
Args: { value: 98.6, from: "fahrenheit", to: "celsius" }
Result: {
original: "98.6 fahrenheit",
converted: "37 celsius",
value: 37
}
```
**Celsius to Kelvin:**
```
User: "Convert 0°C to Kelvin"
Tool: convert_units
Args: { value: 0, from: "celsius", to: "kelvin" }
Result: {
original: "0 celsius",
converted: "273.15 kelvin",
value: 273.15
}
```
---
## 📐 Equation Solver Tool
**Two Real Solutions:**
```
User: "Solve x² - 5x + 6 = 0"
Tool: solve_equation
Args: { a: 1, b: -5, c: 6 }
Result: {
equation: "1x² + -5x + 6 = 0",
solutions: [3, 2],
type: "two real solutions"
}
```
**One Real Solution:**
```
User: "Solve x² - 4x + 4 = 0"
Tool: solve_equation
Args: { a: 1, b: -4, c: 4 }
Result: {
equation: "1x² + -4x + 4 = 0",
solutions: [2],
type: "one real solution"
}
```
**Complex Solutions:**
```
User: "Solve x² + 2x + 5 = 0"
Tool: solve_equation
Args: { a: 1, b: 2, c: 5 }
Result: {
equation: "1x² + 2x + 5 = 0",
solutions: ["-1 + 2i", "-1 - 2i"],
type: "two complex solutions"
}
```
**Different Coefficients:**
```
User: "Solve 2x² - 8x + 6 = 0"
Tool: solve_equation
Args: { a: 2, b: -8, c: 6 }
Result: {
equation: "2x² + -8x + 6 = 0",
solutions: [3, 1],
type: "two real solutions"
}
```
---
## 💯 Percentage Tool
**Percentage Of:**
```
User: "What is 15% of 200?"
Tool: percentage
Args: { operation: "of", value1: 15, value2: 200 }
Result: {
result: 30,
description: "15% of 200"
}
```
**Percentage Increase:**
```
User: "Increase 100 by 20%"
Tool: percentage
Args: { operation: "increase", value1: 100, value2: 20 }
Result: {
result: 120,
description: "100 increased by 20%"
}
```
**Percentage Decrease:**
```
User: "Decrease 80 by 25%"
Tool: percentage
Args: { operation: "decrease", value1: 80, value2: 25 }
Result: {
result: 60,
description: "80 decreased by 25%"
}
```
**What Percentage:**
```
User: "What percentage is 25 of 200?"
Tool: percentage
Args: { operation: "what_percent", value1: 25, value2: 200 }
Result: {
result: 12.5,
description: "25 is 12.50% of 200"
}
```
---
## 📏 Trigonometry Tool
**Sine:**
```
User: "Calculate sin(30°)"
Tool: trigonometry
Args: { function: "sin", angle: 30 }
Result: {
function: "sin",
angle: "30°",
result: 0.5
}
```
**Cosine:**
```
User: "What is cos(60°)?"
Tool: trigonometry
Args: { function: "cos", angle: 60 }
Result: {
function: "cos",
angle: "60°",
result: 0.5
}
```
**Tangent:**
```
User: "Calculate tan(45°)"
Tool: trigonometry
Args: { function: "tan", angle: 45 }
Result: {
function: "tan",
angle: "45°",
result: 1
}
```
**Arc Sine:**
```
User: "What is arcsin(0.5) in degrees?"
Tool: trigonometry
Args: { function: "asin", angle: 0.5 }
Result: {
function: "asin",
angle: "0.5°",
result: 30
}
```
**Arc Cosine:**
```
User: "Calculate arccos(0.707)"
Tool: trigonometry
Args: { function: "acos", angle: 0.707 }
Result: {
function: "acos",
angle: "0.707°",
result: 45.01
}
```
**Arc Tangent:**
```
User: "What is arctan(1)?"
Tool: trigonometry
Args: { function: "atan", angle: 1 }
Result: {
function: "atan",
angle: "1°",
result: 45
}
```
---
## 🎯 Complex Examples
### Multi-Step Problem
**Problem:** "I have a list of test scores: 85, 90, 78, 92, 88. Calculate the mean, then tell me what percentage 85 is of the mean."
**Step 1:**
```
Tool: statistics
Args: { numbers: [85, 90, 78, 92, 88], operation: "mean" }
Result: { mean: 86.6 }
```
**Step 2:**
```
Tool: percentage
Args: { operation: "what_percent", value1: 85, value2: 86.6 }
Result: {
result: 98.15,
description: "85 is 98.15% of 86.6"
}
```
### Real-World Scenario
**Problem:** "I'm running a 5K race (5 kilometers). How many miles is that? If I want to increase my training distance by 20%, how many miles should I run?"
**Step 1:**
```
Tool: convert_units
Args: { value: 5, from: "kilometers", to: "miles" }
Result: { value: 3.10686 }
```
**Step 2:**
```
Tool: percentage
Args: { operation: "increase", value1: 3.10686, value2: 20 }
Result: { result: 3.728232 }
```
**Answer:** Train with 3.73 miles
---
## 🧪 Edge Cases
**Division by Zero:**
```
Tool: calculate
Args: { operation: "divide", a: 10, b: 0 }
Result: Error: "Division by zero"
```
**Invalid Unit Conversion:**
```
Tool: convert_units
Args: { value: 100, from: "meters", to: "pounds" }
Result: Error: "Conversion from meters to pounds not supported"
```
**Quadratic with a=0:**
```
Tool: solve_equation
Args: { a: 0, b: 5, c: 3 }
Result: Error: "Coefficient 'a' cannot be zero for quadratic equation"
```
---
**Author:** Jefferson Rosas Chambilla
**Repository:** https://github.com/Ankluna72/Math-Calculator-MCP-Server-