
Dify Mcp
io.github.salted-butter-joshuaPublished by GitHub account salted-butter-joshuav0.1.0Updated Oct 24, 2026
MCP server exposing Dify knowledge base retrieval to Cursor and other MCP clients
Overview
Lets an assistant search and browse Dify knowledge bases through the Dify Knowledge API.
- What you can do
- Connects an MCP client to a self-hosted or remote Dify instance over HTTP and exposes its knowledge base retrieval. Tools list allowed datasets, fetch one dataset's metadata, run semantic chunk retrieval, and list documents and their text segments. A dataset allowlist restricts which dataset UUIDs are reachable.
- When to use it
- Use it when your team keeps documentation or internal knowledge in Dify and you want an assistant to retrieve relevant chunks and browse documents from that knowledge base. It suits setups where Dify is already running and reachable from your machine.
- Requirements
- Local Python 3.11+ runtime with the dify-mcp package installed, plus a running Dify instance with the Knowledge Base API enabled. Required environment variables: DIFY_API_BASE, DIFY_API_KEY and DIFY_ALLOWED_DATASETS; optional DIFY_TIMEOUT and DIFY_VERIFY_SSL. Network access from your machine to the Dify API endpoint is needed.
Installation
In SourceWeft
- Open Dify Mcp in the dashboard and add it to a workspace.
- Enable the server for the chats that should use its tools.
Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.
Other MCP clients
Follow the launch instructions in the repository.
README
dify-mcp
Expose Dify knowledge base retrieval capabilities via MCP (Model Context Protocol), for use in Cursor and other MCP-compatible clients.
Connect to a self-hosted or remote Dify instance over HTTP, with optional dataset allowlisting for access control.
Features
- Knowledge base discovery — list and inspect allowed datasets
- Semantic retrieval — search chunks via Dify
POST /datasets/{dataset_id}/retrieve - Document browsing — list documents and segments within a dataset
- Dataset allowlist — restrict access to specific
dataset_idvalues - stdio transport — no manual server startup; the MCP client launches the process
Requirements
- Python 3.11+
- A running Dify instance with Knowledge Base API enabled
- Network access from the machine running the MCP server to your Dify API endpoint
- A Dify Knowledge Base API Key (Dify → Knowledge → Service API → API Key)
Quick Start
1. Clone and install
Verify import:
2. Configure environment
Copy the example env file and edit it:
Run the health check:
3. Add to Cursor
You do not need to start the MCP server manually. Cursor launches it automatically via stdio.
- Open Cursor Settings → MCP → Edit config
- Add the following to
mcpServersin your MCP config file:- Windows:
%USERPROFILE%\.cursor\mcp.json - macOS / Linux:
~/.cursor/mcp.json
- Windows:
- Replace paths and env values with your own
- Restart Cursor
See mcp.json.example for a full example.
Windows example:
macOS / Linux example:
4. Verify in Cursor
- Cursor Settings → MCP → confirm
dify-knowledgeshows as enabled - In chat, try:
- List available Dify knowledge bases
- Search the knowledge base for "your query"
MCP Tools
Architecture
The MCP server runs locally on your machine and calls the Dify API over the network. Dify does not need to reach your machine.
Troubleshooting
Project Structure
API Reference
- Dify Knowledge Base API (official)
- Retrieve chunks
- Local path reference:
Dify-API.md
Security Notes
- Never commit
.envor API keys to version control - A single Knowledge Base API key can access all visible datasets under the account — use
DIFY_ALLOWED_DATASETSto limit exposure - Prefer running MCP locally; keep API keys in
mcp.jsonenv or.envon your machine only
Source: README.md at commit 3a0957b
Tools
0Version history
1- v0.1.0LatestSep 16, 2026
Score
50% of the applicable checks met
How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.
- Reached in the last 30 days25 pts
Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.
- Auth declared10 pts
Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.
- Tools listed15 pts
Answer tools/list without a credential, or ship a package that starts in a sandbox without one.
- DescriptionRequired15 pts
- Logo10 pts
- Documentation15 pts
- License10 pts