mcpField
D
Dify Plugin Agent Mcp_sse

Dify Plugin Agent Mcp_sse

github.com/junjiem框架与 SDK13928 周前更新

关于 Dify Plugin Agent Mcp_sse

Dify Plugin Agent Mcp_sse 是 Dify 1.0 的 Agent 策略插件集合,提供 Function Calling 与 ReAct 两种策略。它可通过 SSE 或 Streamable HTTP 传输连接多个 MCP 服务,并发现、调用其中的工具,适合在 Dify 中构建使用 MCP 工具的 Agent。

主要功能

  1. 01提供 Function Calling 与 ReAct 策略
  2. 02支持 SSE 与 Streamable HTTP 传输
  3. 03可同时配置多个 MCP 服务
  4. 04支持连接托管的 MCP 服务
  5. 05可通过 GitHub 地址安装插件

适用场景

  1. 01在 Dify 工作流中为 Agent 添加 MCP 工具
  2. 02连接 Composio 或 Zapier 托管的 MCP 服务
  3. 03通过 GitHub 地址安装插件并选择版本

MCP 相关

该项目是 MCP 客户端,在 Dify 的 Agent 策略中配置并连接 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 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。