mirror of
https://github.com/Sun-ZhenXing/mcp-template-python.git
synced 2026-03-22 00:28:03 +00:00
32 lines
698 B
Python
32 lines
698 B
Python
from operator import add, mul, sub, truediv
|
|
|
|
from mcp.server.fastmcp import FastMCP
|
|
|
|
from mcp_template_python.config import settings
|
|
|
|
mcp = FastMCP("math", instructions=settings.mcp.instructions)
|
|
|
|
|
|
@mcp.tool()
|
|
async def add_num(a: float, b: float) -> float:
|
|
"""Adds two numbers."""
|
|
return add(a, b)
|
|
|
|
|
|
@mcp.tool()
|
|
async def sub_num(a: float, b: float) -> float:
|
|
"""Subtracts the second number from the first."""
|
|
return sub(a, b)
|
|
|
|
|
|
@mcp.tool()
|
|
async def mul_num(a: float, b: float) -> float:
|
|
"""Multiplies two numbers."""
|
|
return mul(a, b)
|
|
|
|
|
|
@mcp.tool()
|
|
async def div_num(a: float, b: float) -> float:
|
|
"""Divides the first number by the second."""
|
|
return truediv(a, b)
|