feat(create_mcp): 添加MCP工具输出Schema定义
添加了固定的输出Schema定义,包含code、message和data字段, 用于规范MCP工具的返回格式,提高API响应的一致性。 - 定义了标准的输出Schema结构 - 包含响应状态码、消息和数据字段 - code和message为必需字段
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -367,12 +367,24 @@ class ApiToolPlugin(ToolPlugin):
|
||||
tool_name = tool_config["interfaceName"] # 工具名称(拼音格式)
|
||||
logger.debug(f"注册工具: {tool_name}")
|
||||
|
||||
# 定义输出 Schema(先写死一个测试)
|
||||
output_schema = {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {"type": "integer", "description": "响应状态码,0表示成功"},
|
||||
"message": {"type": "string", "description": "响应消息"},
|
||||
"data": {"type": "object", "description": "响应数据"}
|
||||
},
|
||||
"required": ["code", "message"]
|
||||
}
|
||||
|
||||
# 创建MCP工具定义
|
||||
tools.append(
|
||||
types.Tool(
|
||||
name=tool_name, # 工具名称
|
||||
description=tool_config["schema_description"], # 工具描述(包含参数说明)
|
||||
inputSchema=tool_config["schema"], # 输入参数的JSON Schema
|
||||
outputSchema=output_schema, # 输出参数的JSON Schema
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user