#!/usr/bin/env python3 """Test the MCP tools directly.""" import sys import os sys.path.insert(0, 'src') # Test simple calculator without MCP wrapper def simple_calculator(operation: str, a: float, b: float): """Test version of the calculator tool.""" try: operations = { "add": lambda x, y: x + y, "subtract": lambda x, y: x - y, "multiply": lambda x, y: x * y, "divide": lambda x, y: x / y if y != 0 else None } if operation.lower() not in operations: return { "error": f"Unknown operation: {operation}. Available: {list(operations.keys())}", "success": False } if operation.lower() == "divide" and b == 0: return { "error": "Division by zero is not allowed", "success": False } result = operations[operation.lower()](a, b) return { "result": result, "operation": operation, "operands": [a, b], "success": True } except Exception as e: return { "error": str(e), "success": False } if __name__ == "__main__": print("Testing simple calculator tool:") print("Add 5 + 3:", simple_calculator('add', 5, 3)) print("Subtract 10 - 3:", simple_calculator('subtract', 10, 3)) print("Multiply 4 * 7:", simple_calculator('multiply', 4, 7)) print("Divide 15 / 3:", simple_calculator('divide', 15, 3)) print("Divide by zero:", simple_calculator('divide', 10, 0)) print("Invalid operation:", simple_calculator('invalid', 1, 2))