feat: 黄庄三号四能力Agent初始版本
能力1: Function Call - LangGraph ToolNode 能力2: MCP - langchain-mcp-adapters + 确定性路由 能力3: 思考模式 - think_node + CoT推理链 能力4: Skill - 自建SkillRegistry注册机制 模型: GLM-4.5-air (智谱)
This commit is contained in:
34
mcp_server.py
Normal file
34
mcp_server.py
Normal file
@@ -0,0 +1,34 @@
|
||||
"""简单的 MCP 服务器 - 提供时间查询和文本处理工具"""
|
||||
from mcp.server.fastmcp import FastMCP
|
||||
|
||||
mcp = FastMCP("hz3-tools")
|
||||
|
||||
@mcp.tool()
|
||||
def get_current_time(timezone: str = "Asia/Shanghai") -> str:
|
||||
"""获取当前时间"""
|
||||
from datetime import datetime
|
||||
import pytz
|
||||
try:
|
||||
tz = pytz.timezone(timezone)
|
||||
now = datetime.now(tz)
|
||||
return f"当前时间({timezone}): {now.strftime('%Y-%m-%d %H:%M:%S %Z')}"
|
||||
except Exception as e:
|
||||
return f"时区错误: {e}"
|
||||
|
||||
@mcp.tool()
|
||||
def count_chars(text: str) -> str:
|
||||
"""统计文本的字符数、词数等"""
|
||||
char_count = len(text)
|
||||
word_count = len(text.split())
|
||||
line_count = text.count('\n') + 1
|
||||
chinese_chars = sum(1 for c in text if '\u4e00' <= c <= '\u9fff')
|
||||
return f"字符数: {char_count}, 词数: {word_count}, 行数: {line_count}, 中文字符: {chinese_chars}"
|
||||
|
||||
@mcp.tool()
|
||||
def generate_uuid() -> str:
|
||||
"""生成一个随机UUID"""
|
||||
import uuid
|
||||
return str(uuid.uuid4())
|
||||
|
||||
if __name__ == "__main__":
|
||||
mcp.run(transport="stdio")
|
||||
Reference in New Issue
Block a user