Fastmcp Health Rbac Secure
FastMCP server + Gemini 2.0 Flash LangChain client for RBAC-protected patient data tools backed by SQLite + JWT.
Ask AI about Fastmcp Health Rbac Secure
Powered by Claude Β· Grounded in docs
I know everything about Fastmcp Health Rbac Secure. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
Patient Data Access MCP
FastMCP server + Gemini 2.0 Flash LangChain client showcasing RBAC-protected patient data tools backed by SQLite + JWT.
Prerequisites
- Python 3.11+
- GOOGLE_API_KEY for Gemini 2.0 Flash (already referenced inside
.env)
Install dependencies:
pip install -r requirements.txt
Environment Variables
.env ships with sample values:
JWT_SECRET β symmetric key used to validate tokens.
DB_URL β path to the SQLite file (sqlite:///app.db by default).
MCP_SERVER_SSE_URL β SSE endpoint exposed by FastMCP (http://127.0.0.1:8000/sse).
GOOGLE_API_KEY β Gemini credential (replace with a valid key).
JWT_* β pre-generated tokens scoped to Doctor, Nurse, LabTechnician, and Admin roles.
Update secrets before using in a real setting.
Running the MCP Server
python server.py --transport sse --host 127.0.0.1 --port 8000
- The first launch creates/ seeds
app.dbwith staff, patients, vitals, labs, etc. - Other transports are available (
stdio,http,streamable-http). Pass--transport stdioto embed inside another process. - Use
python server.py --issue-token Doctor --token-email someone@hospital.testto mint new JWTs.
LangChain + Gemini Client
The client connects to the MCP server through the LangChain MCP Adapter and lets Gemini pick the correct MCP tool per request.
python langchain_client.py --role doctor --query "Order a lipid panel for patient 2"
Flags:
--roleβ one ofdoctor|nurse|labtechnician|adminstaff(selects the JWT token).--queryβ natural-language instruction for Gemini.--server-urlβ override the SSE endpoint if the server runs elsewhere.
RBAC Map β Tools
| Role | Tools |
|---|---|
| Doctor | ViewPatientHistory, UpdateDiagnosis, OrderLabTest |
| Nurse | ViewPatientHistory, UpdateVitals, RecordNurseNotes |
| LabTechnician | ViewLabOrders, EnterLabResults |
| AdminStaff | ScheduleAppointment, BillingInfoView |
Every write tool automatically records an audit entry in the audit_log table (who, what, when, payload).
