使用说明
智能进气和分流MCP服务器
该项目构建并容器化 模型上下文协议(MCP)服务器 为了一个 智能进气和分流系统.
支持 动态路由、严重性评分和类别分类 使用可配置的规则,可选集成到LLM提供商,如 双子座 以便更明智地了解摄入量。
服务器设计用于 多行业使用 (医疗保健、金融、电子商务),通过在运行时使用环境变量和Docker卷挂载切换配置文件夹。
🚀 入门:构建MCP服务器
1) 项目初始化
创建主项目和服务器目录:
mkdir intake-mcp
cd intake-mcp
mkdir mcp-server
cd mcp-server
2) 配置设置
创建分类、严重性和路由配置文件:
mkdir -p config/healthcare
touch config/healthcare/taxonomy.json
touch config/healthcare/severity.yaml
touch config/healthcare/routing.json
3) 服务器文件
创建主Python服务器文件和需求列表:
touch mcp_server.py
touch requirements.txt
将这些依赖项添加到 requirements.txt:
fastmcp
pyyaml
python-dotenv
httpx
starlette
4) 安装与执行
安装所需的软件包并运行服务器:
pip install -r requirements.txt
python mcp_server.py
✅ 预期日志:
🚀 Starting Intelligent Intake and Triage MCP Server...
5) 健康检查
- 状态:
http://0.0.0.0:8000→ ✅ MCP正在运行 - 健康:
http://0.0.0.0:8000/health→OK
🐳 Docker的容器化
1) 多行业配置支持
我们使用Docker打包服务器,支持多个行业(医疗保健、金融、电子商务)通过安装的外部配置。
- 默认配置:
config/healthcare/(作为后备,捆绑在图像中) - 外部配置:
external-config/(运行时安装,支持多行业)
2) 默认配置结构
A. routing.json
{
"default_destination": "General_Queue",
"severity_override": {
"min_score": 9,
"destination": "ER_Triage",
"priority": "HIGH"
},
"routes": [
{
"category": "emergency",
"threshold": 9,
"destination": "ER_Triage"
},
{
"category": "billing",
"threshold": 2,
"destination": "Billing_Department"
}
]
}
B severity.yaml
severity_rules:
critical:
score: 10
keywords:
- chest pain
- unconscious
low:
score: 2
keywords:
- billing
- refund
C taxonomy.json
{
"taxonomy": [
{
"id": "emergency",
"keywords": ["chest pain", "heavy bleeding"]
},
{
"id": "billing",
"keywords": ["insurance", "refund"]
}
]
}
3) 构建并运行Docker
创建 Dockerfile 在 mcp-server 文件夹,然后构建映像:
docker build -t intake-triage-server .
使用外部医疗保健配置运行:
docker run -p 8000:8000 \
-v $(pwd)/external-config:/config \
-e CONFIG_PATH=/config/healthcare \
intake-triage-server
转换行业(如金融):只需改变 CONFIG_PATH 环境变量:
-e CONFIG_PATH=/config/finance
🤖 LLM提供商集成(Gemini)
1) 客户端设置
创建客户端目录和文件:
mkdir mcp-client
cd mcp-client
touch intake_mcp_client.py
touch requirements.txt
将这些添加到 mcp-client/requirements.txt:
fastmcp
google-genai
httpx
2) 执行
安装客户端要求:
pip install -r requirements.txt
设置API密钥:
export GOOGLE_API_KEY="YOUR_API_KEY_HERE"
运行客户端:
python intake_mcp_client.py
📁 最终项目结构
intake-mcp/
├── mcp-server/
│ ├── config/healthcare/
│ │ ├── taxonomy.json
│ │ ├── severity.yaml
│ │ └── routing.json
│ ├── external-config/
│ │ ├── healthcare/
│ │ └── finance/
│ ├── Dockerfile
│ ├── mcp_server.py
│ └── requirements.txt
└── mcp-client/
├── intake_mcp_client.py
└── requirements.txt
🤖 智能进气与分诊演示
MCP服务器根据域动态路由和处理数据。以下是服务器在两个不同部门处理高风险摄入的示例。
🏥 Healthcare Intake | 💰 Finance Intake
The MCP server identifies document types, extracts key entities, and assigns priority levels (Triage) in real-time.
