Cardiology Knowledge Graph MCP
Builds and manages a cardiology-focused knowledge graph in Neo4j by extracting medical entities and relationships from documents using LLMs. It enables users to ingest PDFs, refine extracted data, and perform natural language queries to gain clinical insights.
README
Cardiology Knowledge Graph MCP Server
A Model Context Protocol (MCP) server that creates and queries a cardiology knowledge graph using Neo4j and LLM-powered entity extraction.
Features
- 📚 Document Ingestion: Process PDF files or raw text to extract cardiology entities and relationships
- 🧠 LLM-Powered Extraction: Uses GPT-4 (or customizable models like BioGPT) for intelligent extraction
- 📊 Knowledge Graph: Stores data in Neo4j with proper relationships
- 🔍 Natural Language Queries: Query the graph using plain English
- ✏️ Human-in-the-Loop: Review and edit extractions before adding to graph
- 📈 Graph Analytics: Get statistics and insights about your knowledge graph
Prerequisites
1. Neo4j Setup
-
Option A (Recommended): Download Neo4j Desktop for Mac
- Create a new database with these credentials:
- URI:
bolt://localhost:7687 - Username:
neo4j - Password:
password(or your choice)
- URI:
- Start the database
- Create a new database with these credentials:
-
Option B: Use Neo4j Aura (free cloud instance)
- Update connection details in your environment variables
2. API Key
- Get an OpenAI API key from OpenAI Platform
- Or set up alternative models (see Configuration section)
Installation
-
Clone and setup:
git clone <your-repo> cd "Cardiology Knowledge Graph MCP" -
Install dependencies:
pip install -r requirements.txt -
Set up environment variables:
cp .env.example .env # Edit .env with your actual values -
Test the server:
python mcp_server.py
Claude Desktop Configuration
-
Find your Claude Desktop config:
- Mac:
~/Library/Application Support/Claude/claude_desktop_config.json - Create the file if it doesn't exist
- Mac:
-
Add the MCP server configuration:
{ "mcpServers": { "cardiology-kg": { "command": "python", "args": ["/full/path/to/your/mcp_server.py"], "env": { "NEO4J_URI": "bolt://localhost:7687", "NEO4J_USERNAME": "neo4j", "NEO4J_PASSWORD": "your-password", "OPENAI_API_KEY": "your-openai-key" } } } } -
Restart Claude Desktop and look for the 🔨 hammer icon to confirm the server is connected.
Usage
1. Document Ingestion
Process a PDF file:
Ingest this cardiology document: /path/to/cardiology-textbook-chapter.pdf
Process raw text:
Ingest this cardiology note: "Patient presents with atrial fibrillation. Echocardiogram shows left ventricular hypertrophy. Prescribed metoprolol for rate control."
The system will:
- Extract entities (conditions, medications, procedures, anatomy)
- Identify relationships (causes, treats, affects, etc.)
- Return a draft JSON for your review
2. Review and Edit Extractions
After ingestion, you'll get a draft like:
{
"entities": [
{"name": "atrial fibrillation", "label": "Condition", "properties": {}},
{"name": "metoprolol", "label": "Medication", "properties": {"class": "beta-blocker"}}
],
"relationships": [
{"source": "metoprolol", "target": "atrial fibrillation", "type": "TREATS", "properties": {"purpose": "rate control"}}
]
}
Edit as needed, then add to graph:
Add this to my knowledge graph: [paste your edited JSON]
3. Query the Knowledge Graph
Ask natural language questions:
What medications treat atrial fibrillation?
How does left ventricular hypertrophy affect cardiac function?
Show me all conditions that cause heart failure.
What procedures are used to diagnose coronary artery disease?
4. Graph Management
Get statistics:
Show me statistics about my cardiology knowledge graph
Clear the graph (caution!):
Clear my knowledge graph
Advanced Configuration
Using Alternative LLMs
BioGPT (specialized medical model):
# Uncomment in mcp_server.py:
from langchain_huggingface import HuggingFaceHub
llm = HuggingFaceHub(repo_id="microsoft/BioGPT")
Local Ollama model:
# Uncomment in mcp_server.py:
from langchain_community.llms import Ollama
llm = Ollama(model="llama2") # or "biomedical-llm"
Custom Entity Types and Relationships
Edit the extraction prompt in mcp_server.py to focus on specific:
- Anatomical structures
- Drug classes
- Diagnostic criteria
- Treatment protocols
Integration with Neo4j Official MCP Servers
Install additional Neo4j MCP servers for enhanced capabilities:
pip install mcp-neo4j-cypher mcp-neo4j-memory
Add to Claude config:
{
"mcpServers": {
"cardiology-kg": { /* your custom server */ },
"neo4j-cypher": {
"command": "mcp-neo4j-cypher",
"args": ["--db-url", "bolt://localhost:7687", "--user", "neo4j", "--password", "password"]
}
}
}
Example Workflow
-
Start with a textbook chapter:
Ingest this PDF: /Users/you/Downloads/cardiac-physiology-chapter.pdf -
Review the extraction - you might see entities like:
- Anatomy: "left ventricle", "aortic valve"
- Processes: "cardiac cycle", "systole", "diastole"
- Relationships: "systole FOLLOWS atrial contraction"
-
Edit and refine the JSON to add missing details or correct relationships
-
Add to graph:
Add this to my knowledge graph: [your refined JSON] -
Query for insights:
Explain the cardiac cycle based on my knowledge graph What anatomical structures are involved in systole? How do beta-blockers affect the cardiac cycle?
Troubleshooting
Common Issues
"Connection refused" error:
- Ensure Neo4j database is running
- Check connection details in environment variables
"API key not found":
- Verify OPENAI_API_KEY is set correctly
- Check Claude Desktop config environment variables
"Module not found" errors:
- Run
pip install -r requirements.txtagain - Check Python virtual environment
MCP server not appearing in Claude:
- Verify the full path to
mcp_server.pyin config - Restart Claude Desktop completely
- Check logs in Claude Desktop (Help → Show Logs)
Logs and Debugging
The server logs helpful information. To see detailed logs:
python mcp_server.py 2>&1 | tee server.log
Contributing
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Submit a pull request
License
MIT License - see LICENSE file for details.
Acknowledgments
- Built on the Model Context Protocol by Anthropic
- Uses Neo4j for graph database capabilities
- Powered by LangChain for LLM integration
- Inspired by medical informatics and knowledge representation research
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。