# Dify MCP

> Dify MCP connects your AI agent directly to Dify's backend services. It lets your agent send chat messages, retrieve conversation history, manage files, audit app settings, and submit performance feedback—all without leaving the conversational interface. Use this when you need an LLM application client to run complex, structured workflows against a dedicated AI platform.

## Overview
- **Category:** ai-frontier
- **Price:** Free
- **Tags:** llmops, agent-orchestration, rag-pipeline, workflow-automation, conversation-management, api-management

## Description

This MCP hands your AI agent full control over its operational context within Dify. Instead of just having a single chat window, your agent can now execute multi-step tasks that mimic real software development pipelines. It tracks conversations by listing historical data and analyzing message arrays to pinpoint exactly what was discussed. You can also securely upload files for the agent to process or check the app's structural limits using `get_parameters`. This gives developers a clear path to test and refine their LLM applications without needing external API calls. When you connect it via Vinkius, your agent gains access to this entire suite of Dify tools through natural conversation.

## Tools

### chat
Sends an explicit text message into the Dify agent for immediate action or response.

### list_conversations
Gets a list of recent conversations associated with your Dify project for review.

### list_messages
Retrieves all the historical messages within a specific conversation thread.

### get_parameters
Retrieves and reports on the current configuration limits set within your Dify application workspace.

### upload_file
Sends a local file or binary data to Dify for secure ingestion and processing by the agent.

### feedback
Submits a 'like' or 'dislike' rating to track the performance of a specific message.

## Prompt Examples

**Prompt:** 
```
Send a message to my Dify agent: 'Explain the benefits of RAG.'
```

**Response:** 
```
Dify agent response: 'Retrieval-Augmented Generation (RAG) combines LLMs with external knowledge bases to provide more accurate and context-aware answers...' Would you like to save this to a new conversation?
```

**Prompt:** 
```
List my recent Dify conversations for user 'admin_123'
```

**Response:** 
```
I found 5 recent conversations for 'admin_123'. The latest is 'AI Strategy Discussion' (ID: conv_abc), followed by 'Customer Support Case #456'. Which one would you like to open?
```

**Prompt:** 
```
Give a 'like' to message 'msg_789' in Dify
```

**Response:** 
```
Feedback submitted! I've sent a 'like' for message 'msg_789'. This will help improve the performance tracking of your Dify agent in the dashboard.
```

## Capabilities

### Send conversational messages
Your agent sends specific chat messages directly into the Dify environment.

### Manage conversation history
The agent can list past interactions and retrieve detailed message logs for auditing purposes.

### Upload files securely
You can pass local binaries to the agent, which uploads them as attachments within Dify.

### Audit application settings
The agent checks and reports on the current configuration limits of the referenced Dify workspace.

### Submit performance feedback
You can give a 'like' or 'dislike' to any message, helping track the AI’s overall performance.

## Use Cases

### Auditing a customer support interaction
A team lead needs to review why an agent provided bad advice. They ask their agent to run `list_conversations` first, then select the relevant thread. Finally, they use `list_messages` to get every single message and track down which prompt caused the error.

### Testing a new knowledge base feature
A developer wants to see how well their agent handles PDFs. They first run `get_parameters` to check the file constraints, then use `upload_file` to feed in a test PDF, and finally chat with it using the `chat` tool.

### Analyzing overall product health
The Product team wants an aggregate view of agent performance. They run `list_conversations`, spot several threads that seem problematic, and then use `feedback` to submit 'dislikes' on the worst messages.

### Debugging a complex multi-step workflow
An engineer notices an agent is failing. They ask the agent to list all recent conversations using `list_conversations`, pinpoint the problematic ID, and then use `list_messages` on that specific thread for deep debugging.

## Benefits

- Instead of manually checking logs, you can use `list_messages` to pull the full conversation history directly into your agent's context for review.
- You don’t have to leave your chat client to test file handling. Just prompt the agent, and it uses `upload_file` to securely ingest local binaries for testing.
- Monitoring performance is simple: after a session, use `feedback` to submit ratings, feeding valuable data back into Dify's CRM environment automatically.
- Need to verify constraints? `get_parameters` gives you immediate access to the structural limits of your workspace without needing to consult separate documentation pages.
- You can track an agent’s entire lifecycle—from initial setup parameters via `list_conversations` to final performance ratings using `feedback`.

## How It Works

The bottom line is that you treat complex API calls like simple conversation commands.

1. Subscribe to this MCP and provide your Dify API URL and Application-specific API Key.
2. Your agent uses natural language prompts to trigger specific functions, like asking it to list recent conversations or upload a document.
3. The MCP executes the tool call on the Dify backend and returns structured data back to your AI client.

## Frequently Asked Questions

**How do I check my Dify app limits using the `get_parameters` tool?**
You ask your agent to 'Check the structural parameters for this workspace.' The agent will then call `get_parameters` and return a report detailing the global constraints you've set up.

**Can I use the `upload_file` tool with different file types?**
Yes, the tool is designed to securely transmit local binaries. The agent handles the ingestion of various types, though checking parameters first can confirm supported formats.

**How does the `feedback` tool actually improve my Dify agent?**
Using `feedback` submits explicit message-level data (like/dislike) that is used by Dify to track performance metrics and identify areas where your agent needs retraining or improvement.

**`list_conversations` vs. `list_messages`: what's the difference?**
Use `list_conversations` first; it gives you a high-level overview of recent chat sessions and their IDs. Then, if you need details, use `list_messages` with that ID to get the full thread content.

**What credentials do I need to use the Dify MCP tools?**
You must subscribe to this MCP and provide your specific Dify API URL and an Application-specific API Key. These keys are found within your Dify App's API Access settings.

**How can I get the full, structured message history of a conversation using `list_messages`?**
It retrieves detailed arrays that map every interaction in a conversation. These listings include timestamps, roles (user or agent), and the specific content for each historical message.

**If I need to send a complex prompt structure using `chat`, how does it work?**
The `chat` tool accepts explicit strings, allowing you to embed formatted text, markdown, or structured data directly into the agent's conversation flow. This ensures the agent receives exactly what you intend.

**Does `list_conversations` tell me about files attached to a specific dialogue?**
Yes, it extracts array vectors that represent company-wide conversation listings. These structures often contain pointers or references to attachments made during the recorded discussions.

**Can my agent interact with a specific Dify application via chat?**
Yes. When you provide the Application API Key, the agent uses the 'chat' mutation to send your query directly to that Dify agent. It returns the AI response within your current chat context, allowing for seamless integration.

**How do I retrieve the conversation history from my Dify project?**
Use the 'list_conversations' tool. Your agent will pull the explicitly attached array vectors representing your conversation listing. You can then use 'list_messages' with a specific ID to see the detailed interactions.

**Can I upload files to my Dify agents through this server?**
Absolutely. The 'upload_file' tool allows you to transmit local binaries securely. The agent maps these files internally against standard Dify attachments, making them available for your Dify agents to process.