
Dify Mcp
io.github.salted-butter-joshua由 GitHub 帳號 salted-butter-joshua 發布v0.1.0更新於 Oct 24, 2026
MCP server exposing Dify knowledge base retrieval to Cursor and other MCP clients
概覽
讓助理透過 Dify 知識庫 API 檢索與瀏覽 Dify 知識庫。
- 可以做什麼
- 透過 HTTP 將 MCP 用戶端連線到自架或遠端 Dify 執行個體,並開放其知識庫檢索能力。工具可列出允許的資料集、取得單一資料集的詮釋資料、執行語意分段檢索,以及列出文件與其文字分段。資料集允許清單可限制可存取的 dataset UUID。
- 適用情境
- 當團隊把文件或內部知識放在 Dify,並希望助理從該知識庫檢索相關分段、瀏覽文件時使用。適合 Dify 已在運作且本機可連線的環境。
- 執行需求
- 本機需 Python 3.11+ 執行環境並安裝 dify-mcp 套件,另需一個已啟用知識庫 API 的 Dify 執行個體。必要環境變數為 DIFY_API_BASE、DIFY_API_KEY 與 DIFY_ALLOWED_DATASETS;選用 DIFY_TIMEOUT 與 DIFY_VERIFY_SSL。本機需能透過網路連線到 Dify API 端點。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Dify Mcp,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
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
來源:README.md,提交 3a0957b
工具
0版本歷史
1- v0.1.0最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分