仿生人MCP服务

This commit is contained in:
BBIT-Kai
2025-11-05 18:04:36 +08:00
parent 5f5eefd37b
commit 179604931d
11 changed files with 661 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
# server.py
import logging
import math
import random
from fastmcp import FastMCP
logger = logging.getLogger("Calculator")
def register_calculator_tools(mcp: FastMCP):
# Add an addition tool
@mcp.tool()
def calculator(python_expression: str) -> dict:
"""For mathamatical calculation, always use this tool to calculate the result of a python expression. You can use 'math' or 'random' directly, without 'import'."""
result = eval(python_expression, {"math": math, "random": random})
logger.info(f"Calculating formula: {python_expression}, result: {result}")
return {"success": True, "result": result}