DI

Dify MCP Server for Workflow Automation

Automate Dify workflows with a lightweight MCP server implementation for easy deployment, integration, and scalable workflow automation.

Quick Install
npx -y @YanxingLiu/dify-mcp-server

Overview

Dify MCP Server is a lightweight implementation of a Model Context Protocol (MCP) server designed to automate and orchestrate workflows that involve models, tools, and external services. It acts as a mediator between your application and Dify-style model/tool ecosystems, exposing simple HTTP endpoints to run, manage, and monitor multi-step workflows. The server focuses on being easy to deploy and integrate into existing infrastructure while remaining scalable for production workloads.

This server is useful when you need to coordinate multi-tool sequences (for example, compose an LLM call with a web API fetch, run a short script, and persist results), schedule automated jobs, or expose a stable API surface for model-driven processes. Its lightweight footprint makes it suitable for containerized deployments, CI/CD pipelines, edge services, or as a local development harness for building complex automation flows.

Features

  • Exposes REST endpoints to create, run, and inspect workflows
  • Pluggable tool integrations (HTTP calls, script/shell execution, webhooks, LLM connectors)
  • Configurable concurrency and rate controls for safe scaling
  • Basic persistence for workflow definitions and run history (file or lightweight DB)
  • Health and metrics endpoints for observability
  • Docker-friendly with minimal external dependencies
  • Simple JSON-based workflow DSL to describe tool orchestration

Installation / Configuration

Clone and run the project locally, or run as a Docker container. Below are example steps — adapt to your environment.

Clone repository:

git clone https://github.com/YanxingLiu/dify-mcp-server.git
cd dify-mcp-server

Run locally (example for a Go/Node/Python binary):

# If the project has a build step (example for Go)
go build -o dify-mcp-server ./cmd/server
./dify-mcp-server --config=config.yaml

# Or if it's a Node app
npm install
npm start

Docker (recommended for consistent deployment):

docker build -t dify-mcp-server:latest .
docker run -d \
  -p 8080:8080 \
  -e MCP_PORT=8080 \
  -e DIFY_API_KEY=your_api_key \
  -e STORAGE_PATH=/data \
  -v $(pwd)/data:/data \
  dify-mcp-server:latest

Example config (config.yaml):

server:
  port: 8080
  log_level: info

dify:
  api_key: ${DIFY_API_KEY}
  host: https://api.dify.example.com

storage:
  backend: file
  path: ./data
concurrency:
  max_workers: 4

Common environment variables:

VariableDescriptionDefault
MCP_PORTHTTP port for the server8080
DIFY_API_KEYAPI key for Dify or LLM provider(none)
DIFY_HOSTBase URL for Dify APIhttps://api.dify.com
STORAGE_BACKENDfilefile
STORAGE_PATHwhere to store workflows./data
LOG_LEVELlogging verbosity (debug/info/warn)info

Available Tools / Resources

The server typically includes a set of built-in tool connectors you can use in workflow definitions:

  • HTTP Request Tool — make GET/POST requests to external APIs
  • Shell / Script Tool — run short scripts or shell commands (careful with security)
  • LLM Tool — call Dify or other model endpoints with prompt/context
  • Event / Webhook Tool — emit results to external webhooks or messaging systems
  • File Storage Tool — read/write small artifacts to configured storage

Tool adapters are pluggable: you can add new adapters by implementing a small interface (incoming payload, run, result) and registering them in configuration.

API Examples

Health check:

curl http://localhost:8080/health

Create a workflow (example payload):

curl -X POST http://localhost:8080/workflows \
  -H "Content-Type: application/json" \
  -d '{
    "id": "generate-report",
    "steps": [
      {"id":"fetch-data","tool":"http","input":{"url":"https://api.example.com/data"}},
      {"id":"summarize","tool":"llm","input":{"prompt":"Summarize the data: {{fetch-data.body}}"}},
      {"id":"notify","tool":"webhook","input":{"url":"https://hooks.example.com/notify","body":"{{summarize.output}}"}}
    ]
  }'

Run a workflow:

curl -X POST http://localhost:8080/runs \
  -H "Content-Type: application/json" \
  -d '{"workflow_id":"generate-report","inputs":{}}'

Fetch run status:

curl http://localhost:8080/runs/<run_id>

Node.js example to trigger a workflow:

const fetch = require('node-fetch');

async function runWorkflow() {
  const res = await fetch('http://localhost:8080/runs', {
    method: 'POST',
    headers: {'Content-Type': 'application/json'},
    body: JSON.stringify({workflow_id: 'generate-report'})
  });
  const data = await res.json();
  console.log('Run started', data);
}
runWorkflow();

Use Cases

  • Automated Content Pipelines: Orchestrate data fetch -> LLM summarization -> formatted output -> publish to CMS or webhook. Useful for news digests, product descriptions, or social posts.
  • Data Enrichment: Combine API calls (e.g., CRM, enrichment services) and an LLM step to normalize or enhance records before saving to a database.
  • E-commerce Workflows: After an order event, run a workflow to check inventory, suggest shipping options via an external API, and send notifications to the fulfillment team.
  • Scheduled Batch Jobs: Use a scheduler or cron job to trigger a workflow that aggregates daily logs, summarizes them with an LLM, and writes a report to storage or sends to a Slack webhook.
  • Integration Testing / Dev Harness: Run deterministic workflows locally that mirror production flows to validate logic and tool adapters before deploying.

Next Steps

  • Review the repository README and samples for concrete workflow definitions and adapter templates.
  • Secure your deployment: limit script execution, sanitize inputs, and use network rules for external tool calls.
  • Add or customize tool adapters to match your infrastructure (databases, queues, proprietary APIs).
  • Plug into your monitoring stack using health and metrics endpoints for production readiness.

GitHub: https://github.com/YanxingLiu/dify-mcp-server