hospital-ai-secure-assistant

hospital-ai-secure-assistant

Role-based AI assistant for hospital workflows, patient FAQ, staff tools, and secure document approvals with MCP-style tool access.

Category
访问服务器

README

Hospital AI System

A simulated enterprise healthcare backend and UI for testing role-based AI assistants, hospital workflows, secure document approvals, prompt-injection defenses, and MCP-style tool access.

The project includes:

  • FastAPI backend
  • SQLite demo database
  • Role-based JWT authentication
  • Patient, staff, and management chat surfaces
  • Public patient FAQ mode before login
  • Secure Document Vault for approved confidential supervisor documents
  • MCP-style tool listing and invocation endpoints
  • Mock AI mode for local demos without external AI keys

1. Quick Setup

Run this from the project root on Windows PowerShell:

.\setup.ps1

The script will:

  • create .venv if it does not exist
  • install Python dependencies
  • create .env if missing
  • generate hospital.db if missing
  • create secure_vault/ if missing

To recreate demo data from scratch:

.\setup.ps1 -ResetDb

To setup and start the server immediately:

.\setup.ps1 -StartServer

If PowerShell blocks script execution, run:

Set-ExecutionPolicy -Scope CurrentUser RemoteSigned

Then rerun:

.\setup.ps1

2. Manual Setup

If you do not want to use the setup script:

python -m venv .venv
.\.venv\Scripts\activate
python -m pip install --upgrade pip
pip install -r requirements.txt
python generate_hospital_data.py

Create .env:

HOSPITAL_AI_PROVIDER=mock
JWT_SECRET=hospital-dev-secret
REPORT_GENERATION_DELAY_SECONDS=0

3. Run Locally

Start the app:

.\.venv\Scripts\python.exe -m uvicorn app:app --host 127.0.0.1 --port 8000

Open:

  • Main dashboard: http://127.0.0.1:8000/
  • Patient chat: http://127.0.0.1:8000/patient
  • Staff chat: http://127.0.0.1:8000/staff
  • Management chat: http://127.0.0.1:8000/management
  • Secure Document Vault: http://127.0.0.1:8000/vault
  • Swagger API docs: http://127.0.0.1:8000/docs
  • Health/status: http://127.0.0.1:8000/api/status

4. Run With Ngrok

Install ngrok, then start your local server first:

.\.venv\Scripts\python.exe -m uvicorn app:app --host 127.0.0.1 --port 8000

In another terminal:

ngrok http 8000

Ngrok will print a public URL like:

https://example-name.ngrok-free.dev

Share these with testers:

  • https://example-name.ngrok-free.dev/patient
  • https://example-name.ngrok-free.dev/staff
  • https://example-name.ngrok-free.dev/management
  • https://example-name.ngrok-free.dev/vault
  • https://example-name.ngrok-free.dev/docs

If you use a fixed ngrok domain, point it to the same local port your FastAPI app is running on.

To inspect active ngrok tunnels locally:

Invoke-RestMethod http://127.0.0.1:4040/api/tunnels

5. Demo Accounts

Username Password Role
admin Admin@123 SUPER_ADMIN
supervisor1 Supervisor@123 HOSPITAL_SUPERVISOR
doctor1 Doctor@123 DOCTOR
doctor2 Doctor@123 DOCTOR
doctor3 Doctor@123 DOCTOR
nurse1 Nurse@123 NURSE
labtech1 LabTech@123 LAB_TECH
receptionist1 Reception@123 RECEPTIONIST
billing1 Billing@123 BILLING_INSURANCE
patient1 Patient@123 PATIENT
patient2 Patient@123 PATIENT

6. Chat Surfaces

Patient Chat

URL:

/patient

API:

POST /chat/patient

Behavior:

  • Without login: public hospital FAQ mode
  • With PATIENT login: private patient mode

Public mode can answer general questions about:

  • services
  • appointment process
  • lab services
  • billing support
  • emergency guidance
  • medical-record request process

