Provides secure read-only access to a PostgreSQL-based Hospital Management System through defined views, enabling queries for doctors, departments, appointments, room status, and billing summaries while protecting sensitive patient health information.
π₯ Hospital MCP Server
Secure PostgreSQL Access via Model Context Protocol (MCP)
Claude Desktop acts as the MCP client
This project implements a secure Model Context Protocol (MCP) server that connects to a PostgreSQL-based Hospital Management System.
Claude Desktop communicates with this server and can safely query hospital data through defined, read-only MCP tools.
π Project Structure
ποΈ 1. PostgreSQL Setup
You must create secure read-only views before exposing data to Claude.
Create Views (Safe, non-sensitive)
π 2. Create Restricted DB Role
Only the views are exposed β raw PHI tables are protected.
βοΈ 3. Environment Variables (.env)
Your MCP server reads DB credentials from here:
π§ 4. MCP Server (main.py)
main.py runs your MCP server and exposes tools such as:
get_doctor_by_idlist_doctors_by_departmentget_appointments_for_doctorcheck_room_statusget_patient_billing_summary
All SQL queries are:
β parameterized β read-only β safely constrained
π 5. Installing Dependencies
Inside your project folder:
Or if using pip manually:
(Dependencies are defined in pyproject.toml)
π€ 6. Connecting MCP Server to Claude Desktop
Claude Desktop automatically detects MCP servers placed in its extensions directory.
In your local file system "C:\Users\shesh\AppData\Roaming\Claude\claude_desktop_config.json" edit this file with your configurations
π Step 3 β Restart Claude Desktop
Go to:
Claude Desktop β Settings β Developer You should see:
Claude will now:
Launch your
main.pyMCP serverDiscover available tools
Call them automatically during conversation
π§ͺ 7. Testing Inside Claude
In Claude Desktop you can ask:
Claude will call:
Or:
Claude β calls your MCP tool β your DB β safe output returned.
π― Summary
You now have:
β A working Python MCP server β Secure PostgreSQL integration β Fully wired Claude Desktop tool access β Safe read-only hospital data views β Clean project structure
Claude Desktop communicates with your DB only through your safe MCP tools, never accessing raw tables directly.
This server cannot be installed