feat(tool system): add all methods for obtaining the tool
This commit is contained in:
@@ -27,7 +27,7 @@ class DateTimeTool(BuiltinTool):
|
||||
type=ParameterType.STRING,
|
||||
description="操作类型",
|
||||
required=True,
|
||||
enum=["format", "convert_timezone", "timestamp_to_datetime", "datetime_to_timestamp", "calculate", "now"]
|
||||
enum=["format", "convert_timezone", "timestamp_to_datetime", "now"]
|
||||
),
|
||||
ToolParameter(
|
||||
name="input_value",
|
||||
|
||||
@@ -29,8 +29,7 @@ class JsonTool(BuiltinTool):
|
||||
type=ParameterType.STRING,
|
||||
description="操作类型",
|
||||
required=True,
|
||||
enum=["format", "minify", "validate", "convert", "to_yaml", "from_yaml", "to_xml", "from_xml", "merge",
|
||||
"extract", "insert", "replace", "delete", "parse"]
|
||||
enum=["insert", "replace", "delete", "parse"]
|
||||
),
|
||||
ToolParameter(
|
||||
name="input_data",
|
||||
|
||||
@@ -204,7 +204,7 @@ class MCPClient:
|
||||
)
|
||||
|
||||
init_response = json.loads(response)
|
||||
if "error" in init_response:
|
||||
if init_response.get("error", None) is not None:
|
||||
raise MCPProtocolError(f"初始化失败: {init_response['error']}")
|
||||
|
||||
return True
|
||||
@@ -325,7 +325,7 @@ class MCPClient:
|
||||
try:
|
||||
response = await self._send_request(request_data, timeout)
|
||||
|
||||
if "error" in response:
|
||||
if response.get("error", None) is not None:
|
||||
error = response["error"]
|
||||
raise MCPProtocolError(f"工具调用失败: {error.get('message', '未知错误')}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user