Home / MCP / Dify MCP Server

Dify MCP Server

Provides an MCP server that triggers Dify workflows via MCP tools and clients.

typescript
Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
    "mcpServers": {
        "dify_mcp": {
            "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",
                "CONFIG_PATH": "/Users/you/config.yaml"
            }
        }
    }
}

You set up a Model Context Protocol (MCP) Server to invoke Dify workflows from any MCP-enabled client. This server serves as a bridge: you expose your Dify workflows to MCP clients, and the MCP client can trigger those workflows through a consistent, lightweight interface. This makes it easy to orchestrate Dify-powered tasks from multiple tools and environments.

How to use

You can run the MCP server locally or in your preferred environment and connect to it from any MCP-capable client. Two practical approaches exist: using the server through a remote configuration or running it directly from your machine with a local setup. In either case, you expose one or more Dify workflows to MCP clients so they can invoke them on demand.

How to install

Prerequisites: ensure you have a compatible runtime for MCP client configurations and a way to run the MCP server from your environment.

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

Additional configuration and usage notes

Optionally, you can configure the MCP server with a YAML config file and point the server runtime to that config using an environment variable if you prefer not to pass values directly in the client configuration.

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

Alternative local run via a config path

If you want to reference a local YAML config file through a path, you can pass the path to the client configuration so the MCP server reads the values from that file.

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

Working with a local uv command

You can also run the server from a local clone using the uv tool directly. The client configuration should reference the uv invocation and point to the local server directory.

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

Security and maintenance notes

Keep your Dify Base URL and App SKs confidential. Rotate SKs periodically and restrict access to the MCP client configurations. If you update the config file, reload or restart the MCP client to apply changes.