Skip to main content
Glama
rpint

nfyy-ckd-risk-warning-mcp

by rpint

童肾营养师·风险预警 Agent —— Mock MCP Server

团队编号:NFYY038 | 项目:南方医科大学南方医院「童肾营养师」多智能体辅助决策系统 子智能体:风险预警 Agent(复赛演示版)

本仓库是「童肾营养师」多智能体系统中风险预警 Agent 的自定义 MCP(Model Context Protocol)服务实现。它解决复赛阶段无法接入真实 HIS / LIS、无法通过小程序真实推送的约束,用模拟数据 + 确定性硬规则引擎 + 北向报文/MQ 模拟,完整复现「风险研判 → 等级判定 → 结构化报文推送 → 临床处置 SOP」的预警能力。


1. 它能做什么

能力

说明

南向 Mock·LIS 趋势

fetch_patient_biochemical_trends 模拟调用院内 LIS,返回近 3 个月生化趋势、本次结果、变化百分比、身高/体重 Z 评分序列

硬规则引擎

evaluate_risk_rules全部阈值与涨幅计算下沉为确定性 Python 代码,杜绝 8B 小模型算术幻觉

北向报文 + MQ 模拟

trigger_warning_event 生成 CKD-ALERT/1.0 结构化报文,模拟抛出至消息队列并透传医生工作站 / 家长端微信小程序,返回投递回执

临床处置 SOP

get_clinical_sop 查询每条规则的主诊医生 / 护理 / 家长三视图处置建议与循证依据

内置 5 个 MCP 工具15 例虚构患儿(覆盖 normal / abnormal / boundary / exception 四类场景)、13 条硬规则


Related MCP server: ckd-meal-plan-mcp

2. 架构与数据流

医生「研判指令输入」
        │
        ▼
┌──────────────────────────────────────────────────────────┐
│ 风险预警 Agent(8B 模型,仅组织自然语言)                  │
│   1. list_mock_patients            → 选定患儿              │
│   2. fetch_patient_biochemical_trends (南向 Mock①/LIS)    │
│   3. evaluate_risk_rules          → 硬规则引擎判定等级    │
│   4. trigger_warning_event        (北向 Mock②/推送+MQ)    │
│   5. get_clinical_sop             → 处置 SOP              │
└──────────────────────────────────────────────────────────┘
        │ 结构化 JSON 报文 (CKD-ALERT/1.0)
        ▼
┌──────────────────────────────────────────────────────────┐
│ 北向接口 / 消息队列(模拟 ⇒ 上线替换为 Kafka / 企微网关) │
│   topic: ckd.alert.pediatric                              │
└──────────────────────────────────────────────────────────┘
        │ 透传
        ▼
   医生工作站待办卡片  /  家长端微信小程序订阅消息

硬规则(防幻觉红线)示例:肌酐较基线涨幅 ≥50% → L1 一级 AKI;血钾 >5.5 mmol/L → L1 高钾危急;白蛋白 <35 g/L 且体重 Z 连续下降 → L2 PEW。完整 13 条见 src/nfyy_ckd_risk_warning/rules.pyknowledge/


3. 安装与运行

方式一:PyPI / uvx(魔搭 MCP 广场部署用)

# 以 stdio 方式拉起服务(魔搭/Nexent 自定义 MCP 即如此调用)
uvx nfyy-ckd-risk-warning-mcp

服务配置 JSON(魔搭 MCP 广场「自定义创建-可托管部署」填法):

{ "mcpServers": { "nfyy038-risk-warning": { "command": "uvx", "args": ["nfyy-ckd-risk-warning-mcp"] } } }

方式二:源码安装(开发 / 评测)

python -m venv .venv && source .venv/bin/activate
pip install -e .
nfyy-ckd-risk-warning-mcp            # 等价于 python -m nfyy_ckd_risk_warning

本地 SDK 调用(不依赖 MCP 传输,便于单测/演示)

from nfyy_ckd_risk_warning import server
# 输入今日生化报告 API 新结果,引擎自动对比上一次历史结果并重新研判
out = server.trigger_warning_event("C_8808", today_creatinine=165, today_potassium=5.8, today_albumin=33)
# out["reassessment"] -> 历史 L3 → 本次 L1 对照;out["payload"] / out["markdown"] -> 报文与 SOP

4. 复赛 Demo 演示要点

复赛无真实北向接口时,用「研判指令输入 + 今日生化报告 API 模拟** 触发即可证明预警能力:

