🩺 MCP-Based AI Doctor Assistant
Your Virtual Medical Advisor powered by Model Context Protocol (MCP)
  
---
⚠️ IMPORTANT DISCLAIMER
This AI assistant is NOT a replacement for professional medical advice, diagnosis, or treatment. - ❌ Cannot diagnose diseases - ❌ Cannot prescribe medications - ❌ Cannot replace a real doctor - ✅ CAN provide health information - ✅ CAN detect potential emergencies - ✅ CAN explain medical terms Always consult a qualified healthcare provider for medical decisions.
---
🌟 Features
12 Medical Tools
| Tool | Description | |------|-------------| | 🔍 check_symptoms | Analyze symptoms, assess risk level, provide self-care tips | | 🚨 detect_emergency | Detect life-threatening situations, provide immediate guidance | | 🔬 explain_lab_report | Explain blood tests, lab values in simple language | | 💪 health_advice | Exercise, sleep, stress management, lifestyle tips | | 💊 medicine_info | Medicine information (NOT prescriptions) | | 🧠 mental_health_support | Anxiety, stress, depression resources, crisis helplines | | 🥗 diet_nutrition | Diet plans for diabetes, heart health, weight loss | | 🆘 first_aid_guide | Step-by-step first aid for emergencies | | 🤰 pregnancy_guide | Trimester-specific pregnancy information | | 👶 child_health | Vaccination schedules, pediatric guidance | | 🏥 chronic_disease_info | Diabetes, hypertension, heart disease management | | 📍 find_hospital | Help finding nearby healthcare facilities |
Safety Features
- ✅ Emergency Detection: Automatically detects life-threatening symptoms
- ✅ Medical Disclaimers: Every response includes appropriate warnings
- ✅ No Prescriptions: Never recommends specific medications or dosages
- ✅ Doctor Referral: Always encourages professional consultation
- ✅ Audit Logging: All interactions can be logged for review
---
🚀 Quick Start
Prerequisites
- Python 3.11 or higher
- pip (Python package manager)
Installation
- Clone the repository
git clone <repository-url>
cd "MCP-Based AI Doctor Assistant"
- Create virtual environment
python -m venv venv
# Windows
.\venv\Scripts\activate
# Mac/Linux
source venv/bin/activate
- Install dependencies
pip install -r requirements.txt
- Configure environment variables
# Copy example env file
cp .env.example .env
# Edit .env and add your Gemini API key (optional, for enhanced AI responses)
# Get free key at: https://makersuite.google.com/app/apikey
- Run the server
python -m src.server
---
🔧 Configuration
Environment Variables
| Variable | Description | Required | |----------|-------------|----------| | GEMINI_API_KEY | Google Gemini API key for AI responses | Optional | | SERVER_HOST | Server host (default: 0.0.0.0) | No | | SERVER_PORT | Server port (default: 8000) | No | | DEBUG_MODE | Enable debug mode (default: true) | No | | LOG_LEVEL | Logging level (default: INFO) | No |
MCP Configuration
The server can be configured in Claude Desktop or other MCP clients:
{
"mcpServers": {
"ai-doctor": {
"command": "python",
"args": ["-m", "src.server"],
"cwd": "/path/to/MCP-Based AI Doctor Assistant"
}
}
}
---
📖 Usage Examples
Checking Symptoms
# Using the MCP tool
{
"tool": "check_symptoms",
"arguments": {
"symptoms": ["headache", "fever", "fatigue"],
"age": 35,
"gender": "male",
"duration": "2 days"
}
}
Explaining Lab Reports
{
"tool": "explain_lab_report",
"arguments": {
"tests": {
"hemoglobin": 12.5,
"wbc": 7500,
"fasting_glucose": 110
},
"gender": "female"
}
}
Getting Health Advice
{
"tool": "health_advice",
"arguments": {
"topic": "sleep"
}
}
Emergency Detection
{
"tool": "detect_emergency",
"arguments": {
"symptoms": ["chest pain", "shortness of breath"],
"context": "Started suddenly while walking"
}
}
---
🏗️ Project Structure
MCP-Based AI Doctor Assistant/
├── src/
│ ├── __init__.py
│ ├── server.py # Main MCP server
│ ├── config.py # Configuration
│ │
│ ├── core/
│ │ ├── safety_engine.py # Emergency detection, disclaimers
│ │ ├── llm_client.py # Gemini API client
│ │ └── memory.py # Conversation memory
│ │
│ └── tools/
│ ├── symptom_checker.py
│ ├── emergency_detector.py
│ ├── lab_report.py
│ ├── health_advisor.py
│ ├── medicine_info.py
│ ├── mental_health.py
│ ├── diet_nutrition.py
│ ├── first_aid.py
│ ├── pregnancy.py
│ ├── child_health.py
│ ├── chronic_disease.py
│ └── hospital_finder.py
│
├── requirements.txt
├── mcp_config.json
├── .env.example
└── README.md
---
🔒 Safety & Compliance
Emergency Detection
The system automatically detects critical symptoms like:
- Chest pain / Heart attack signs
- Difficulty breathing
- Signs of stroke (FAST)
- Severe bleeding
- Loss of consciousness
- Suicidal thoughts
- Poisoning
When detected: AI reasoning stops immediately, emergency instructions are provided.
Medical Disclaimers
Every response includes:
- Clear statement that this is not medical advice
- Recommendation to consult healthcare providers
- Emergency contact numbers when appropriate
What This System Does NOT Do
- ❌ Diagnose diseases
- ❌ Prescribe medications
- ❌ Recommend specific dosages
- ❌ Replace professional medical judgment
- ❌ Store personal health information persistently
---
🌐 Free Deployment Options
Option 1: Render.com
- Create account at render.com
- New Web Service → Connect GitHub
- Add environment variables
- Deploy (Free tier: 750 hours/month)
Option 2: Railway.app
- Create account at railway.app
- New Project → Deploy from GitHub
- Add environment variables
- Deploy (Free tier: $5 credit/month)
---
🧪 Testing
# Run tests
pytest tests/ -v
# Run with coverage
pytest tests/ --cov=src --cov-report=html
---
📞 Emergency Contact Numbers
| Country | Service | Number | |---------|---------|--------| | 🇮🇳 India | National Emergency | 112 | | 🇮🇳 India | Ambulance | 108 | | 🇺🇸 USA | Emergency | 911 | | 🇬🇧 UK | Emergency | 999 | | 🇪🇺 EU | Emergency | 112 | | 🌍 International | Varies | IASP Directory |
---
🤝 Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
Guidelines
- Always maintain safety features
- Add appropriate disclaimers
- Test emergency detection
- Document new features
---
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
---
🙏 Acknowledgments
- Built using Model Context Protocol (MCP)
- Medical information sourced from WHO, CDC, NIH public guidelines
- Emergency protocols based on standard first aid guidelines
---
⚠️ Final Reminder
This AI assistant provides INFORMATION, not MEDICAL ADVICE. For any health concerns: 1. 🏥 Consult a qualified healthcare provider 2. 📞 Call emergency services for urgent situations 3. 🚑 Visit the nearest hospital for serious symptoms Your health matters. Trust professionals, not AI.
---
Made with ❤️ for better health awareness











