@wallacewen/dify-mcp-server
v1.0.0
Published
Model Context Protocol server for Dify AI integration - supports server management, monitoring, and system tools
Downloads
21
Maintainers
Readme
Dify MCP Server
A Model Context Protocol (MCP) server that integrates with Dify AI to provide server management, monitoring, and system administration tools through conversational AI.
Features
- 🧹 Log Cleaning: Automated server log cleaning and maintenance
- 🚀 Server Deployment: Environment deployment and Jenkins integration
- 📊 Server Monitoring: Real-time server resource monitoring (CPU, memory, disk)
- 🔧 System Tools: Network connectivity checks, port monitoring, and system utilities
- 🔒 Secure Configuration: Environment-based configuration for sensitive data
- 🎯 MCP Compatible: Works with Claude Desktop and other MCP clients
Installation
npm install -g @wallacewen/dify-mcp-serverOr with pnpm:
pnpm add -g @wallacewen/dify-mcp-serverConfiguration
Required Environment Variables
Before using the server, you must configure these environment variables:
| Variable | Description | Required |
|----------|-------------|----------|
| DIFY_API_TOKEN | Your Dify API authentication token | ✅ |
| DIFY_BASE_URL | Base URL of your Dify instance | ✅ |
| DIFY_DEFAULT_USER | Default user ID for Dify API requests | ✅ |
Environment Setup
Create a .env file or set environment variables:
# .env file
DIFY_API_TOKEN=your_dify_api_token_here
DIFY_BASE_URL=https://your-dify-instance.com
DIFY_DEFAULT_USER=your_user_id_hereOr export them in your shell:
export DIFY_API_TOKEN="your_dify_api_token_here"
export DIFY_BASE_URL="https://your-dify-instance.com"
export DIFY_DEFAULT_USER="your_user_id_here"Claude Desktop Configuration
Add the server to your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"dify-server": {
"command": "dify-mcp-server",
"env": {
"DIFY_API_TOKEN": "your_dify_api_token_here",
"DIFY_BASE_URL": "https://your-dify-instance.com",
"DIFY_DEFAULT_USER": "your_user_id_here"
}
}
}
}Usage
Once configured, the server provides the following tools through your MCP client:
🧹 Log Cleaning (dify_log_clean)
Clean server logs and manage log files:
Query: "清理服务器日志,10.0.19.41"
Query: "清理10.0.19.41 /var/log 目录下的旧日志文件"🚀 Server Deployment (dify_server_deployment)
Manage server deployments and Jenkins integration:
Query: "服务器环境到jenkins"
Query: "配置生产环境jenkins"📊 Server Monitoring (dify_server_monitoring)
Monitor server resources and performance:
Query: "查看服务器10.0.19.41的CPU和内存使用情况"
Query: "监控生产环境服务器资源状态"🔧 System Tools (dify_system_tools)
Execute system utilities and checks:
Query: "检查网络连通性ping baidu.com"
Query: "查看磁盘空间df -h"
Query: "检查端口8080占用netstat -tulpn | grep 8080"Development
Prerequisites
- Node.js >= 18.0.0
- pnpm (recommended) or npm
Setup
- Clone the repository:
git clone https://github.com/wallacewen/dify-mcp-server.git
cd dify-mcp-server- Install dependencies:
pnpm install- Set up environment variables:
cp .env.example .env
# Edit .env with your configuration- Build the project:
pnpm run build- Run in development mode:
pnpm run devTesting
Run the test suite:
pnpm testRun tests with coverage:
pnpm run test:coverageCode Quality
Format code:
pnpm run formatLint code:
pnpm run lintType check:
pnpm run check-typesRun all checks:
pnpm run ciHow to Get Dify Configuration
1. Get Your Dify API Token
- Log in to your Dify instance
- Go to your application settings
- Navigate to the "API Access" section
- Copy your API key
2. Get Your Dify Base URL
This is the base URL of your Dify instance, for example:
https://api.dify.ai(for Dify Cloud)https://your-domain.com(for self-hosted)
3. Get Your User ID
The user ID can be found in:
- Your Dify application logs
- API response headers
- Contact your Dify administrator
Troubleshooting
Common Issues
Missing Environment Variables
❌ Missing required environment variables:
DIFY_API_TOKEN
DIFY_BASE_URL
DIFY_DEFAULT_USERSolution: Ensure all required environment variables are set correctly.
Connection Errors
- Verify your
DIFY_BASE_URLis correct and accessible - Check your
DIFY_API_TOKENis valid and has proper permissions - Ensure your network allows connections to the Dify instance
Authentication Errors
- Verify your API token is correct
- Check if the token has expired
- Ensure the user ID has proper permissions
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Run the test suite
- Submit a pull request
License
MIT © Wallace Wen
Support
- 🐛 Report Issues
- 💬 Discussions
- 📧 Contact: [email protected]
