TypeScript MCP server transforms Dify workflows into tools with streaming support and YAML configuration
The Dify MCP Server is a robust, open-source TypeScript implementation that seamlessly integrates advanced AI models into a unified protocol known as Model Context Protocol (MCP). This MCP server converts Dify applications into tools accessible via MCP, enabling them to work with various AI clients. By providing type safety and configurability through a YAML file, the server ensures a smooth and efficient interaction between AI applications like Claude Desktop, Continue, Cursor, and others.
The Dify MCP Server boasts several key features that make it an essential tool for developers and AI application integrators:
The architecture of the Dify MCP Server is designed around the core principles of the Model Context Protocol (MCP). This protocol acts as a universal adapter, allowing diverse AI applications to interact with specific data sources and tools through a standardized interface. The server's main components include:
graph TD
A[AI Application] -->|MCP Client| B[MCP Protocol]
B --> C[MCP Server]
C --> D[Data Source/Tool]
style A fill:#e1f5fe
style C fill:#f3e5f5
style D fill:#e8f5e8
graph LR;
A[Dify Workflow] --> B[Streaming API Responses]
B --> C[MCP Server]
C --> D[Client Application Interface]
D --> E[Data Source/Tool]
style A fill:#e0f2ff
style C fill:#f4e8eca9
style D fill:#e6ffe6
Installing the Dify MCP Server is straightforward and can be done using both Smithery or traditional command-line methods. Follow these steps to set up your environment:
To install the Dify MCP Server for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @faiz-gear/dify-mcp-server-ts --client claude
Clone the Repository
git clone <repository-url>
cd dify-mcp-server-ts
Install Dependencies
npm install
Create a Configuration File
# config.yaml
dify_base_url: 'https://api.dify.ai/v1'
dify_app_sks:
- 'your-dify-app-sk-1' # Replace with your actual Dify app secret key
- 'your-dify-app-sk-2' # Replace with your actual Dify app secret key
The Dify MCP Server enables developers to build versatile AI workflows by integrating various tools and data sources. Here are two real-world scenarios:
Automated Content Generation: Combine an AI text generator workflow from Dify with a content management system (CMS) via MCP, allowing for the creation and deployment of dynamic blog posts or articles in near-real-time.
Customized Marketing Campaigns: Use a pre-trained email marketing workflow provided by Dify alongside CRM systems to craft personalized emails that target specific users based on their behavior metrics.
graph LR;
A[AI Text Generator] --> B[MCP Server]
B --> C[CMS Interface]
style A fill:#e0f2ff
style B fill:#f3e5f5
style C fill:#e6ffe6
graph LR;
A[Personalization Engine] --> B[MCP Server]
B --> C[CMS Interface]
style A fill:#e0f2ff
style B fill:#f3e5f5
style C fill:#e6ffe6
The Dify MCP Server ensures seamless integration with a variety of AI clients that support the MCP protocol. The following matrix highlights the current compatibility status:
MCP Client | Resources | Tools | Prompts |
---|---|---|---|
Claude Desktop | ✅ | ✅ | ✅ |
Continue | ✅ | ✅ | ✅ |
Cursor | ❌ | ✅ | ❌ |
The compatibility and performance metrics of the Dify MCP Server are as follows:
These benchmarks ensure optimal performance even under heavy load conditions.
Advanced users can configure the Dify MCP Server using a custom YAML file or environment variables. Here's an example of how to specify configurations:
{
"mcpServers": {
"[server-name]": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-[name]"],
"env": {
"API_KEY": "your-api-key"
}
}
}
}
This sample configuration demonstrates how to integrate the Dify MCP Server with a custom environment:
# config.yaml
mcpServers:
server-one:
command: npx
args: ["-y", "@modelcontextprotocol/server-template"]
env:
API_KEY: your-api-key
Q: Can I integrate multiple Dify applications with a single MCP Server? A: Yes, the server supports integration of multiple Dify applications by defining different resources and tool configurations.
Q: How do I handle errors during the streaming process? A: The server is designed to handle streaming gracefully. In case of an error, it will notify the client and stop streaming until the issue is resolved.
Q: What happens when too many clients request simultaneously? A: The server has built-in throttling mechanisms to prevent overload. Excessive requests are rate-limited or queued, ensuring stable performance.
Q: Can I change API keys dynamically without restarting the server? A: Yes, environment variables can be updated in real-time which will affect the configurations without a restart.
Q: Is security enabled by default for MCP requests? A: The server includes basic authentication and encryption to secure MCP interactions, but advanced security configurations may vary based on client needs.
Contributions are welcome from the community! To contribute:
Join the MCP community by exploring related resources, tutorials, and forums:
Participate in discussions and collaborate with other developers to enhance the MCP ecosystem.
This comprehensive documentation positions the Dify MCP Server as a valuable tool for integrating advanced AI applications into a standardized protocol, ensuring seamless integration across multiple clients and use cases.
RuinedFooocus is a local AI image generator and chatbot image server for seamless creative control
Learn to set up MCP Airflow Database server for efficient database interactions and querying airflow data
Simplify MySQL queries with Java-based MysqlMcpServer for easy standard input-output communication
Access NASA APIs for space data, images, asteroids, weather, and exoplanets via MCP integration
Explore CoRT MCP server for advanced self-arguing AI with multi-LLM inference and enhanced evaluation methods
Build stunning one-page websites track engagement create QR codes monetize content easily with Acalytica