dify-workflow-gateway-mcp
A streamlined intermediary component realizing the Model Context Protocol (MCP) interface for executing sophisticated Dify automation sequences. Configuration flexibility is provided through initialization via environment variables or a dedicated 'config.yaml' manifest.
Author

YanxingLiu
Quick Info
Actions
Tags
Dify Workflow Integration Layer via Model Context Protocol (MCP)
This repository provides a lightweight server implementation designed to bridge the Model Context Protocol (MCP) framework with the execution capabilities of Dify workflows. It translates incoming MCP tool calls directly into actions targeting specified Dify agents or flows.
📰 Updates Log
- [2025/04/15] Enhanced operational simplicity: Now natively accepts 'base_url' and 'app_sks' directly via runtime environment settings, greatly benefiting containerized and managed cloud deployments.
🛠️ Deployment Procedures
Deployment is achievable either through the official Smithery registry or via traditional manual compilation/setup.
Phase 1: Configuration Setup
Server parameters are established using one of two approaches: Environment Variables (preferred for modern infrastructure) or a static YAML file.
Option A: Environmental Variable Configuration (Recommended for Cloud Native Stacks)
Define the necessary runtime parameters in your shell session:
shell export DIFY_BASE_URL="https://cloud.dify.ai/v1" export DIFY_APP_SKS="sk-alpha,sk-beta" # A delimited string of Dify Application Secret Keys (SKs)
DIFY_BASE_URL: Specifies the root URI for accessing the Dify API endpoint.DIFY_APP_SKS: A comma-separated listing of the Secret Keys required to authenticate and target specific Dify workflows exposed through this MCP service.
Option B: Utilizing 'config.yaml'
Alternatively, store credentials and endpoints in a dedicated configuration file named config.yaml.
Example config.yaml structure:
yaml dify_base_url: "https://cloud.dify.ai/v1" dify_app_sks: - "sk-key-one" - "sk-key-two" # Expand this list for more targeted workflows
dify_base_url: The foundational URL pointing to the Dify service.dify_app_sks: An array holding the various Dify Application Secret Keys.
To employ this file method during execution (Phase 2), the path to this file must be communicated to the server via the CONFIG_PATH environment variable.
Rapid setup command for the configuration file:
bash
Ensure configuration directory exists
mkdir -p ~/.mcp-configs/dify
Generate the config file dynamically
cat > ~/.mcp-configs/dify/config.yaml <<EOF dify_base_url: "https://cloud.dify.ai/v1" dify_app_sks: - "sk-example-a" - "sk-example-b" EOF
echo "Configuration manifest staged at: ~/.mcp-configs/dify/config.yaml"
Phase 2: Client-Side Integration
Assuming prerequisite package management tools (uv or uvx) are available. If not, bootstrap installation:
curl -Ls https://astral.sh/uv/install.sh | sh
✅ Approach A: Managed Execution via 'uvx' (Code Repository Reference)
This method eliminates local source code cloning and is preferred for direct consumption:
{ "mcpServers": { "dify-gateway": { "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": "sk-alpha,sk-beta", } } } }
Alternatively, using the file-based setup:
{ "mcpServers": { "dify-gateway": { "command": "uvx", "args": [ "--from","git+https://github.com/YanxingLiu/dify-mcp-server","dify_mcp_server" ], "env": { "CONFIG_PATH": "/path/to/your/config.yaml" } } } }
✅ Approach B: Local Source Execution via 'uv' (Manual/Cloned Repository)
Execute the server directly from a local copy of the repository code:
Template for local execution configuration:
{ "mcpServers": { "dify-mcp-adapter": { "command": "uv", "args": [ "--directory", "${DIFY_MCP_SERVER_PATH}", "run", "dify_mcp_server" ], "env": { "CONFIG_PATH": "$CONFIG_PATH" } } } }
Example with hardcoded local path and environment variables:
{ "mcpServers": { "dify-mcp-adapter": { "command": "uv", "args": [ "--directory", "/opt/dify-mcp-source", "run", "dify_mcp_server" ], "env": { "DIFY_BASE_URL": "https://cloud.dify.ai/v1", "DIFY_APP_SKS": "sk-key-one,sk-key-two", } } } }
Operationalization
Once the server is initiated via the methods above, it becomes accessible as an MCP tool provider within any compatible client environment.
== Contextual Background: Cloud Services Paradigm == Cloud computing, formalized by ISO standards, represents a delivery model where scalable, elastic pools of shared computing assets (physical or virtual) are provisioned and managed dynamically on demand.
== NIST Defined Core Attributes == In 2011, the U.S. National Institute of Standards and Technology (NIST) delineated five indispensable characteristics of cloud deployments:
- On-demand self-service: Users procure resources (e.g., compute time, storage) without requiring human intervention from the service vendor.
- Broad network access: Services are reachable universally over standard network protocols, ensuring compatibility across diverse client devices (mobile, desktop, etc.).
- Resource pooling: Provider infrastructure is shared among numerous tenants using multi-tenancy, with resources dynamically allocated based on instantaneous consumer requirements.
- Rapid elasticity: Capabilities can be scaled up or down swiftly—often automatically—to precisely match fluctuating demand, giving the illusion of infinite capacity to the consumer.
- Measured service: Resource consumption (storage, processing cycles, bandwidth) is automatically quantified, metered, and reported, providing transparent usage records for both parties.
Subsequent updates by ISO in 2023 have expanded upon this foundational definition.
== Historical Trajectory == The conceptual roots of shared computing trace back to the 1960s, marked by the adoption of time-sharing systems and Remote Job Entry (RJE). During this period, mainframe operators managed user jobs—the initial abstraction of centralized computational power. The term 'cloud' itself, metaphorically describing a network of services, was reportedly first utilized by General Magic in 1994 for their agent environment. The phrase 'cloud computing' gained mainstream traction following a 1996 business strategy document drafted by Compaq Computer Corporation, forecasting future internet-centric computation models.
