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
访问服务器

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

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选