feat: add /ws

This commit is contained in:
Sun-ZhenXing
2025-07-21 00:09:53 +08:00
parent bcb5994356
commit 48f2efef7a
10 changed files with 347 additions and 51 deletions

View File

@@ -1,39 +1,31 @@
from operator import add, mul, sub, truediv
from mcp.server.fastmcp import FastMCP
from mcp_template_python.lib.better_mcp import BetterFastMCP
from ..config import settings
mcp = FastMCP("math", settings=settings.instructions)
mcp = BetterFastMCP("math", settings=settings.instructions)
@mcp.tool()
async def add_nums(a: float, b: float) -> float:
"""
Adds two numbers.
"""
async def add_num(a: float, b: float) -> float:
"""Adds two numbers."""
return add(a, b)
@mcp.tool()
async def sub_nums(a: float, b: float) -> float:
"""
Subtracts the second number from the first.
"""
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_nums(a: float, b: float) -> float:
"""
Multiplies two numbers.
"""
async def mul_num(a: float, b: float) -> float:
"""Multiplies two numbers."""
return mul(a, b)
@mcp.tool()
async def div_nums(a: float, b: float) -> float:
"""
Divides the first number by the second.
"""
async def div_num(a: float, b: float) -> float:
"""Divides the first number by the second."""
return truediv(a, b)