AI Doctor Assistant MCP Server
by pashaarshad
README.md
# ๐ฉบ MCP-Based AI Doctor Assistant
> **Your Virtual Medical Advisor powered by Model Context Protocol (MCP)**
[](https://python.org)
[](https://modelcontextprotocol.io)
[](LICENSE)
---
## โ ๏ธ 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
1. **Clone the repository**
```bash
git clone <repository-url>
cd "MCP-Based AI Doctor Assistant"
```
2. **Create virtual environment**
```bash
python -m venv venv
# Windows
.\venv\Scripts\activate
# Mac/Linux
source venv/bin/activate
```
3. **Install dependencies**
```bash
pip install -r requirements.txt
```
4. **Configure environment variables**
```bash
# 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
```
5. **Run the server**
```bash
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:
```json
{
"mcpServers": {
"ai-doctor": {
"command": "python",
"args": ["-m", "src.server"],
"cwd": "/path/to/MCP-Based AI Doctor Assistant"
}
}
}
```
---
## ๐ Usage Examples
### Checking Symptoms
```python
# Using the MCP tool
{
"tool": "check_symptoms",
"arguments": {
"symptoms": ["headache", "fever", "fatigue"],
"age": 35,
"gender": "male",
"duration": "2 days"
}
}
```
### Explaining Lab Reports
```python
{
"tool": "explain_lab_report",
"arguments": {
"tests": {
"hemoglobin": 12.5,
"wbc": 7500,
"fasting_glucose": 110
},
"gender": "female"
}
}
```
### Getting Health Advice
```python
{
"tool": "health_advice",
"arguments": {
"topic": "sleep"
}
}
```
### Emergency Detection
```python
{
"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
1. Create account at [render.com](https://render.com)
2. New Web Service โ Connect GitHub
3. Add environment variables
4. Deploy (Free tier: 750 hours/month)
### Option 2: Railway.app
1. Create account at [railway.app](https://railway.app)
2. New Project โ Deploy from GitHub
3. Add environment variables
4. Deploy (Free tier: $5 credit/month)
---
## ๐งช Testing
```bash
# 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](https://www.iasp.info/resources/Crisis_Centres/) |
---
## ๐ค Contributing
Contributions are welcome! Please:
1. Fork the repository
2. Create a feature branch
3. Make your changes
4. 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](LICENSE) file for details.
---
## ๐ Acknowledgments
- Built using [Model Context Protocol (MCP)](https://modelcontextprotocol.io)
- 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*
This server cannot be deployed
Maintenance
ActivityInactive
ResponsivenessNo issues