math_server.pyβ’623 B
from mcp.server.fastmcp import FastMCP
mcp=FastMCP("Math")
@mcp.tool()
def add(a:int, b:int)->int:
"""Return the sum of two integers."""
return a + b
@mcp.tool()
def subtract(a: int, b: int) ->int:
"""Return the difference of two integers."""
return a - b
@mcp.tool()
def multiply(a: int, b: int) ->int:
"""Return the product of two integers."""
return a * b
@mcp.tool()
def divide(a: int, b: int) -> float:
"""Return the quotient of two integers."""
if b == 0:
raise ValueError("Cannot divide by zero")
return a / b
if __name__=="__main__":
mcp.run(transport="stdio")