dify-mcp-server
The dify-mcp-server is a Model Context Protocol (MCP) server integrated with the Dify AI API. This server provides code generation capabilities for Ant Design business components and supports both text and image inputs. It also implements streaming response handling, making it easy for developers to build applications utilizing AI. Implemented in TypeScript, it serves as a good example of core MCP concepts.
GitHub Stars
40
User Rating
Not Rated
Favorites
0
Views
18
Forks
11
Issues
1
Installation
Difficulty
IntermediateEstimated Time
10-20 minutes
Requirements
Node.js: 18.0.0以上npm: 8.0.0以上Installation
Installation
Prerequisites
Please specify required software and versions:Node.js: 18.0.0 or higher
npm: 8.0.0 or higher
Installation Steps
1. Clone Repository
bash
git clone https://github.com/AI-FE/dify-mcp-server
cd dify-mcp-server
2. Install Dependencies
bash
npm install
3. Build Server
bash
npm run build
4. Start Server
bash
npm start
Troubleshooting
Common Issues
Issue: Server won't start Solution: Check Node.js version and reinstall dependencies.Configuration
Configuration
Basic Configuration
Setup in Continue
Add the following configuration to~/.continue/config.json:
json
{
"experimental": {
"modelContextProtocolServers": [
{
"transport": {
"type": "stdio",
"command": "node",
"args": ["your/path/dify-server/build/index.js"],
"env": {
"DIFY_API_KEY": "*"
}
}
}
]
}
}
Setup in Cline
Add the following configuration toyour/path/cline_mcp_settings.json:
json
{
"mcpServers": {
"dify-server": {
"command": "node",
"args": ["your/path/dify-server/build/index.js"],
"env": {
"DIFY_API_KEY": "*"
}
}
}
}
Environment Variables
Set the following environment variable as needed:bash
export DIFY_API_KEY="your-api-key"
Security Settings
Store API keys in environment variables
Set appropriate file access permissions
Examples
Examples
Basic Usage
Here are basic usage examples for the MCP server:Using with Claude Desktop
1Verify MCP Server Startup
Open Claude Desktop and confirm that the configuration has been loaded correctly.
2Execute Basic Commands
Available tools from this MCP server:
- antd-component-codegen-mcp-tool: Code generation for Ant Design components
Programmatic Usage
javascript
// JavaScript example (Node.js)
const { MCPClient } = require('@modelcontextprotocol/client');
const client = new MCPClient();
await client.connect();
// Execute tool
const result = await client.callTool('antd-component-codegen-mcp-tool', {
input: 'example input',
image: 'path/to/image.png'
});
console.log(result);
Advanced Examples
Automation Script
bash
#!/bin/bash
Batch processing example
for file in *.txt; do
mcp-tool process "$file"
done
Use Cases
Developing chatbots utilizing Dify AI
Automating the generation of Ant Design components for frontend development
Building data analysis tools using image inputs
Creating applications with real-time user interactions