Dify Server

by YanxingLiu
Verified

local-only server

The server can only run on the client’s local machine because it depends on local resources.

用于 dify 工作流的模型上下文协议 (MCP) 服务器

一个使用dify 的MCP 服务器的简单实现,通过调用 MCP 的工具来实现对 Dify 工作流的调用。

🔨安装

服务器可以通过Smithery安装,也可以手动安装。两种安装方式都需要 Config.yaml 文件。因此,我们需要在安装前准备好它。

准备 config.yaml

在使用 mcp 服务器之前,你需要准备一个 config.yaml 文件来保存你的 dify_base_url 和 dify_sks。示例配置如下:

dify_base_url: "https://cloud.dify.ai/v1" dify_app_sks: - "app-sk1" - "app-sk2"

您可以在终端中运行以下命令来快速创建配置文件:

mkdir -p ~/tools && cat > ~/tools/config.yaml <<EOF dify_base_url: "https://cloud.dify.ai/v1" dify_app_sks: - "app-sk1" - "app-sk2" EOF

不同的SK对应不同的dify工作流程。

通过 Smithery 安装

smithery是一款自动安装 dify mcp 服务器的工具。要通过Smithery自动为 Claude Desktop 安装 Dify MCP 服务器,请执行以下操作:

提示: npm从 5.2 版本开始添加了npx命令。Mac 用户可以使用brew install node安装 npm 和

npx -y @smithery/cli install dify-mcp-server --client claude

除了claude之外,还支持cline, windsurf, roo-cline, witsy, enconvo, cursor

手动安装

❓ 如果您尚未安装 uv 或 uvx,则可以使用以下命令快速安装:

curl -Ls https://astral.sh/uv/install.sh | sh

✅ 方法一:使用 uv(本地克隆+uv 启动)

您也可以在客户端手动运行 dify mcp 服务器。客户端的配置格式如下:

{ "mcpServers": { "mcp-server-rag-web-browser": { "command": "uv", "args": [ "--directory", "${DIFY_MCP_SERVER_PATH}", "run", "dify_mcp_server" ], "env": { "CONFIG_PATH": "$CONFIG_PATH" } } } }

示例配置:

{ "mcpServers": { "dify-mcp-server": { "command": "uv", "args": [ "--directory", "/Users/lyx/Downloads/dify-mcp-server", "run", "dify_mcp_server" ], "env": { "CONFIG_PATH": "/Users/lyx/Downloads/config.yaml" } } } }

✅ 方法 2:使用 uvx(无需 clone 代码,推荐)

"mcpServers": { "dify-mcp-server": { "command": "uvx", "args": [ "--from","git+https://github.com/YanxingLiu/dify-mcp-server","dify_mcp_server" ], "env": { "CONFIG_PATH": "/Users/lyx/Downloads/config.yaml" } } }

好好享受

最后,您可以在任何支持 mcp 的客户端上使用 dify 工具。

-
security - not tested
F
license - not found
-
quality - not tested

Dify使用服务器,通过调用 MCP 的工具实现 Dify 工作流的调用。

  1. 🔨Installation
    1. Prepare config.yaml
    2. Installing via Smithery
    3. Manual Installation
    4. Enjoy it
ID: 0bnt6865ar