tools =[{"type":"function","function":{"name":"get_delivery_date","description":"Get the delivery date for a customer's order. Call this whenever you need to know the delivery date, for example when a customer asks 'Where is my package'","parameters":{"type":"object","properties":{"order_id":{"type":"string","description":"The customer's order ID.",},},"required":["order_id"],"additionalProperties":False,},}}]
messages =[{"role":"system","content":"You are a helpful customer support assistant. Use the supplied tools to assist the user."},{"role":"user","content":"Hi, can you tell me the delivery date for my order?"}]
每个支持 MCP 的软件,都有一个 MCP Server 文件,里面列出了所有支持调用的函数,函数注释里的内容是给 AI 看的,告诉 AI 这个函数是做什么用的。
MCP Server 文件就是给 AI 看的工具说明书。
例如百度地图 MCP 案例:
https://github.com/baidu-maps/mcp/blob/main/src/baidu-map/python/src/mcp_server_baidu_maps/map.py
每个以@mcp.tool()开头的函数,都是一个百度地图支持 MCP 调用的功能。
(, 下载次数: 0)
上传
点击文件名下载附件
你也可以按照这个规范,自己开发 MCP Server,让你自己的软件支持 MCP 协议,让 AI 能调用你软件中的功能。
1.11 参考资料
组件插件化:插件与主平台解耦,模型和工具以插件形式独立运行,支持单独更新与升级。新模型的适配不再依赖于 Dify 平台的整体版本升级,用户只需单独更新相关插件,无需担心系统维护和兼容性问题。新工具的开发和分享将更加高效,支持接入各类成熟的软件解决方案和工具创新。开发者友好:插件遵循统一的开发规范和接口标准,配备远程调试、代码示例和 API 文档的工具链,帮助插件开发者快速上手。热插拔设计:支持插件的动态扩展与灵活使用,确保系统高效运行。多种分发机制: