from mcp.server.fastmcp import FastMCP
logger = logging.getLogger('test_mcp')
mcp = FastMCP("Calculator")
def calculator(python_expression: str) -> dict:
"""For mathamatical calculation, always use this tool to calculate the result of a python expression. `math` and `random` are available."""
result = eval(python_expression)
logger.info(f"Calculating formula: {python_expression}, result: {result}")
return {"success": True, "result": result}
if __name__ == "__main__":
mcp.run(transport="stdio")