使用说明
""" 生成内容返回类似这样的结果: 生成内容响应( done=True, 迭代器=None, result = protos.GenerateContentResponse({ "候选人": [ { "content": { "parts": [ { "函数调用": { "name": "获取数据",, "args": { "端点": "https://meowfacts.herokuapp.com/", "id": 3.0 翻译成中文是:“id”:3.0 } } } ], "role": "模型" }, "finish_reason": "停止", "avg_logprobs": -0.029699273904164634 (中文翻译为:“平均对数概率”:-0.029699273904164634) } ], "usage_metadata": { "提示标记数(prompt_token_count)": 108,, "候选人令牌数量": 15, "总标记数":123 }, "model_version": "gemini-2.0-flash" 翻译成中文为:“模型版本”:“gemini-2.0-flash” }), ) —使用.text作为“快捷按钮”,或者在需要精确控制时(例如,检测并执行工具调用),遍历候选项→内容→部分。 """
""" 调用工具结果( content=[ 文本内容( 类型='文本', text='{ "状态":200,, "url":"https://meowfacts.herokuapp.com/?count=3",翻译成中文是:“网址”:“https://meowfacts.herokuapp.com/?count=3”, "query": {"count": 3}, "data":数据 { "data": 数据 [ “<猫的趣事1>”, “<猫咪事实2>”, “<猫咪冷知识3>” ] } }, 注释=None, meta=None(元数据为无) ) ], 结构化内容= { 'data':数据 { 'data':数据 [ '<猫的事实1>', “猫的冷知识2”, “<猫的事实3>” ] } 'query': {'count': 3} 翻译为中文是:“查询”:{'数量': 3}, 'status': 200,翻译为中文是“状态码:200”, "url": "https://meowfacts.herokuapp.com/?count=3", data=(在中文语境中,这通常表示“数据=”,即某个变量或数据集的赋值或定义) { 'data':数据 { 'data':数据 [ '<猫的趣事1>', '<猫的事实2>', '<猫咪趣事3>' ] } 'query': {'count': 3} 翻译成中文是:“查询”:{'数量': 3}, 'status': 200, (翻译为)'状态': 200,, 'url': 'https://meowfacts.herokuapp.com/?count=3' 翻译为中文是:“网址”: “https://meowfacts.herokuapp.com/?count=3” }, is_error=False(表示没有错误) """
""" [ 名称:获取数据 参数 { 字段 { 键:"端点" 值 { 字符串值:"https://meowfacts.herokuapp.com/" } } 字段 { 键: "count" 值 { 数字值:3 } } } ] """
MCP 返回一个工具对象列表,格式如下: [ 工具( name='获取数据', 标题=None, 从公共API端点获取数据。示例:端点="https://meowfacts.herokuapp.com/" 可选查询参数:count(整数):要获取的项目数量 id(整数):特定记录ID lang(字符串):语言代码, inputSchema=(可翻译为)输入模式= { 'properties':属性 { 'endpoint': {'type': 'string'},翻译为中文是:“端点”:{'类型': '字符串'}, 'count': {'anyOf': [{'type': 'integer'}, {'type': 'string'}, {'type': 'null'}], 'default': None},翻译为中文是:“计数”:{“任意类型”:[“整数类型”、“字符串类型”、“空类型”],“默认值”:None}, 'id': {'anyOf': [{'type': 'integer'}, {'type': 'null'}], 'default': None} 翻译成中文为:“id”: {“任意一种情况满足”:[“类型为整数”,“类型为null”], “默认值”:None}, 'lang': {'anyOf': [{'type': 'string'}, {'type': 'null'}], 'default': None} 翻译成中文为:“语言”字段:其值可以是字符串类型或空值,且默认值为None } “required”: [“endpoint”],翻译成中文是:“必需项”:[“端点”], 'type': 'object' 翻译成中文是:“类型”:“对象” }, outputSchema=None,(可翻译为)输出模式(或输出架构)为None, 图标(icons)为None, 注释=None, meta={'_fastmcp': {'tags': []}} 翻译成中文为:`meta`对象中的`_fastmcp`键对应的值是一个包含空标签列表的字典 ) ]
Gemini Tools list is of the format:
[
{
'description':
'Fetch data from a public API endpoint.\n'
'Example: endpoint="https://meowfacts.herokuapp.com/"\n'
'\n'
'Optional query parameters:\n'
' count (int): number of items to fetch\n'
' id (int): specific record ID\n'
' lang (str): language code',
'name': 'fetch_data',
'parameters':
{
'properties':
{
'count': {'type': 'NUMBER'},
'endpoint': {'type': 'STRING'},
'id': {'type': 'NUMBER'},
'lang': {'type': 'STRING'}
},
'required': ['endpoint'],
'type': 'OBJECT'
}
}
]
"""
预期的MCP形状(简化版): { "name": "获取数据",, "description": "…", "inputSchema": { "类型": "对象", "properties": { "endpoint": {...}, 。.. }, "required": ["端点"] } } 返回: { "name": "获取数据",, "描述": "...",, "参数": { "type": "OBJECT",翻译为中文是:“类型”:“对象”, "properties": { "endpoint": { "type": "STRING", ... } },翻译成中文为:“属性”:{ “端点”:{ “类型”: “字符串”, ... } }, "required": ["端点"] } } """