The Model Context Protocol (MCP) Server for Dify workflows enables you to use Dify workflows through the Model Context Protocol (MCP). This implementation calls Dify workflows by leveraging MCP tools, allowing seamless integration between MCP-compatible clients and your existing Dify workflows.
The server can be installed via Smithery or manually following these steps.
You can configure the server using either environment variables or a config.yaml
file.
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 APIDIFY_APP_SKS
: Comma-separated list of your Dify App Secret Keys (SKs)Create a config.yaml
file with your Dify settings:
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
You can create this file quickly using:
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"
First, install UV if you haven't already:
curl -Ls https://astral.sh/uv/install.sh | sh
Add this configuration to your client's MCP server settings:
{
"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 file:
{
"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"
}
}
}
}
Clone the repository locally, then configure your client:
{
"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"
}
}
}
}
Once the server is configured and running, you can use Dify tools in any client that supports MCP. The server will automatically expose your configured Dify workflows as MCP tools, making them available to your MCP-compatible clients.
The server handles the communication between your MCP client and the Dify API, translating MCP tool invocations into Dify workflow executions and returning the results back to your client.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.