请对患儿 C_8808 进行风险研判。今日生化报告 API 回传:血肌酐 165 μmol/L,血钾 5.8 mmol/L,血清白蛋白 33 g/L。 (患儿上一次历史结果:肌酐 95、血钾 5.4、白蛋白 43;历史系统判定 L3。)

Agent 经 fetch(历史记录) → trigger(输入今日新报告,引擎自动对比上一次结果并重新研判) 两步,输出:

  1. 重新研判对照:历史系统判定 L3 → 本次基于新数据重新研判 L1(肌酐 95→165 +73.7%≥50% → R-01;血钾 5.8>5.5 → R-02;白蛋白 33<35 且体重 Z 连降 → R-04),明确标注「历史等级被新数据推翻」;

  2. 推送 JSON 报文CKD-ALERT/1.0 契约,含等级、命中规则、复查、循证);

  3. 临床处置 SOP(Markdown:主诊医生 / 护理 / 家长 / 饮食红线 / 复查);

  4. 一句话结论摘要(模型组织,附免责声明)。

说明:模拟数据 = 患儿历史记录;今日新血检结果(生化报告 API 模拟)是重新研判的驱动方——新数据优先、不沿用历史等级。本工具不设「以系统/引擎为准」的强制纠偏,历史系统判定仅作对比展示,最终等级由「今日新数据 + 上一次历史基线」的硬规则计算决定。


5. 目录结构

nfyy038-ckd-risk-warning-mcp/
├── src/nfyy_ckd_risk_warning/
│   ├── data/patients.json        # 15 例模拟患儿数据集(虚构)
│   ├── rules.py                  # 硬规则引擎(13 条)
│   ├── sop.py                    # 临床处置 SOP 文案库 + 循证
│   ├── store.py                  # 模拟 LIS/HIS 南向数据访问层
│   ├── payload.py                # 北向报文 + 消息队列模拟 + Markdown 渲染
│   ├── server.py                 # FastMCP Server(5 个工具)
│   ├── __main__.py / __init__.py
├── scripts/                      # 数据生成 / 测评集生成 / stdio 冒烟
├── prompts/                     # 系统提示词(四模块模板)
├── knowledge/                    # 知识库 SOP 简化版(iData RAG 挂载参考)
├── datasets/                     # 模拟数据集 + 测评数据集 + 数据/测评说明
├── docs/                         # 部署/接入/Demo/材料清单
├── tests/test_engine.py          # 确定性测试套件(15 例全通过)
└── pyproject.toml                # PyPI 发布配置(包名 nfyy-ckd-risk-warning-mcp)

6. 测试

pip install -e .
python tests/test_engine.py       # 4 项全部通过:15 例预期等级+规则、报文/MQ 契约
python scripts/_smoke_stdio.py    # MCP stdio 握手:暴露 5 个工具

7. 免责声明

本项目及全部数据均为虚构合成数据,仅用于「南方医科大学南方医院智能体创新大赛」复赛演示,不可用于任何真实临床决策。所有处方级用药调整须由主诊医生决定。

Available Tools

5 tools
evaluate_risk_rulesA

【硬规则引擎】按预警 SOP 硬阈值做确定性研判,返回预警等级与命中规则。

这是防止小模型算术幻觉的关键工具:涨幅计算、阈值比较、等级归并全部由代码完成。 Agent 必须以本工具返回的 level 与 triggered_rule_ids 为唯一判定依据。

两种用法:

  1. 传 patient_id:自动从模拟 LIS 拉取全部数据后研判(推荐)。

  2. 直接传指标数值:用于医生口述/临时录入的场景,未传的项按缺失处理。

