Repository: githejie/mcp-server-calculator

Issue:
Incorrectly identifying exponentiation as BitXor
The prompt is: Calculate 42 raised to the 7th power.

![Image](https://github.com/user-attachments/assets/3f6d661a-8311-49ca-83f3-85bc1eb38a50)

Hints from issue comments:

Solution patch:
diff --git a/src/mcp_server_calculator/calculator.py b/src/mcp_server_calculator/calculator.py
index 19ced8a..be97f8e 100644
--- a/src/mcp_server_calculator/calculator.py
+++ b/src/mcp_server_calculator/calculator.py
@@ -26,6 +26,7 @@ def evaluate(expression: str) -> str:
             return -eval_expr(node.operand)
         raise ValueError(f"Unsupported operation: {ast.dump(node)}")
 
+    expression = expression.replace('^', '**').replace('×', '*').replace('÷', '/')
     parsed_expr = ast.parse(expression, mode='eval')
     result = eval_expr(parsed_expr.body)
     return str(result)


Test patch:
diff --git a/tests/test_calculator.py b/tests/test_calculator.py
index 17796ba..08dcb2b 100644
--- a/tests/test_calculator.py
+++ b/tests/test_calculator.py
@@ -10,9 +10,11 @@ class TestCalculator(unittest.TestCase):
 
     def test_multiplication(self):
         self.assertEqual(evaluate("2 * 3"), "6")
+        self.assertEqual(evaluate("2 × 3"), "6")
 
     def test_division(self):
         self.assertEqual(evaluate("8 / 2"), "4.0")
+        self.assertEqual(evaluate("8 ÷ 2"), "4.0")
 
     def test_floor_division(self):
         self.assertEqual(evaluate("7 // 2"), "3")
@@ -22,6 +24,7 @@ class TestCalculator(unittest.TestCase):
 
     def test_power(self):
         self.assertEqual(evaluate("2 ** 3"), "8")
+        self.assertEqual(evaluate("2 ^ 3"), "8")
 
     def test_unary_minus(self):
         self.assertEqual(evaluate("-5"), "-5")