Medical GraphRAG Assistant

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.

Category
Visit Server

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)

  1. search_fhir_documents - Full-text search of clinical notes
  2. get_entity - Retrieve specific medical entities by ID
  3. search_entities_by_type - Find entities by type (Condition, Medication, etc.)
  4. get_entity_relationships - Get all relationships for an entity
  5. search_relationships_by_type - Find relationships by type (treats, causes, etc.)
  6. 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 config
  • config/fhir_graphrag_config.aws.yaml - AWS deployment config
  • config/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 client
  • boto3 - AWS SDK
  • streamlit - Chat UI
  • mcp - 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

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

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.

Official
Featured
TypeScript
Audiense Insights MCP Server

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.

Official
Featured
Local
TypeScript
Magic Component Platform (MCP)

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.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
Kagi MCP Server

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.

Official
Featured
Python
graphlit-mcp-server

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.

Official
Featured
TypeScript
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Exa Search

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.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured