# π₯ MCP Hospital Assistant
A full-stack intelligent hospital appointment management system powered by React, Node.js, PostgreSQL, and Mistral LLM (via Ollama).
## π₯ Preview
### π₯ Demo Video
[βΆοΈ Click here to watch the demo](./MCP_DEMO.webm)
### π Dashboard

### π¬ LLM Chat Assistant

### π¬ Mannual Booking

π Node.js + Express
π¨ React.js (frontend)
π§ LLM (Ollama - Mistral)
πΎ PostgreSQL
π‘οΈ Session-based login
π· UI Preview
Login / Register Page
Dashboard with buttons to manage system manually
Book Appointment (manual)
LLM-powered auto assistant interface
π Project Structure
βββ backend/
β βββ server.js # Node.js + Express backend
β βββ config/config.js # PostgreSQL config
β βββ mcp/ # All business logic handlers
β βββ auth/ # Login, register, session routes
βββ frontend/
β βββ mcp-ui/ # React frontend
β βββ components/ # AddDoctor, Chat, Login, Home etc.
β βββ App.js # Main route controller
βοΈ Setup Instructions
1. β
Install PostgreSQL and create DB
sudo apt install postgresql postgresql-contrib
sudo -u postgres psql
Then run:
CREATE DATABASE mcp;
CREATE USER mcpuser WITH PASSWORD 'mcppass';
GRANT ALL PRIVILEGES ON DATABASE mcp TO mcpuser;
2. π¦ Create Schema
Connect:
psql -U mcpuser -d mcp -h localhost
CREATE TABLE doctors (
doctor_id SERIAL PRIMARY KEY,
name TEXT,
department TEXT,
available_slots JSONB
);
CREATE TABLE patients (
patient_id SERIAL PRIMARY KEY,
name TEXT,
age INTEGER,
contact TEXT
);
CREATE TABLE appointments (
appointment_id SERIAL PRIMARY KEY,
doctor_id INTEGER REFERENCES doctors(doctor_id),
patient_id INTEGER REFERENCES patients(patient_id),
appointment_time TEXT
);
CREATE TABLE users (
id SERIAL PRIMARY KEY,
username TEXT UNIQUE,
password TEXT
);
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO mcpuser;
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO mcpuser;
3. π§ Install Ollama with Mistral
curl -fsSL https://ollama.com/install.sh | sh
ollama run mistral
Make sure the local Ollama server is running and available on default port 11434.
4. π Backend Setup (Node.js)
cd backend/
npm install
node server.js
This starts backend on: http://localhost:3007
5. π» Frontend Setup (React)
cd frontend/mcp-ui
npm install
npm start
This starts frontend at: http://localhost:3000
π§ Key Functionalities
β¨ Mode 1: Manual via UI
You can click on homepage icons to:
β Add Doctor
β Add Patient
π
Book Appointment
π View Doctors
π View Appointments
These UI features directly use API endpoints (/api/execute, /api/book, etc.)
π Mode 2: Smart Assistant (LLM-enabled)
From the "Ask Assistant" chat interface:
Type: Show all appointments
Or: Book appointment for patient John with doctor 2 at 10:00
β
If MCP Tools is enabled (checkbox at top), the LLM will:
π Understand user command
π§ Choose correct tool from tools.json
π§ Generate SQL
π Automatically execute API calls behind the scenes
β If disabled, LLM simply gives plain answers (no system change).
π Authentication
Only authenticated users can access core pages.
Register page stores hashed credentials securely in PostgreSQL.
Session stored using express-session.
π Example Prompts for LLM
Show all the doctors in doctor table
Show appointments after 11:00
Book an appointment with Dr. Renu at 09:00 for John (age 30)
β
Summary
Feature Manual UI LLM Tools
Add Doctor β
Yes β
via prompt
Book Appointment β
Yes β
if slot available
View Doctors/Appointments β
Yes β
via prompt
Edit Slots β
Yes (via query) β
via prompt
Security π Session Login π Session Protected