dify-mcp-server

MCP.Pizza Chef: YanxingLiu

The dify-mcp-server is a lightweight Model Context Protocol (MCP) server designed to integrate dify AI workflows into MCP-enabled environments. It facilitates the invocation of dify workflows by calling MCP tools, allowing developers to embed dify's AI capabilities within their applications seamlessly. The server supports configuration via environment variables or a config.yaml file, making it flexible for both local and cloud-hosted deployments. With support for environment variable-based configuration, it simplifies secure and scalable usage in cloud platforms. Installation is straightforward via Smithery or manual setup, enabling rapid adoption. This server is ideal for developers looking to leverage dify's AI workflow automation within the MCP ecosystem.

Use This MCP server To

Invoke dify AI workflows through MCP tool calls Integrate dify workflows into AI-enhanced applications Configure dify server for cloud or local environments Automate AI task execution using dify within MCP Manage multiple dify app keys via environment variables

README

Model Context Protocol (MCP) Server for dify workflows

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

📰 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.

Step1: prepare config.yaml or enviroments

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 SK typically corresponds to a different Dify workflow you want to make available via MCP.

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
  # Add more SKs as needed
  • dify_base_url: The base URL for your Dify API.
  • dify_app_sks: A list of your Dify App Secret Keys (SKs). Each SK typically corresponds to a different Dify workflow.

You can create this file quickly using the following command (adjust the path and values as needed):

# Create a directory if it doesn't exist
mkdir -p ~/.config/dify-mcp-server

# Create the config file
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 (as shown in Step 2), you will need to provide the path to this config.yaml file via the CONFIG_PATH environment variable if you choose this method.

Step2: Installation on your client

❓ If you haven't installed uv or uvx yet, you can do it quickly with the following command:

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

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

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

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

You can also run the dify mcp server manually in your clients. The config of client should like the following format:

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

or

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

Example config:

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

Enjoy it

At last, you can use dify tools in any client who supports mcp.

dify-mcp-server FAQ

How do I configure dify-mcp-server for cloud deployment?
Use environment variables DIFY_BASE_URL and DIFY_APP_SKS to set the base URL and app secret keys, ideal for cloud platforms.
Can I install dify-mcp-server manually?
Yes, you can install it manually or via Smithery for convenience.
What is the purpose of the config.yaml file?
It provides an alternative to environment variables for configuring the server settings.
How does dify-mcp-server invoke dify workflows?
It calls MCP tools that trigger dify workflows, enabling seamless integration.
Is dify-mcp-server compatible with multiple dify app keys?
Yes, it supports a comma-separated list of app secret keys for managing multiple dify apps.
Does dify-mcp-server support secure API key management?
Yes, by using environment variables, it supports secure and flexible API key management suitable for cloud environments.
Can dify-mcp-server be used with other LLM providers?
While focused on dify workflows, it can be integrated within MCP environments that also support OpenAI, Claude, and Gemini models.
Where can I find installation instructions?
Installation instructions are available on the GitHub repository and via Smithery.ai.