
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 分