From 93c1ac067d86d2edfc5d3e633c9dc158d59c4a05 Mon Sep 17 00:00:00 2001 From: cvcat <992822653@qq.com> Date: Tue, 15 Jul 2025 00:34:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E8=B0=83=E7=94=A8?= =?UTF-8?q?=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- app/core/mcp_server.py | 7 ++++--- app/core/message_service.py | 7 +++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index c494edf..219ec7d 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![Python Version](https://img.shields.io/badge/python-3.10%2B-blue)](https://www.python.org/) [![Node.js Version](https://img.shields.io/badge/nodejs-18%2B-blue)](https://nodejs.org/zh-cn/) -一个基于飞书(Lark)的全场景MCP Function Call AI Agent,实现大模型通过飞书进行函数调用和消息处理。 +一个基于飞书(Lark)的AI Agent,实现大模型通过飞书进行函数调用和消息处理。 **无需配置飞书机器人,你的飞书账号即是AI助手。** diff --git a/app/core/mcp_server.py b/app/core/mcp_server.py index a333aa8..50056bd 100644 --- a/app/core/mcp_server.py +++ b/app/core/mcp_server.py @@ -6,8 +6,7 @@ import datetime from loguru import logger from sqlalchemy import func, desc from mcp.server.fastmcp import FastMCP - - +from typing_extensions import Annotated BASE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..')) if BASE_DIR not in sys.path: @@ -39,7 +38,9 @@ def list_tools() -> str: return result @register_tool(name="get_weather", description="获取城市天气") -def get_weather(city): +def get_weather( + city: Annotated[str, "城市名称"] = "北京" +): """ 获取城市天气 :param city: 城市名称 diff --git a/app/core/message_service.py b/app/core/message_service.py index 383c179..e74f9de 100644 --- a/app/core/message_service.py +++ b/app/core/message_service.py @@ -63,13 +63,12 @@ class MessageService: async with Client(self.mcp_transport) as mcp_client: tools = [] for tool in await mcp_client.list_tools(): - info = tool.model_dump() if hasattr(tool, "model_dump") else tool.dict() tools.append({ "type": "function", "function": { - "name": info["name"], - "description": info.get("description", ""), - "parameters": info.get("parameters", {}) + "name": tool.name, + "description": tool.description, + "parameters": tool.inputSchema, } }) messages = [