ParametersJSON Schema
NameRequiredDescriptionDefault
albuminNo本次血清白蛋白 g/L。
potassiumNo本次血钾 mmol/L。
age_monthsNo月龄,手工模式下用于血磷年龄分层,缺省按学龄期处理。
creatinineNo本次血肌酐 μmol/L。
patient_idNo患儿编号。传入时其余参数作为覆盖值,留空则完全使用手工输入。
phosphorusNo本次血磷 mmol/L。
specimen_noteNo标本备注,含「溶血」时会触发假性高钾复核规则。
height_z_seriesNo身高 Z 评分序列,格式同上。
weight_z_seriesNo体重 Z 评分序列,逗号分隔按时间升序,如 "-1.02,-1.28,-1.61"。
baseline_creatinineNo约 3 个月前血肌酐 μmol/L。

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.3/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It discloses that arithmetic calculations are code-computed to prevent hallucination, that patient_id mode auto-fetches data, and that missing values are treated as missing. Also notes special handling for hemolyzed specimens. This offers valuable behavioral context beyond the schema.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with a clear intro, rationale, and bulleted usage modes. It is slightly longer than necessary but every sentence contributes context. The front-loaded purpose statement helps the agent quickly identify the tool's role.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the 10-parameter complexity and the presence of an output schema, the description sufficiently covers when and how to use the tool, return types (level and triggered rules), missing value behavior, and special cases. Additional details on exact thresholds are appropriately left to the SOP.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema already has 100% coverage with parameter descriptions. The description adds meaningful usage semantics by explaining the override behavior when patient_id is passed, the default handling for age/phosphorus in manual mode, and the special specimen_note trigger. This enhances understanding beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly identifies the tool as a deterministic rule engine that evaluates against warning SOP hard thresholds, returning warning level and triggered rules. This specific verb-resource combination distinguishes it from sibling tools like fetch_patient_biochemical_trends or trigger_warning_event.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly states two usage modes: passing patient_id for automatic LIS data pull (recommended) or direct metric values for manual entry. It also instructs the agent to rely solely on this tool's output for risk judgment. Does not explicitly contrast with alternatives, but context makes it clear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_clinical_sopA

查询预警规则对应的完整临床处置 SOP(医生 / 护理 / 家长三视图)与循证依据。

ParametersJSON Schema
NameRequiredDescriptionDefault
rule_idNo规则编号,如 R-02。留空则返回全部规则的 SOP 索引。

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses what the tool returns (complete SOP, three views, evidence basis) but does not mention any side effects, permissions, or edge-case behavior. This is adequate for a query tool but lacks deeper behavioral context such as error handling or data scope.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, front-loaded sentence that efficiently conveys the tool's purpose and key features. Every word adds value, with no redundancy or filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given that an output schema exists, the description need not explain return values. The description covers the essential aspects: the object (SOP for warning rules), the views (doctor/nursing/parent), and evidence basis. It lacks explicit usage guidance, but the schema covers blank-rule_id behavior, making it sufficiently complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description already thoroughly covers the only parameter rule_id, including its default and blank behavior. The tool description adds no additional parameter semantics beyond what the schema provides, so the baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool queries the complete clinical SOP corresponding to warning rules, including doctor/nursing/parent views and evidence basis. This is a specific verb+resource that distinguishes it from sibling tools like evaluate_risk_rules and trigger_warning_event.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

While no explicit alternatives are named, the description clearly implies this tool is for retrieving SOPs for warning rules, which is distinct from the other sibling tools. The schema description also clarifies behavior when rule_id is blank. No exclusions are provided, but the context is clear enough.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

list_mock_patientsA

列出模拟 HIS 中全部可用患儿档案,用于 Demo 演示时选择研判对象。

ParametersJSON Schema
NameRequiredDescriptionDefault
scenario_typeNo可选场景过滤,取值 normal / abnormal / boundary / exception,留空返回全部。

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full responsibility for behavioral disclosure. It describes the action as '列出' (list), which implies a read-only operation, and notes the mock nature of the data. However, it does not explicitly state that there are no side effects, require no special permissions, or describe any limitations. This is adequate for a simple listing tool but lacks deeper behavioral context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, concise sentence that clearly communicates the tool's purpose and use case. There is no unnecessary information or redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool is simple with one optional parameter and an output schema, so the description is largely sufficient. It provides the purpose and usage context. It does not elaborate on return format, but the output schema exists, covering that. The only minor gap is not explicitly connecting the '全部' (all) in the description to the filtering capability of the scenario_type parameter, but the schema covers that.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description covers 100% of the parameter (scenario_type), so the description itself does not need to add parameter details. The tool description does not mention the parameter, but the schema fully documents its purpose and allowed values. Baseline 3 is appropriate since the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's function: '列出模拟 HIS 中全部可用患儿档案' (list all available pediatric patient records in the mock HIS). It uses a specific verb (list) and resource (patient records), and distinguishes itself from siblings like fetch_patient_biochemical_trends or evaluate_risk_rules by focusing on patient selection for demos.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly states the context: '用于 Demo 演示时选择研判对象' (used for selecting analysis targets during demo presentations). This implies when to use the tool but does not explicitly exclude alternative tools or mention when not to use it, so it's slightly below perfect.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

