🏥 MCP医院助理
一个由React、Node.js、PostgreSQL和Mistral LLM(通过Ollama)支持的全栈智能医院预约管理系统。
🔥 预览
🎥 演示视频
🏠 仪表盘
💬 LLM聊天助理
💬 人工预订
🔁 Node.js + Express
🎨 React.js (frontend)
🧠 LLM (Ollama - Mistral)
💾 PostgreSQL
🛡️ Session-based login📷 UI预览
Login / Register Page
Dashboard with buttons to manage system manually
Book Appointment (manual)
LLM-powered auto assistant interface📁 项目结构
├── 后端/ │ ├── server.js#Node.js+Express后端 │ ├── config/config.js#PostgreSQL配置 │ ├── mcp/#所有业务逻辑处理程序 │ ├── auth/#登录、注册、会话路由 ├── 前端/ │ └── mcp-ui/#React前端 │ ├── 组件/#添加医生、聊天、登录、主页等。 │ └── App.js#主路由控制器
⚙️ 安装说明
- ✅ 安装PostgreSQL并创建数据库
sudo apt安装postgresql-postgresql-contrib sudo-u postgres psql
然后运行:
创建数据库mcp; 使用密码“mcppass”创建用户mcpuser; 将数据库mcp的所有特权授予mcpuser;
- 📦 创建架构
连接:
psql-U mcpuser-d mcp-h本地主机
创建TABLE医生( doctor_id序列主键, 名称TEXT, TEXT部门, 可用_插槽JSONB );
创建TABLE患者( 患者id序列主键, 名称TEXT, 年龄整数, 联系TEXT );
创建TABLE约会( appoint_id序列主键, doctor_id指代医生(doctor_id), 患者id INTEGER参考患者(患者id), 约会_时间文本 );
创建TABLE用户( id串行主键, 用户名TEXT UNIQUE, 密码文本 );
将Scheme公共区域所有桌子上的所有特权授予mcpuser; 将方案中所有序列的所有特权授予mcpuser;
- 🧠 用Mistral安装Ollama
curl-fsSLhttps://ollama.com/install.sh|sh 奥拉玛跑米斯特拉尔
确保本地Ollama服务器正在运行,并且在默认端口11434上可用。 4.🚀 后端设置(Node.js)
cd后端/ npm安装 node-server.js
这将在以下时间启动后端:http://localhost:3007 5.💻 前端设置(React)
cd前端/mcp用户界面 npm安装 npm启动
这从前端开始:http://localhost:3000 🧠 关键功能 ✨ 模式1:通过UI手动
您可以点击主页图标:
➕ Add Doctor
➕ Add Patient
📅 Book Appointment
📋 View Doctors
📋 View Appointments这些UI功能直接使用API端点(/API/execute、/API/book等) 🔍 模式2:智能助理(启用LLM)
从“询问助手”聊天界面:
Type: Show all appointments
Or: Book appointment for patient John with doctor 2 at 10:00✅ 如果启用了MCP工具(顶部的复选框),LLM将:
🔎 Understand user command
🔧 Choose correct tool from tools.json
🧠 Generate SQL
🔁 Automatically execute API calls behind the scenes❌ 如果禁用,LLM只会给出简单的答案(没有系统更改)。 🔐 认证
Only authenticated users can access core pages.
Register page stores hashed credentials securely in PostgreSQL.
Session stored using express-session.📝 LLM提示示例
显示医生桌上的所有医生 显示11:00后的约会 为John(30岁)预约09:00与Renu医生会面
✅ 总结 功能手册UI LLM工具 添加医生✅ 是✅ 通过提示 预订预约✅ 是✅ 如果插槽可用 查看医生/预约✅ 是✅ 通过提示 编辑插槽✅ 是(通过查询)✅ 通过提示 安全🔐 会话登录🔐 会话受保护
