Skip to content

MedGuide AI is an intelligent medical assistant that helps everyday people understand their health information through AI-powered document analysis and conversation.

Notifications You must be signed in to change notification settings

gauravfs-14/medguide-ai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

20 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿง  MedGuide AI โ€” A Private AI Agent for Understanding Health Reports and Medications

Python 3.11+ Streamlit LangChain Model Context Protocol

๐Ÿฉบ What it Does

MedGuide AI is an intelligent medical assistant that helps everyday people understand their health information through AI-powered document analysis and conversation. It provides:

  • Lab test interpretation - Understand blood work, thyroid panels, and other diagnostic results
  • Medication guidance - Learn about prescriptions, dosages, and side effects
  • Medical document analysis - Parse reports, visit summaries, and clinical notes
  • Health education - Get explanations for medical terminology and concepts

All processing happens locally with privacy-first design and offline capabilities.


โš ๏ธ Problem it Solves

Healthcare information is often confusing and inaccessible:

  • Lab results like "TSH = 4.9 mIU/L" leave patients confused
  • Medication instructions like "Losartan 50mg BID" aren't clear to non-medical people
  • Clinical documents are filled with jargon that's hard to understand
  • Online searches lead to information overload and misinterpretation

MedGuide AI bridges this gap by providing personalized, contextual explanations in plain language.


๐Ÿ—๏ธ Architecture Overview

MedGuide AI uses a modern Model Context Protocol (MCP) architecture for modular, extensible AI capabilities:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Streamlit     โ”‚โ—„โ”€โ”€โ–บโ”‚   LangGraph      โ”‚โ—„โ”€โ”€โ–บโ”‚  MCP Servers    โ”‚
โ”‚   Frontend      โ”‚    โ”‚   Agent          โ”‚    โ”‚                 โ”‚
โ”‚                 โ”‚    โ”‚                  โ”‚    โ”‚ โ€ข Memory        โ”‚
โ”‚ โ€ข Chat UI       โ”‚    โ”‚ โ€ข Tool Calling   โ”‚    โ”‚ โ€ข Vector Store  โ”‚
โ”‚ โ€ข File Upload   โ”‚    โ”‚ โ€ข Reasoning      โ”‚    โ”‚ โ€ข PDF Parser    โ”‚
โ”‚ โ€ข Document      โ”‚    โ”‚ โ€ข Context Mgmt   โ”‚    โ”‚ โ€ข Embeddings    โ”‚
โ”‚   Visualization โ”‚    โ”‚                  โ”‚    โ”‚                 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Core Components

Component Technology Purpose
Frontend Streamlit Interactive chat interface with file upload
AI Agent LangGraph + Google Gemini Orchestrates reasoning and tool usage
Memory System MCP Memory Server Persistent conversation and document history
Vector Database ChromaDB via MCP Document embedding and semantic search
PDF Processing PyMuPDF + Custom MCP Server Extract and vectorize medical documents
Embeddings Ollama (nomic-embed-text) Local text embeddings for RAG

๐Ÿš€ Key Features

Intelligent Document Processing

  • Automatic PDF analysis - Upload documents and get instant insights
  • Smart vectorization - Documents are automatically embedded and stored
  • Memory integration - Past documents are remembered across sessions
  • Multi-format support - PDF, images, text files, and Word documents

Conversational AI

  • Context-aware responses - References your previous documents and medical history
  • Reasoning transparency - See the AI's thought process with expandable reasoning blocks
  • Tool integration - Seamlessly uses multiple AI tools for comprehensive analysis
  • Streaming responses - Real-time response generation for better UX

Privacy & Security

  • Local processing - All document analysis happens on your machine
  • No data sharing - Your medical information never leaves your environment
  • Offline capable - Works without internet once models are downloaded
  • Encrypted storage - ChromaDB provides secure document storage

๐Ÿ’ก How It Works

  1. Document Upload ๐Ÿ“„

    • Upload lab reports, prescriptions, or medical documents
    • AI automatically extracts filename and creates document collections
    • PDF content is vectorized and stored in ChromaDB
  2. Intelligent Analysis ๐Ÿง 

    • LangGraph agent coordinates multiple MCP tools
    • Memory system recalls relevant past medical information
    • Vector search finds related document sections
  3. Expert Explanations ๐Ÿ’ฌ

    • Gemini 2.0 Flash provides medical explanations in plain language
    • Responses reference specific document content and medical history
    • Suggestions for follow-up questions and next steps
  4. Persistent Memory ๐Ÿ’พ

    • All interactions and documents are remembered
    • Cross-session context maintains continuity
    • Build comprehensive medical history over time

๐Ÿ› ๏ธ Technology Stack

AI & ML

Document Processing

Framework & Infrastructure


๐Ÿ“‹ Prerequisites

Required Software

  • Python 3.11+ - Core runtime
  • Node.js 22+ - For MCP memory server
  • Ollama - Local embedding model hosting
  • UV - Python package manager

Required Models

# Install Ollama embedding model
ollama pull nomic-embed-text:latest

Environment Variables

# Google Gemini API (required)
GOOGLE_API_KEY=your_google_api_key_here

# Optional customization
CHROMA_DB_PATH=./data  # ChromaDB storage location
MEMORY_FILE_PATH=./memory.json  # Memory persistence file

๐Ÿš€ Quick Start

1. Clone and Setup

git clone https://github.com/gauravfs-14/medguide-ai.git
cd medguide-ai

# Install dependencies with UV
uv sync

2. Configure Environment

# Copy environment template
cp .env.example .env

# Add your Google API key
echo "GOOGLE_API_KEY=your_api_key_here" >> .env

