FHIR MCP Server
A comprehensive MCP server that bridges AI applications with FHIR healthcare data systems, enabling patient data access, clinical data retrieval, and data quality assessment.
README
FHIR MCP Server
A comprehensive Model Context Protocol (MCP) server that provides FHIR (Fast Healthcare Interoperability Resources) functionality with advanced data quality assessment and error handling capabilities.
🎯 Overview
This MCP server bridges the gap between AI applications and FHIR healthcare data systems, providing robust tools for accessing patient information, clinical data, and assessing data quality across different FHIR servers. Perfect for healthcare AI development, clinical research, and testing FHIR implementations.
✨ Key Features
🏥 Comprehensive FHIR Resource Access
- Patient Management: Search, retrieve, and analyze patient demographics
- Clinical Data: Access observations, conditions, medications, diagnostic reports
- Care Coordination: Retrieve care plans and treatment information
- Server Capabilities: Query FHIR server metadata and supported features
🔍 Advanced Data Quality Assessment
- Quality Scoring: 0-100 data quality scores for FHIR servers
- Integrity Checks: Detect orphaned references and disconnected data
- Validation: Comprehensive FHIR response validation
- Issue Detection: Identify data consistency problems automatically
🛡️ Enhanced Error Handling
- HTTP Status Handling: Proper 404, 401, 403, timeout responses
- FHIR OperationOutcome: Standards-compliant error reporting
- Detailed Logging: Request/response debugging information
- Graceful Degradation: Continues operation despite server issues
🧰 Developer-Friendly Tools
- Async Architecture: High-performance async/await implementation
- Pagination Support: Handle large datasets efficiently
- Flexible Configuration: Environment-based server configuration
- MCP Integration: Seamless Claude Desktop integration
🚀 Quick Start
Prerequisites
- Python 3.11 or newer
- Claude Desktop (for MCP integration)
Installation
-
Clone the repository
git clone https://github.com/jcafazzo/fhir-mcp.git cd fhir-mcp -
Install dependencies
pip install -r requirements.txt -
Configure Claude Desktop
Add to your
claude_desktop_config.json:{ "mcpServers": { "fhir-server": { "command": "python3", "args": ["/path/to/fhir-mcp/fhir_mcp_server.py"], "env": { "FHIR_BASE_URL": "https://r4.smarthealthit.org" } } } } -
Restart Claude Desktop
🔧 Configuration
Environment Variables
| Variable | Description | Default |
|---|---|---|
FHIR_BASE_URL |
FHIR server endpoint | https://hapi.fhir.org/baseR4 |
FHIR_AUTH_TOKEN |
Bearer token for authentication | None |
Recommended FHIR Servers
| Server | URL | Quality | Use Case |
|---|---|---|---|
| SMART Health IT | https://r4.smarthealthit.org |
⭐⭐⭐⭐⭐ | Production testing |
| Firely Server | https://server.fire.ly |
⭐⭐⭐⭐ | Development |
| HAPI Test | https://hapi.fhir.org/baseR4 |
⭐⭐ | Basic testing |
🛠️ Available Tools
Core Patient Tools
get_patient- Retrieve specific patient by IDsearch_patients- Search patients by name/familysearch_all_patients- Get all patients (paginated)
Clinical Data Tools
search_observations- Find lab results, vital signs, measurementssearch_conditions- Access diagnoses and medical conditionssearch_medication_requests- Retrieve prescriptions and medicationssearch_diagnostic_reports- Get lab reports and diagnostic studiessearch_care_plans- Access treatment and care plans
Quality & Diagnostics
assess_data_quality- Comprehensive server quality assessmentfind_patients_with_conditions- Identify patients with clinical dataget_capability_statement- Query server capabilities
📊 Usage Examples
Basic Patient Search
"Search for patients named 'Smith' and show their demographics"
Diabetes Management Workflow
"Find all patients with diabetes conditions, then show their:
- Current medications
- Recent glucose observations
- Active care plans
- Latest diagnostic reports"
Data Quality Assessment
"Assess the data quality of this FHIR server and identify any issues"
Research Query
"Find patients with conditions containing 'diabetes' and analyze their
medication patterns over time"
🏥 Healthcare Use Cases
Clinical Research
- Population Studies: Analyze patient cohorts across multiple conditions
- Treatment Outcomes: Track medication effectiveness and care plan adherence
- Data Quality: Validate FHIR implementations before production use
AI Development
- Training Data: Access clean, validated healthcare datasets
- Model Testing: Evaluate AI models against real clinical scenarios
- Integration Testing: Verify FHIR API compatibility
Quality Assurance
- Server Validation: Assess FHIR server implementations
- Data Integrity: Identify orphaned records and missing references
- Compliance Testing: Verify standards adherence
🔒 Security & Privacy
- No PHI Storage: Server operates read-only, no data retention
- Configurable Auth: Support for Bearer token authentication
- Audit Logging: Comprehensive request/response logging
- Error Handling: Secure error responses without data leakage
🧪 Testing
Test Server Quality
# Test different FHIR servers
python3 fhir_mcp_server.py
Use the assess_data_quality tool to evaluate:
- Data completeness (0-100 score)
- Reference integrity
- Resource availability
- Error rates
Synthetic Data Testing
Works excellently with:
- Synthea: Realistic synthetic patient data
- MIMIC-IV FHIR: Real anonymized hospital data
- Custom datasets: Load your own test data
🤝 Contributing
We welcome contributions! Please see our Contributing Guidelines for details.
Development Setup
# Clone and setup development environment
git clone https://github.com/jcafazzo/fhir-mcp.git
cd fhir-mcp
pip install -r requirements.txt
python3 fhir_mcp_server.py # Test locally
Roadmap
- [ ] Bulk FHIR operations support
- [ ] Temporal data analysis tools
- [ ] Enhanced MIMIC-IV integration
- [ ] Performance optimization
- [ ] Additional FHIR resource types
📚 Documentation
- CLAUDE.md - Claude Code integration guide
- FHIR R4 Specification - Official FHIR documentation
- MCP Protocol - Model Context Protocol specification
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- HL7 FHIR Community for the FHIR specification
- Anthropic for the Model Context Protocol
- SMART Health IT for excellent test servers
- Synthea Project for realistic synthetic data
📞 Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: Check CLAUDE.md for detailed setup
Built with ❤️ for the healthcare AI community
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。