Function Calling标准化演进:从OpenAI到MCP统一协议
工具调用:从实验性功能到标准基础设施 2023年OpenAI推出Function Calling时,它被视为一个便捷的实验性功能。到2026年,工具调用已成为大模型应用的标准基础设施——每个Agent都需要调用工具,而调用方式的标准化程度直接决定了开发效率。 各厂商方案对比 OpenAI Function Calling OpenAI的方案是最早的标准化工具调用格式: { "tools": [ { "type": "function", "function": { "name": "get_weather", "description": "获取指定城市的天气", "parameters": { "type": "object", "properties": { "city": {"type": "string", "description": "城市名"}, "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]} }, "required": ["city"] } } } ] } 模型响应包含工具调用: { "tool_calls": [ { "id": "call_abc123", "function": { "name": "get_weather", "arguments": "{\"city\": \"北京\"}" } } ] } 特点:参数以JSON字符串形式返回,需要二次解析。Parallel function calling支持一次调用多个工具。 Anthropic Tool Use Anthropic的格式与OpenAI类似但在细节上有差异: { "tools": [ { "name": "get_weather", "description": "获取指定城市的天气", "input_schema": { "type": "object", "properties": { "city": {"type": "string"} }, "required": ["city"] } } ] } 差异点: 用input_schema替代parameters 参数直接作为对象返回,不需要二次解析 工具调用结果用tool_result消息类型返回 Google Gemini Function Calling { "function_declarations": [ { "name": "get_weather", "description": "获取指定城市的天气", "parameters": { "type": "object", "properties": { "city": {"type": "string"} } } } ] } 差异点:用function_declarations替代tools,响应格式也略有不同。 ...


