mcpField
D
Dify Agent Mcp Sse

Dify Agent Mcp Sse

远程服务
deepwiki.comAI 与智能体13928 周前更新

关于 Dify Agent Mcp Sse

Dify Agent Mcp Sse 是一组用于 Dify 1.0 插件的 Agent 策略,支持 Function Calling 与 ReAct 两种方式。它让 Dify Agent 通过 SSE 或 Streamable HTTP 传输连接并调用 MCP 工具。

主要功能

  1. 01Function Calling 与 ReAct 策略
  2. 02支持 SSE 与 Streamable HTTP 传输
  3. 03可配置多个 MCP 服务
  4. 04兼容托管 MCP 服务的接入

适用场景

  1. 01在 Dify 工作流中让 Agent 调用远程 MCP 工具
  2. 02接入 Composio、Zapier 等托管 MCP 服务
  3. 03安装时绕过未上架插件的签名校验

MCP 相关

该插件是 MCP 客户端侧的适配器,Dify Agent 通过其配置的 URL 连接一个或多个 MCP 服务,发现并调用其中的工具。

配置

远程服务无需本地安装。选择你使用的客户端,复制配置或使用一键安装。

服务地址http://127.0.0.1:8000/sse
一键复制安装命令
Claude CodeTerminal
Cursor.cursor/mcp.json
VS Code.vscode/mcp.json
Claude Desktopclaude_desktop_config.json
Windsurf~/.codeium/windsurf/mcp_config.json

命令在终端中运行;JSON 粘贴到对应客户端的 MCP 配置后重启。需要授权的服务会在首次连接时提示登录。

全部服务地址
Streamable HTTPhttp://127.0.0.1:8000/sse
Streamable HTTPhttp://127.0.0.1:8001/sse
Streamable HTTPhttp://127.0.0.1:8002/mcp
Streamable HTTPhttp://127.0.0.1:8003/mcp

工具

详细介绍

Dify 1.0 插件支持 MCP 工具 Agent 策略

作者: Junjie.M
类型: agent-strategy
Github 仓库: https://github.com/junjiem/dify-plugin-agent-mcp_sse
Github 问题: issues


描述

提供 Function Calling 和 ReAct 的 Agent 策略集合 (支持通过 HTTP with SSE 或 Streamable HTTP 传输方式使用 MCP 协议来发现和调用工具)。

mcp_sse_agent

mcp_sse_agent_strategies

mcp_sse_agent_react

MCP 服务配置,支持多个 MCP 服务。如下示例:

{
  "server_name1": {
    "transport": "sse",
    "url": "http://127.0.0.1:8000/sse",
    "headers": {},
    "timeout": 50,
    "sse_read_timeout": 50
  },
  "server_name2": {
    "transport": "sse",
    "url": "http://127.0.0.1:8001/sse"
  },
  "server_name3": {
    "transport": "streamable_http",
    "url": "http://127.0.0.1:8002/mcp",
    "headers": {},
    "timeout": 50
  },
  "server_name4": {
    "transport": "streamable_http",
    "url": "http://127.0.0.1:8003/mcp"
  }
}

或

{
  "mcpServers": {
      "server_name1": {
        "transport": "sse",
        "url": "http://127.0.0.1:8000/sse",
        "headers": {},
        "timeout": 50,
        "sse_read_timeout": 50
      },
      "server_name2": {
        "transport": "sse",
        "url": "http://127.0.0.1:8001/sse"
      },
      "server_name3": {
        "transport": "streamable_http",
        "url": "http://127.0.0.1:8002/mcp",
        "headers": {},
        "timeout": 50
      },
      "server_name4": {
        "transport": "streamable_http",
        "url": "http://127.0.0.1:8003/mcp"
      }
    }
}

注: "transport" 参数为 sse 或 streamable_http,默认为 sse。


托管的 MCP 服务

如果你想尝试 MCP,但不知道如何部署 SSE 传输的 MCP 服务,可以尝试连接托管的 MCP 服务。

示例 1

Composio 托管的 MCP 服务

composio_mcp_list

参考 Cursor 设置,如下图:

composio_mcp_cursor composio_mcp_cursor2

MCP 服务配置,如下示例:

{
  "tavily": {
    "url": "https://mcp.composio.dev/tavily/xxxx-xxxx-xxxx-xxxx"
  }
}
示例 2

Zapier 托管的 MCP 服务

复制 MCP 服务 URL,在 Dify 插件配置中使用。

zapier_mcp_servers

MCP 服务配置,如下示例:

{
  "zapier-mcp": {
    "url": "https://actions.zapier.com/mcp/sk-xxxxxxxxxx/sse"
  }
}

点击 "Edit MCP Actions",进入工具和操作的添加页面。

zapier_mcp_edit_actions

点击 "Add a new action",添加需要的 MCP 服务实例。

zapier_mcp_add_actions

你还可以继续添加不同的 Action,丰富 Agent 可用的工具集。

示例 3

MCP.so 托管的 MCP 服务

Streamable HTTP

mcpso_mcp_servers_streamable_http

MCP 服务配置,如下示例:

{
  "tavily-mcp": {
    "transport": "streamable_http",
    "url": "https://router.mcp.so/mcp/xxxxxxxxxxx"
  }
}
SSE

mcpso_mcp_servers_sse

MCP 服务配置,如下示例:

{
  "tavily-mcp": {
    "url": "https://router.mcp.so/sse/xxxxxxxxxxx"
  }
}

通过 GitHub 安装插件

可以通过 GitHub 仓库地址安装该插件。访问 Dify 平台的插件管理页,选择通过 GitHub 安装插件,输入仓库地址后,选择版本号和包文件完成安装。

install_plugin_via_github


FAQ
1. How to Handle Errors When Installing Plugins? 安装插件时遇到异常应如何处理?

Issue: If you encounter the error message: plugin verification has been enabled, and the plugin you want to install has a bad signature, how to handle the issue?

Solution: Add the following line to the end of your .env configuration file: FORCE_VERIFYING_SIGNATURE=false Once this field is added, the Dify platform will allow the installation of all plugins that are not listed (and thus not verified) in the Dify Marketplace.

问题描述:安装插件时遇到异常信息:plugin verification has been enabled, and the plugin you want to install has a bad signature,应该如何处理?

解决办法:在 .env 配置文件的末尾添加 FORCE_VERIFYING_SIGNATURE=false 字段即可解决该问题。 添加该字段后,Dify 平台将允许安装所有未在 Dify Marketplace 上架(审核)的插件,可能存在安全隐患。

2. How to install the offline version 如何安装离线版本

Scripting tool for downloading Dify plugin package from Dify Marketplace and Github and repackaging [true] offline package (contains dependencies, no need to be connected to the Internet).

从 Dify 市场和 Github 下载 Dify 插件包并重新打【真】离线包(包含依赖,不需要再联网)的脚本工具。

Github Repo: https://github.com/junjiem/dify-plugin-repackaging

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。