Dify Cloud MCP Server
Exposes SQLite database tables (users, products, orders) as MCP tools, allowing AI agents to query real data from the database instead of generating fake answers.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Dify Cloud MCP ServerShow me all users in the sales department"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP Server for Dify Cloud
把 SQLite 数据库暴露为 MCP Tool,接入 Dify Cloud Chatflow/Agent,杜绝 LLM 编造数据——所有回答来自数据库真实记录。
场景
用户提问 → Dify API → Chatflow/Agent → MCP Tool → SQLite → 只返回真实数据Related MCP server: MCP SQLite Server
Windows 部署
1. 环境准备
# 安装 Python 3.10+(https://python.org 下载,记得勾选 "Add to PATH")
python --version
# 安装依赖
pip install -r requirements.txt2. 初始化数据库
python init_db.py3. 启动 MCP Server
python mcp_server.py
# 看到 "Uvicorn running on http://0.0.0.0:8000" 就是跑起来了4. 暴露公网(任选一种)
你的 PC 在内网,Dify Cloud 访问不到 127.0.0.1,需要打洞。
推荐:bore(零注册,一行命令)
去 https://github.com/ekzhang/bore/releases 下载 bore.exe,放到 PATH 里:
bore local 8000 --to bore.pub
# 输出 bore.pub:xxxxx备选:serveo(Windows 10/11 自带 SSH)
ssh -R 80:localhost:8000 serveo.net
# 输出 https://xxxxxxxx.serveousercontent.com5. 让 MCP Server 不掉线
关了终端就没了,用以下任一方式常驻后台:
NSSM(注册为 Windows 服务)
nssm install MCP_Server "python" "D:\mcp_dify_server\mcp_server.py"
nssm set MCP_Server AppDirectory "D:\mcp_dify_server"
nssm start MCP_Server或者简单写个 bat 放启动目录
@echo off
cd /d D:\mcp_dify_server
start /min python mcp_server.py
start /min bore local 8000 --to bore.pub接入 Dify Cloud
1. 添加 MCP Server
Dify 工作空间 → 工具 → MCP → 添加 MCP Server (HTTP)
URL 填入 bore 或 serveo 给的地址 + /mcp:
http://bore.pub:xxxxx/mcphttps://xxxxxxxx.serveousercontent.com/mcp
Dify 会自动发现 9 个 Tool。
2. 创建 Chatflow
新建 Chatflow 应用,拖入:开始 → Agent → 回答
Agent 节点里勾选所有 MCP Tool。
3. System Prompt(关键)
你是一个帮助查询公司内部数据库的助手。
你只能通过调用数据库工具获取数据,数据库里有 users(用户)、products(产品)、orders(订单)三张表。
规则:
1. 任何用户提问,必须先调用对应的数据库工具查询,不得直接回答
2. 如果工具返回"未找到匹配记录",如实告知用户未找到
3. 回答时只引用工具返回的真实数据,不得编造任何信息
4. 如果用户问题不够明确,调用工具尝试查询,而不是解释你为什么不知道4. 发布
右上角发布 → 拿到 API Key → 前端调 /v1/chat-messages
验证示例
问 Dify:"技术部有哪些人?"
返回:
张三 | zhangsan@example.com | 13800001001 | 技术部
赵六 | zhaoliu@example.com | 13800001004 | 技术部
吴九 | wujiu@example.com | 13800001007 | 技术部都是数据库里的真实记录,不是 LLM 编的。
自定义数据库
database.py 里已经有 users、products、orders 三张表。按需求修改表结构,然后在 mcp_server.py 里增减对应的 @mcp.tool() 即可。
环境变量
变量 | 默认值 | 说明 |
|
| 监听地址 |
|
| 监听端口 |
|
| 数据库路径 |
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/QUARES-1/dify-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server