Dify Workflows MCP server

Integrates with the Dify API to enable AI-driven workflow execution and management for automated task processing and decision making across domains.
Back to servers
Provider
gotoolkits
Release date
Dec 26, 2024
Language
Go
Stats
42 stars

The mcp-difyworkflow-server provides a way to integrate and interact with Dify workflows through the Model Context Protocol (MCP). It allows you to query and invoke multiple custom Dify workflows on demand, serving as a bridge between your applications and the Dify platform.

Installation

You can install the mcp-difyworkflow-server by following these steps:

# Clone the repository
git clone https://github.com/gotoolkis/mcp-difyworkflow-server.git

# Navigate to the project directory
cd mcp-difyworkflow-server

# Build using Go
go build .

# Alternatively, use make to build
make build

Configuration

The server requires proper configuration to connect with your Dify workflows. Create a configuration file with the following structure:

{
  "mcpServers": {
    "mcp-difyworkflow-server": {
      "command": "mcp-difyworkflow-server",
      "args": ["-base-url", "http://localhost/v1"],
      "env": {
        "DIFY_WORKFLOW_NAME": "workflow-translator,workflow-genImage",
        "DIFY_API_KEYS": "appkey-xxxxxxxxxxxa,appkey-xxxxxxxxxxxb"
      }
    }
  }
}

Configuration Parameters

  • base-url: The base URL of your Dify platform API server

  • command: The command to execute the server binary

    • You can specify an absolute path to the binary
    • Alternatively, create a symbolic link with:
      sudo ln -s <gitWorkPath>/mcp-difyworkflow-server /usr/local/bin/mcp-difyworkflow-server
      
  • DIFY_WORKFLOW_NAME and DIFY_API_KEYS:

    • These must correspond one-to-one in order
    • Workflow names can be self-defined in your Prompt
    • You'll need to generate API Keys for each workflow from the Dify platform

Using the Server

The mcp-difyworkflow-server provides two main functions:

Available Commands

  • list_workflows: Lists all authorized workflows you have access to
  • execute_workflow: Executes a specified workflow
    • Arguments required: workflow_name, input
    • Note: The input variable name in your Dify workflow should be defined as "message"

Examples

You can interact with the server using prompts like:

查看 mcp-difyworkflow-server 可使用的工具列表

This will list all available workflows.

给我执行 dify 名为 workflow-translator 的工作流,输入的消息为"这是一条测试消息"

This will execute the "workflow-translator" workflow with the message "这是一条测试消息".

In English:

View the list of tools available for mcp-difyworkflow-server.
Execute the workflow named 'workflow-translator' for me, the input message is "This is a test message".

How to add this MCP server to Cursor

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.

Adding an MCP server to Cursor globally

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

Adding an MCP server to a project

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.

How to use the MCP server

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.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later