Public mode cannot reveal:

  • patient profile
  • medical records
  • lab reports
  • billing records
  • prescriptions
  • insurance claims
  • appointment status

Staff Chat

URL:

/staff

API:

POST /chat/staff

Requires one of:

  • DOCTOR
  • NURSE
  • LAB_TECH
  • RECEPTIONIST
  • BILLING_INSURANCE

Each staff role only sees tools allowed for that role.

Management Chat

URL:

/management

API:

POST /chat/management

Requires:

  • SUPER_ADMIN
  • HOSPITAL_SUPERVISOR

Management role split:

  • Supervisor creates secure document requests and checks own request status.
  • Admin approves/rejects document requests and views pending queue.
  • Admin does not create supervisor document requests.
  • Supervisor does not approve requests.

7. Secure Document Vault

URL:

/vault

APIs:

GET /vault/docs
GET /vault/docs/{request_id}

Allowed roles:

  • SUPER_ADMIN
  • HOSPITAL_SUPERVISOR

Denied roles:

  • PATIENT
  • DOCTOR
  • NURSE
  • LAB_TECH
  • RECEPTIONIST
  • BILLING_INSURANCE

Vault behavior:

  • Supervisor creates confidential document requests from management chat.
  • The generated document content is stored in secure_vault/.
  • Chat never displays confidential document content.
  • Request stays PENDING_ADMIN_APPROVAL.
  • Admin approves/rejects.
  • After approval, supervisor signs into /vault again to view their own approved docs.
  • Admin signs into /vault to view all approved docs.

8. API Endpoints

Method Endpoint Auth Description
GET / No Main UI
GET /patient No Patient UI
GET /staff No page auth, chat requires JWT Staff UI
GET /management No page auth, chat requires JWT Management UI
GET /vault No page auth, vault APIs require JWT Secure Document Vault UI
GET /docs No Swagger/OpenAPI docs
GET /api/status No Service status
POST /auth/login No Login and receive JWT
POST /chat/patient Optional Public patient FAQ or signed-in patient chat
POST /chat/staff Yes Staff chat
POST /chat/management Yes Management chat
GET /mcp/health No MCP health
GET /mcp/tools Yes List tools available to signed-in role
POST /mcp/invoke Yes Invoke a tool directly
GET /mcp/sse Yes/token query MCP SSE stream
POST /mcp/sse/message Yes/token query MCP SSE message endpoint
GET /vault/docs Yes List approved vault docs
GET /vault/docs/{request_id} Yes Read approved vault doc

9. Database

Main SQLite database:

hospital.db

Generated by:

python generate_hospital_data.py

Important tables include:

  • users
  • hospital_staff
  • doctors
  • patients
  • appointments
  • medical_records
  • prescriptions
  • lab_reports
  • billing
  • insurance
  • hospital_documents
  • audit_logs
  • management_report_requests

management_report_requests stores metadata for secure document requests. The confidential document body is stored in secure_vault/.

10. Security Model

  • JWT authentication
  • Role-based access control
  • Patient self-access isolation
  • Staff tools limited by role
  • Supervisor creates confidential document requests
  • Admin approves/rejects confidential document requests
  • Vault requires separate sign-in
  • Vault content is not served from /static
  • Chat does not display confidential vault document bodies
  • Prompt filtering blocks obvious prompt-injection attempts
  • Audit logs record tool execution attempts

11. Recommended Demo Flow

  1. Open /patient.

  2. Ask public question without login:

    What services does the hospital provide?
    
  3. Sign in as patient1.

  4. Ask:

    Show my lab reports
    
  5. Open /management.

  6. Sign in as supervisor1.

  7. Ask:

    Create lab reports document for patient 1
    
  8. Sign out/refresh or login as admin.

  9. Ask:

    Show pending document requests
    Approve document request 1
    
  10. Open /vault.

  11. Sign in as supervisor1 to see own approved docs.

  12. Sign in as admin to see all approved docs.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选