MCP HubMCP Hub
YanxingLiu

dify-mcp-server

by: YanxingLiu

Model Context Protocol (MCP) Server for dify workflows

186created 25/12/2024
Visit
Protocol
Workflow

📌Overview

Purpose: The Model Context Protocol (MCP) Server enables seamless integration and invocation of Dify workflows by utilizing MCP tools.

Overview: The MCP Server serves as a lightweight implementation designed to facilitate the execution of Dify workflows effortlessly. It provides users with straightforward installation options and a structured configuration setup, allowing for streamlined operation across compatible clients.

Key Features:

  • Easy Installation: Users can install the Dify MCP Server automatically using Smithery or manually, ensuring flexibility in deployment methods.

  • Custom Configuration: A config.yaml file is required that allows users to define their Dify base URL and application secret keys (SKs), making it adaptable to various workflows.


Model Context Protocol (MCP) Server for dify workflows

A simple implementation of an MCP server for using dify. It enables the invocation of Dify workflows by calling the MCP tools.

📰 News

  • [2025/4/15] zNow supports directly using environment variables to pass base_url and app_sks, making it more convenient to use with cloud-hosted platforms.

🔨 Installation

The server can be installed via Smithery or manually.

Step 1: Prepare configuration

You can configure the server using either environment variables or a config.yaml file.

Method 1: Using Environment Variables (Recommended for Cloud Platforms)

Set the following environment variables:

export DIFY_BASE_URL="https://cloud.dify.ai/v1"
export DIFY_APP_SKS="app-sk1,app-sk2" # Comma-separated list of your Dify App SKs
  • DIFY_BASE_URL: The base URL for your Dify API.
  • DIFY_APP_SKS: A comma-separated list of your Dify App Secret Keys (SKs), each corresponding to a different Dify workflow.

Method 2: Using config.yaml

Create a config.yaml file to store your Dify base URL and App SKs.

Example config.yaml:

dify_base_url: "https://cloud.dify.ai/v1"
dify_app_sks:
  - "app-sk1" # SK for workflow 1
  - "app-sk2" # SK for workflow 2

You can quickly create this file with:

mkdir -p ~/.config/dify-mcp-server

cat > ~/.config/dify-mcp-server/config.yaml <<EOF
dify_base_url: "https://cloud.dify.ai/v1"
dify_app_sks:
  - "app-your-sk-1"
  - "app-your-sk-2"
EOF

echo "Configuration file created at ~/.config/dify-mcp-server/config.yaml"

When running the server, provide the path to this config.yaml file via the CONFIG_PATH environment variable.


Step 2: Install on your client

If you haven't installed uv or uvx yet, install quickly:

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

Method 1: Use uvx (Recommended, no need to clone code)

Example MCP server config:

{
  "mcpServers": {
    "dify-mcp-server": {
      "command": "uvx",
      "args": [
        "--from","git+https://github.com/YanxingLiu/dify-mcp-server","dify_mcp_server"
      ],
      "env": {
        "DIFY_BASE_URL": "https://cloud.dify.ai/v1",
        "DIFY_APP_SKS": "app-sk1,app-sk2"
      }
    }
  }
}

Or if using a config.yaml:

{
  "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"
      }
    }
  }
}

Method 2: Use uv (Local clone + uv start)

Run the dify MCP server manually in your client. Example configuration:

{
  "mcpServers": {
    "dify-mcp-server": {
      "command": "uv",
      "args": [
        "--directory", "/Users/lyx/Downloads/dify-mcp-server",
        "run", "dify_mcp_server"
      ],
      "env": {
        "DIFY_BASE_URL": "https://cloud.dify.ai/v1",
        "DIFY_APP_SKS": "app-sk1,app-sk2"
      }
    }
  }
}

Or if using a config.yaml:

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

Enjoy

You can now use dify tools in any MCP-supporting client.