Medical GraphRAG Assistant
Enables AI-powered medical information retrieval through FHIR clinical document search and GraphRAG-based exploration of medical entities and relationships. Combines vector search with knowledge graph queries for comprehensive healthcare data analysis.
README
Medical GraphRAG Assistant
A production-ready medical AI assistant platform built on Model Context Protocol (MCP), featuring GraphRAG multi-modal search, FHIR integration, and AWS Bedrock Claude Sonnet 4.5.
Originally forked from: FHIR-AI-Hackathon-Kit
What This Is
This is an agentic medical chat platform that uses:
- š¤ Model Context Protocol (MCP) - Claude autonomously calls medical search tools
- š§ GraphRAG - Knowledge graph-based retrieval with entity and relationship extraction
- š„ FHIR Integration - Full-text search of clinical documents
- āļø AWS Bedrock - Claude Sonnet 4.5 with multi-iteration tool use
- š Interactive UI - Streamlit interface with execution transparency
- šļø InterSystems IRIS - Vector database with GraphRAG tables
Quick Start
1. Run the Streamlit Chat Interface
# Install dependencies
pip install -r requirements.txt
# Set AWS credentials
export AWS_PROFILE=your-profile
# Run the chat app
cd mcp-server
streamlit run streamlit_app.py
Visit http://localhost:8501 and start chatting!
2. Use as MCP Server (Claude Desktop, etc.)
# Configure MCP client to point to:
python mcp-server/fhir_graphrag_mcp_server.py
Architecture
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā Streamlit Chat UI ā
ā - Conversation history ā
ā - Chart visualization ā
ā - Execution log display ā
āāāāāāāāāāāāāāāā¬āāāāāāāāāāāāāāāāāāāāāāā
ā AWS Bedrock Converse API
āāāāāāāāāāāāāāāā¼āāāāāāāāāāāāāāāāāāāāāāā
ā Claude Sonnet 4.5 ā
ā - Agentic tool calling ā
ā - Multi-iteration reasoning ā
āāāāāāāāāāāāāāāā¬āāāāāāāāāāāāāāāāāāāāāāā
ā MCP Protocol (stdio)
āāāāāāāāāāāāāāāā¼āāāāāāāāāāāāāāāāāāāāāāā
ā FHIR + GraphRAG MCP Server ā
ā - 6 medical search tools ā
ā - FHIR document search ā
ā - GraphRAG entity/relationship ā
ā - Hybrid search ā
āāāāāāāāāāāāāāāā¬āāāāāāāāāāāāāāāāāāāāāāā
ā IRIS Native API (TCP)
āāāāāāāāāāāāāāāā¼āāāāāāāāāāāāāāāāāāāāāāā
ā AWS IRIS Database ā
ā - FHIR documents (migrated) ā
ā - GraphRAG entities (83) ā
ā - Relationships (540) ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
Features
MCP Tools (6 total)
- search_fhir_documents - Full-text search of clinical notes
- get_entity - Retrieve specific medical entities by ID
- search_entities_by_type - Find entities by type (Condition, Medication, etc.)
- get_entity_relationships - Get all relationships for an entity
- search_relationships_by_type - Find relationships by type (treats, causes, etc.)
- hybrid_search - Combined vector + graph search with relevance ranking
Chat Interface Features
- ā Execution Transparency - See which tools Claude calls and its reasoning
- ā Interactive Charts - Generate visualizations from data
- ā Conversation History - Multi-turn conversations with context
- ā Error Handling - Graceful handling of API issues with detailed logs
- ā Max Iterations Control - Prevents infinite loops (10 iteration limit)
- ā Type-Safe Content Processing - Robust handling of mixed content formats
Current Version: v2.10.2
Recent Improvements:
- Fixed "'str' object has no attribute 'get'" error with proper type checking
- Increased max iterations from 5 ā 10 for complex queries
- Added execution details with expandable UI
- Improved error messages with context
Configuration
Required Environment Variables
# AWS Credentials
export AWS_PROFILE=your-profile # or set AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
# IRIS Database (AWS)
export IRIS_HOST=your-iris-host
export IRIS_PORT=1972
export IRIS_NAMESPACE=USER
export IRIS_USERNAME=SQLAdmin
export IRIS_PASSWORD=your-password
Config Files
config/fhir_graphrag_config.yaml- Local development configconfig/fhir_graphrag_config.aws.yaml- AWS deployment configconfig/aws-config.yaml- AWS infrastructure settings
Project Structure
medical-graphrag-assistant/
āāā mcp-server/ # MCP server and Streamlit app
ā āāā fhir_graphrag_mcp_server.py # MCP server implementation (45KB)
ā āāā streamlit_app.py # Chat UI (39KB)
ā āāā test_*.py # Integration tests
āāā src/
ā āāā db/ # IRIS database clients
ā āāā embeddings/ # NVIDIA NIM embedding integration
ā āāā search/ # Search implementations
ā āāā vectorization/ # Document vectorization
ā āāā validation/ # Data validation
āāā config/ # Configuration files
āāā docs/ # Documentation
ā āāā architecture.md # System architecture
ā āāā deployment-guide.md # AWS deployment
ā āāā development/ # Development history
āāā scripts/ # Deployment scripts
āāā tests/ # Test suite
Technology Stack
AI/ML:
- AWS Bedrock (Claude Sonnet 4.5)
- NVIDIA NIM Embeddings (1024-dim vectors)
- Model Context Protocol (MCP)
Database:
- InterSystems IRIS (Vector DB + GraphRAG tables)
- Native VECTOR(DOUBLE, 1024) support
- COSINE similarity search
Infrastructure:
- AWS EC2 (for IRIS database)
- Python 3.10+
- Streamlit for UI
Key Libraries:
intersystems-irispython- IRIS native clientboto3- AWS SDKstreamlit- Chat UImcp- Model Context Protocol SDK
Example Queries
Try these in the chat interface:
FHIR Search:
- "Find patients with chest pain"
- "Search for diabetes cases"
- "Show recent emergency visits"
GraphRAG:
- "What medications treat hypertension?"
- "Show me the relationship between conditions and procedures"
- "What are the side effects of metformin?"
Hybrid Search:
- "Find treatment options for chronic pain" (combines vector + graph search)
Visualization:
- "Show a chart of conditions by frequency"
- "Graph the most common medications"
Development
Running Tests
# Unit tests
pytest tests/unit/
# Integration tests
pytest tests/integration/
# E2E tests
pytest tests/e2e/
Debug Mode
Enable debug logging:
import logging
logging.basicConfig(level=logging.DEBUG)
Troubleshooting
See docs/troubleshooting.md for common issues.
Common Issues:
- AWS credentials not configured ā Set AWS_PROFILE or AWS env vars
- IRIS connection failed ā Check IRIS_HOST and credentials
- Max iterations reached ā Query may be too complex, try simplifying
Documentation
- Architecture Overview - System design and data flow
- Deployment Guide - AWS deployment instructions
- MCP Server Complete - MCP implementation details
- Development History - Session notes and findings
Contributing
This project is based on the FHIR-AI-Hackathon-Kit. The original tutorial content remains in the tutorial/ directory.
License
Inherits license from upstream FHIR-AI-Hackathon-Kit repository.
Acknowledgments
- Original Project: FHIR-AI-Hackathon-Kit by gabriel-ing
- InterSystems IRIS for the vector database platform
- AWS Bedrock for Claude Sonnet 4.5 access
- Model Context Protocol by Anthropic
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
E2B
Using MCP to run code via e2b.
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Neon Database
MCP server for interacting with Neon Management API and databases