Skip to main content
Glama
README.md
# a207-his-mcp

儿童慢性肾脏病(CKD)患者主数据 MCP 包(M1),模拟医院 HIS 患儿全量信息,供 CKDNutri 项目调度 Agent 与各业务子 Agent 锚定患儿身份与确诊事实。

本包为**只读主数据源**,不提供任何写入工具。分期以本服务返回的确诊值为准,调用方不得自行复算(MX-1 约束:营养师/家长助手命中分期词族时只读此处确诊值,不触发 M6 分期计算)。

## 五个工具

| 工具 | 说明 |
|------|------|
| `get_patient_profile` | 患儿档案:人口学、确诊分期、病因、透析方式、过敏史、医生营养上限。医生助手/风险预警/调度获全量视图(含 5 天饮食日记与跨月度生化);营养师视图不含生化;家长视图仅诊断、过敏与上限且必须携带 guardian_token |
| `get_diagnosis` | 医生确诊的 CKD 分期与透析方式,供营养师/家长助手替代分期复算 |
| `verify_guardian_binding` | 核验监护人与患儿绑定关系,家长助手每次访问患儿数据前必经此步 |
| `list_patients` | 按条件(分期/透析/年龄带)筛选患儿清单,供联调与演示 |
| `get_nutrition_ceiling` | 医生设定的能量/蛋白/钾/磷/钠/液体上限,作为营养计算与食谱生成的硬约束 |

## 调用方身份(P0-1)

调用方身份**不再是工具入参**,由部署侧通过环境变量 `A207_CALLER` 注入(取值见 `a207_policy.CALLERS`),
模型无法自证身份。未注入时所有工具 fail-closed 抛 `CallerUnknown`。放行集合统一取自 `a207_policy`
(`HIS_READ` / `HIS_FULL_VIEW` / `HIS_LIMITED` / `HIS_BLOCKED` / `HIS_COHORT` / `HIS_ALLOWED_FILTER_KEYS`),本包不再维护副本。

```bash
A207_CALLER=doctor_assistant python -m a207_his_mcp.server
```

## 数据

- `data/patients.json`:由 `data/generate.py` 确定性生成,覆盖 G2-G5 × HD/PD/非透析 × 各年龄带,**36 例**高拟真患儿,含 5 天食谱与跨月度生化。
- 家长视图受限:A207_CALLER=parent_assistant 须携带 guardian_token,否则返回字段裁剪或拒绝。

## 目录结构

```
a207-his-mcp/
├── pyproject.toml
├── README.md
├── src/a207_his_mcp/
│   ├── __init__.py
│   ├── core.py          # 纯逻辑(无 MCP/pydantic 依赖)
│   ├── server.py        # FastMCP >=2 服务定义(5 个 @mcp.tool)
│   ├── models.py        # pydantic v2 入参模型(extra=forbid)
│   └── data/patients.json
└── tests/test_tools.py
```

## 设计约束

- 不依赖、不 import 任何其它领域 `a207-*` 包(仅依赖统一策略包 `a207-policy`)
- 只读;A207_CALLER=child_companion 一律拒绝
- 错误以 `{"ok": false, "error": ...}` 形式返回

## 运行与测试

```bash
# 编译(server.py/models.py 依赖 fastmcp/pydantic,仅做语法校验)
python -m py_compile src/a207_his_mcp/*.py

# 纯标准库自测(core 逻辑不依赖 fastmcp/pydantic,可独立运行)
python tests/test_tools.py
```

返回非零退出码表示存在失败用例。

## 启动 MCP 服务

```bash
pip install -e .
python -m a207_his_mcp.server
# 或
fastmcp dev src/a207_his_mcp/server.py
# 或(已注册 console script)
uvx --from . a207-his-mcp
```

TDQS

A3.9/5.0

Scored across 5 tools

Disambiguation3/5

Tools have distinct names and purposes, but get_patient_profile overlaps with get_diagnosis and get_nutrition_ceiling by including diagnosis and nutrition limits in its data. While role-based views and descriptions help clarify intended usage, an agent could be uncertain whether to call the specialized getter or the full profile.

Naming Consistency5/5

All tools follow a consistent verb_noun pattern with snake_case (get_patient_profile, get_diagnosis, verify_guardian_binding, list_patients, get_nutrition_ceiling). The verbs are predictable (get/list/verify) and resources are clearly named.

Tool Count5/5

Five tools is well-scoped for a patient-data access server focused on read operations and authorization. Each tool serves a distinct function in the workflow, with no redundant or trivial tools.

Completeness4/5

The server covers core read workflows: patient lookup, detailed profile access, diagnosis verification, nutrition limits, and guardian authorization. Minor gaps exist, such as lacking a separate tool for labs or diet diary, but they are embedded in the profile, so agents can achieve their goals without dead ends.

Maintenance

ActivityMaintained
ResponsivenessSyncing