3. Install Ollama Model

# Install embedding model
ollama pull nomic-embed-text:latest

4. Run the Application

# Start the Streamlit app
uv run streamlit run mcp-client/client.py

Visit http://localhost:8501 to access the application.


๐Ÿณ Docker Deployment

Build and Run

# Build Docker image
docker build -t medguide-ai .

# Run container
docker run -p 8501:8501 \
  -e GOOGLE_API_KEY=your_api_key \
  -v $(pwd)/data:/medguide-ai/data \
  medguide-ai

Docker Compose (Recommended)

version: '3.8'
services:
  medguide-ai:
    build: .
    ports:
      - "8501:8501"
    environment:
      - GOOGLE_API_KEY=${GOOGLE_API_KEY}
    volumes:
      - ./data:/medguide-ai/data
      - ./memory.json:/medguide-ai/memory.json

๐Ÿ“š Usage Examples

Lab Report Analysis

User: "Can you analyze my recent blood work?"
[Upload: blood_test_results.pdf]

AI: "I've analyzed your blood test results. Here are the key findings:

๐Ÿ”ฌ **Complete Blood Count (CBC)**
- White Blood Cells: 6.2 K/ฮผL (Normal: 4.0-10.0)
- Red Blood Cells: 4.8 M/ฮผL (Normal: 4.2-5.4) 
- Hemoglobin: 14.2 g/dL (Normal: 12.0-15.5)

โœ… **Overall Assessment**: Your blood counts are within normal ranges, indicating good general health..."

Medication Questions

User: "What does 'Metformin 500mg BID' mean?"

AI: "**Metformin 500mg BID** means:

๐Ÿ’Š **Medication**: Metformin - a diabetes medication that helps control blood sugar
๐Ÿ“ **Dosage**: 500 milligrams per dose  
โฐ **Frequency**: BID = 'bis in die' (twice daily)

**How to take**: Take one 500mg tablet twice per day, typically with meals to reduce stomach upset..."

๐Ÿ”ง Configuration

MCP Server Configuration

The application uses mcp-client/mcp_config.json to configure AI tools:

{
  "mcpServers": {
    "memory": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-memory"],
      "transport": "stdio",
      "env": {
        "MEMORY_FILE_PATH": "memory.json"
      }
    },
    "vectorize_mcp": {
      "command": "uv",
      "args": ["--directory", "./mcp-servers", "run", "vectorize_mcp.py"],
      "transport": "stdio"
    }
  }
}

Custom MCP Servers

Add your own MCP servers by:

  1. Creating a new server in mcp-servers/
  2. Adding configuration to mcp_config.json
  3. Implementing tools using FastMCP or similar

๐Ÿค Contributing

We welcome contributions! Here's how to get started:

Development Setup

# Clone repository
git clone https://github.com/gauravfs-14/medguide-ai.git
cd medguide-ai

# Install development dependencies  
uv sync --dev

# Install pre-commit hooks
pre-commit install

Project Structure

medguide-ai/
โ”œโ”€โ”€ mcp-client/           # Streamlit frontend and agent
โ”‚   โ”œโ”€โ”€ client.py         # Main Streamlit application
โ”‚   โ”œโ”€โ”€ graph.py          # LangGraph agent definition
โ”‚   โ””โ”€โ”€ mcp_config.json   # MCP server configuration
โ”œโ”€โ”€ mcp-servers/          # Custom MCP tool servers
โ”‚   โ””โ”€โ”€ vectorize_mcp.py  # PDF vectorization server
โ”œโ”€โ”€ data/                 # ChromaDB and document storage
โ”œโ”€โ”€ Dockerfile            # Container configuration
โ”œโ”€โ”€ pyproject.toml        # Python dependencies
โ””โ”€โ”€ README.md             # This file

Adding New Features

  1. New MCP Tools - Add servers in mcp-servers/
  2. UI Improvements - Modify mcp-client/client.py
  3. Agent Logic - Update mcp-client/graph.py
  4. Documentation - Update README and docstrings

๐Ÿ”ฎ Roadmap

Current Features โœ…

  • PDF document processing and vectorization
  • Intelligent chat interface with memory
  • MCP-based modular architecture
  • Local embedding and vector storage
  • Docker containerization

Upcoming Features ๐Ÿšง

  • OCR Support - Process scanned documents and images
  • Drug Database Integration - Comprehensive medication information
  • Calendar Integration - Medication reminders and appointments
  • Multi-language Support - Support for non-English medical documents
  • Advanced Visualizations - Charts and graphs for lab trends
  • Mobile App - React Native or Flutter mobile interface

Future Enhancements ๐ŸŽฏ

  • FHIR Integration - Connect with electronic health records
  • Clinical Decision Support - AI-powered health recommendations
  • Telemedicine Integration - Connect with healthcare providers
  • Wearable Data - Integration with fitness trackers and health devices

โš ๏ธ Important Medical Disclaimer

MedGuide AI provides educational information only and is not a substitute for professional medical advice, diagnosis, or treatment. Always consult your healthcare provider for medical decisions. In case of medical emergencies, contact emergency services immediately.


๐Ÿ“„ License

This project is licensed under the MIT License. See LICENSE for details.


๐Ÿ™‹โ€โ™‚๏ธ Support


๐ŸŒŸ Acknowledgments


Made with โค๏ธ for better healthcare accessibility

โญ Star this repo | ๐Ÿ› Report Bug | ๐Ÿ’ก Request Feature

About

MedGuide AI is an intelligent medical assistant that helps everyday people understand their health information through AI-powered document analysis and conversation.

Resources

Stars

Watchers

Forks

Contributors 2

  •  
  •