trigger_warning_eventA

【北向 Mock 工具②】生成结构化预警报文,抛出至北向接口与消息队列,返回投递回执。

完整流程:拉取模拟 LIS 数据 -> 硬规则研判 -> 组装 CKD-ALERT/1.0 报文 -> 投递至医生工作站 / 家长端微信小程序 -> 返回带 offset 的 MQ 回执。

若 agent_suggested_level 与规则引擎判定不一致,以规则引擎为准, 并在回执 level_correction 字段中记录纠偏,用于防止小模型误判等级。

ParametersJSON Schema
NameRequiredDescriptionDefault
channelsNo推送通道,逗号分隔,如 "doctor_workstation,wechat_miniprogram"。留空按等级自动选择。
extra_noteNo附加备注,会写入报文 trigger_note 字段。
patient_idYes患儿编号,如 C_8801。
trigger_sourceNo触发来源,如 manual_review(医生研判)、lis_auto(检验自动触发)、followup(随访)。manual_review
agent_suggested_levelNoAgent 自行判断的等级(L0/L1/L2/L3),选填,仅用于一致性校验。

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.2/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It discloses key behaviors: pulling simulated LIS data, performing hard rule assessment, prioritizing the rule engine over agent_suggested_level, and recording level_correction in the receipt. It also mentions the return receipt with offset, providing useful transparency without contradictions.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized, with a summary sentence, a flow diagram, and a behavioral note. It is front-loaded with the main purpose and every sentence adds value, though the flow could be slightly more compact.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the presence of an output schema and complete parameter descriptions, the description is sufficient. It explains the tool's role, the full process, and a critical correction behavior, leaving no major gaps in understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3. The description adds some context, especially for agent_suggested_level (used for consistency check and correction) and relates channels to delivery targets, but it does not systematically enrich parameter understanding beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool generates structured warning messages, sends them to the northbound interface and message queue, and returns a delivery receipt. This is a specific verb+resource+outcome, and it is distinct from sibling tools like list_mock_patients or evaluate_risk_rules, which serve different functions.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context by outlining the complete flow (pull LIS data -> rule assessment -> assemble message -> deliver -> return receipt), which implies when the tool should be used. However, it does not explicitly specify when not to use it or name alternatives, so it lacks exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 5 tool updatesv1.0.0
    • First observedevaluate_risk_rules
    • First observedfetch_patient_biochemical_trends
    • First observedget_clinical_sop
    • First observedlist_mock_patients
    • First observedtrigger_warning_event

TDQS

A4.4/5.0
Disambiguation5/5

Each tool targets a distinct step in the clinical warning workflow: patient selection, data retrieval, SOP lookup, rule evaluation, and event dispatch. No overlapping purposes or ambiguous boundaries.

Naming Consistency5/5

All tool names follow a consistent verb_noun snake_case pattern (list_, fetch_, get_, evaluate_, trigger_), making the naming predictable and easy to reason about.

Tool Count5/5

Five tools is well-scoped for this server's purpose, covering the entire warning process without redundancy or bloat. Each tool serves a necessary function.

Completeness5/5

The tool surface covers the complete workflow from patient list retrieval to risk evaluation and warning dispatch, with SOP lookup as a supporting function. No critical gaps or dead ends.

Maintenance

ActivityMaintained
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    B
    maintenance
    MCP server for infant fever management that tracks symptoms, medication, and lab results, providing guideline-based escalation levels, pharmacokinetic predictions, and structured clinical reports.
    -
  • A
    license
    A
    quality
    B
    maintenance
    This MCP server generates individualized meal plans for children with chronic kidney disease (CKD) based on KDIGO 2024/PRNT 2020/KRCP 2025 guidelines, incorporating patient age, CKD stage, allergies, dietary culture, and diet diary analysis. It provides deterministic nutrient computations and tools for meal plan generation, food database lookup, and risk analysis.
    13
    MIT
  • F
    license
    A
    quality
    B
    maintenance
    MCP server for pediatric CKD lab data, providing lab panel queries, critical value alerts, trend analysis, and write operations with role-based permissions.
    5
    -
  • F
    license
    A
    quality
    B
    maintenance
    Read-only MCP server providing pediatric CKD patient master data with tools for patient profiles, diagnosis, nutrition ceilings, guardian verification, and patient lists, designed for the CKDNutri project.
    5
    -

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/rpint/nfyy-ckd-risk-warning-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server