AI创想

标题: Dify MCP 保姆级教程来了! [打印本页]

作者: mazaoxie    时间: 2025-9-7 23:06
标题: Dify MCP 保姆级教程来了!
Dify MCP 保姆级教程来了!

1. MCP介绍

1.1 大语言模型 VS 智能体Agent?

大语言模型,例如 DeepSeek,如果不能联网、不能操作外部工具,只能是聊天机器人。除了聊天没什么可做的。
而一旦大语言模型能操作工具,例如:联网/地图/查天气/函数/插件/API 接口/代码解释器/机械臂/灵巧手,它就升级成为智能体 Agent,能更好地帮助人类。今年爆火的 Manus 就是这样的智能体。
众多大佬、创业公司,都在 All In 押注 AI 智能体赛道。
也有不少爆款的智能体产品,比如 Coze、Manus、Dify。
1.2 以前的智能体是怎么实现的?

在以前,如果想让大模型调用外部工具,需要通过写大段提示词的方法,实现“Function Call”。
比如在 openai 中这是一个用于处理客户订单配送日期查询的工具调用逻辑设计。以下是关键点解读:
一、工具功能解析


二、客服对话流程示例

假设用户提问:“Hi, can you tell me the delivery date for my order?”
助手应执行以下步骤:
“Sure! Please provide your order ID so I can check the delivery schedule.”
  1. tools = [
  2.     {
  3.         "type": "function",
  4.         "function": {
  5.             "name": "get_delivery_date",
  6.             "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'",
  7.             "parameters": {
  8.                 "type": "object",
  9.                 "properties": {
  10.                     "order_id": {
  11.                         "type": "string",
  12.                         "description": "The customer's order ID.",
  13.                     },
  14.                 },
  15.                 "required": ["order_id"],
  16.                 "additionalProperties": False,
  17.             },
  18.         }
  19.     }
  20. ]
  21. messages = [
  22.     {"role": "system", "content": "You are a helpful customer support assistant. Use the supplied tools to assist the user."},
  23.     {"role": "user", "content": "Hi, can you tell me the delivery date for my order?"}
  24. ]
  25. response = openai.chat.completions.create(
  26.     model="gpt-4o",
  27.     messages=messages,
  28.     tools=tools,
  29. )
复制代码
1.3 靠大段提示词的方法实现的 Function Call 有什么问题?

对开发者(你)来说:
对软件厂商来说(百度地图)来说:
对大模型厂商(DeepSeek)来说:
每个软件都要定制开发不同的大模型调用模板。
1.4 秦王扫六合:MCP协议



Anthropic 公司(就是发布 Claude 大模型的公司),在 2024 年 11 月,发布了 Model Context Protocol 协议,简称 MCP。
MCP 协议就像 Type-C 扩展坞,让海量的软件和工具,能够插在大语言模型上,供大模型调用
MCP 协议是连接【大模型(客户端)】和【各种工具应用(服务端)】的统一接口。


1.5 几个 MCP 的应用案例

\1. 调用Unity的MCP接口,让AI自己开发游戏。
https://www.bilibili.com/video/BV1kzoWYXECJ
\2. 调用Blender的MCP接口,让AI自己3D建模。
https://www.bilibili.com/video/BV1pHQNYREAX
\3. 调用百度地图的MCP接口,让AI自己联网,查路况,导航。
https://www.bilibili.com/video/BV1dbdxY5EUP
\4. 调用 Playwright 的MCP接口,让 AI 自己操作网页。(后面的保姆级教程讲的就是这个)
只要“扩展坞”上插的“工具”够多,每个人都能几分钟,搭积木手搓出,类似 Manus 的智能体





欢迎光临 AI创想 (http://llms-ai.com/) Powered by Discuz! X3.4