a207-lis-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@a207-lis-mcpWhat are the latest labs for P0028?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
a207-lis-mcp —— M2 检验数据
CKDNutri / NFYY038 Wave 1 交付包。为儿童慢性肾脏病场景提供检验面板查询、危急值独立通道、单指标趋势与新增采样写入。
技术栈:FastMCP ≥2.0 + pydantic ≥2 + Python 3.13,stdio 传输。
铁律遵循
不 import 任何其他
a207-*包,不向其他 MCP 发起调用。所有入参为显式字段,由调度 Agent 从 PCP 取值后传入。core.py/models.py/views.py/store.py/reference.py不依赖 fastmcp,未安装 fastmcp 也能跑tests/test_tools.py。单位与
contracts/pcp-schema.json锁死:Scr μmol/L,K/P/Ca/Na/Cl/BUN/HCO3 mmol/L,Alb/Hb g/L,iPTH pg/mL,UA μmol/L,eGFR mL/min/1.73m²。写入口对 mg/dL、g/dL 口径做归一化。写操作带
caller校验,越权返回{"ok": false, "error": "FORBIDDEN", "detail": "..."}。
Related MCP server: ckd-meal-plan-mcp
权限(需求文档 §7 权限矩阵)
caller | get_labs | get_critical_values | get_lab_trend | upsert_lab_result |
doctor_assistant | 全量 | 允许 | 允许 | 允许写 |
risk_warning | 全量 | 允许 | 允许 | 拒绝 |
parent_assistant | 受限视图 | 拒绝 | 拒绝 | 拒绝 |
nutritionist | 拒绝 | 拒绝 | 拒绝 | 拒绝 |
child_companion | 拒绝 | 拒绝 | 拒绝 | 拒绝 |
orchestrator | 拒绝 | 拒绝 | 拒绝 | 拒绝 |
家长受限视图只返回最近一次 K / P / 白蛋白 / 血红蛋白的趋势方向(↑ ↓ →)、是否在儿童参考区间内与危急标注,不返回任何原始数值。这是"能不能吃西瓜"类问题能个体化回答、又不越界暴露化验单的前提。
工具
get_labs(patient_id, caller="doctor_assistant")
按报告日期升序返回全部检验面板。每个指标附单位、儿童年龄别参考区间上下限、状态判定(critical_high / high / in_range / low / critical_low)。caller=parent_assistant 走受限视图。
get_critical_values(patient_id, caller="risk_warning")
危急值独立通道,扫描最近一次采样。内置阈值:K⁺ > 6.5、K⁺ < 2.8、Hb < 60、Ca < 1.60、Ca > 3.50、Na < 120、Na > 160、P > 3.20、HCO₃⁻ < 12。命中时 next_action 提示编排层走通知链路。
get_lab_trend(patient_id, analyte, caller="doctor_assistant", window_days=None)
单指标时间序列,含环比绝对差、环比百分比、最小二乘拟合的每 30 天斜率与方向。analyte 取契约字段名,如 scr_umol_L、k_mmol_L、hb_g_L。
upsert_lab_result(patient_id, caller, lab, write_mode=True)
新增一条采样。写权仅 doctor_assistant(MX-3)。lab 走 pydantic 白名单校验,未声明字段与越界数值一律拒绝。成功返回 recommend_reevaluate: true,编排层据此强制触发风险规则重评;若新值命中危急阈值,notify_action 同时给出通知动作。
write_mode=False 为回滚模式:完成校验、单位归一化与危急值预演,但不落盘。
list_known_patients()
列出本数据集覆盖的 patient_id,供跨包联调核对。
数据
data/labs.json 由 data/generate.py 以固定 seed(20260808)程序化生成,重复运行结果一致,产物随包提交。
34 例患儿、105 次采样,patient_id
P0001–P0034,格式匹配 PCP 契约的^P[0-9]{4,}$覆盖分期 G2 / G3a / G3b / G4 / G5 × 透析方式 none / hemodialysis / peritoneal × 年龄带 1-3 / 4-6 / 7-12 / 13-17
每例 2–4 次跨月度采样,随时间轻度进展
先按分期抽取 eGFR,再用 Schwartz 床边公式反解肌酐,保证分期与肌酐互不矛盾;血钾在血透例偏高(透析前采样蓄积)、白蛋白在腹透例偏低(腹透液蛋白丢失)
强制置入 3 例危急值供链路测试:P0028 K⁺ 6.9 mmol/L、P0031 Hb 55 g/L、P0023 Ca 1.52 mmol/L
写入落盘到 data/labs_store.json(基线 labs.json 保持只读)。数据目录解析顺序:环境变量 A207_LIS_DATA_DIR → 包内 data/ → 仓库根 data/。
重新生成:
python data/generate.py自测
python -m py_compile src/a207_lis_mcp/*.py
python tests/test_tools.py31 项断言,覆盖权限矩阵、受限视图零数值泄露、危急值命中、单位归一化、白名单校验、越权无副作用、零跨包引用。写操作跑在临时目录,不污染提交产物。
启动
fastmcp dev src/a207_lis_mcp/server.pyAvailable Tools
5 toolsget_critical_valuesA
危急值独立通道。扫描最近一次采样,命中 K+>6.5 / Hb<60 / Ca<1.6 等阈值即返回。
| Name | Required | Description | Default |
|---|---|---|---|
| caller | No | risk_warning | |
| patient_id | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
The description discloses the key behavioral trait of scanning the most recent sample and returning only when critical thresholds are hit. With no annotations provided, the description carries the full burden, but it does not clarify behaviors such as what happens when no critical value is found, whether it returns all hits or just the first, or whether it operates per patient or globally. This leaves meaningful gaps.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, compact sentence that front-loads the core purpose ('危急值独立通道') and then specifies the threshold logic. It is efficient, though the opening phrase is somewhat redundant with the tool name and uses domain jargon that may not be self-explanatory to all agents.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The description provides essential threshold values and the scanning behavior, and the presence of an output schema removes the need to describe return values. However, it fails to clarify how patient_id scopes the operation, which is a required parameter, and leaves ambiguity about what 'most recent sample' means in a multi-patient context. These gaps make the description only minimally complete for correct invocation.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema has 0% description coverage, and the tool description does not explain either parameter. The required patient_id is not mentioned as a filter for which patient's sample to scan, and the caller default is ignored. The description adds no value beyond the schema's bare type/default fields.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly identifies a dedicated critical-values channel that scans the latest lab sample and returns when thresholds are hit (K+>6.5, Hb<60, Ca<1.6). This distinguishes it from sibling tools like get_labs and get_lab_trend, which are general-purpose lab retrieval tools. The verb 'scan' and specific threshold criteria make the tool's purpose unambiguous.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The phrase '危急值独立通道' indicates this is a specialized, separate path for critical-value alerts, which signals when to prefer this tool over general lab-fetching siblings. However, it does not explicitly mention when not to use it or name alternatives, so there is room for more explicit exclusion guidance.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_labsA
按时间升序返回患者全部检验面板。
caller=parent_assistant 时返回受限视图:仅最近一次 K/P/白蛋白/血红蛋白的 趋势方向与是否在儿童参考区间内,不含原始数值。
| Name | Required | Description | Default |
|---|---|---|---|
| caller | No | doctor_assistant | |
| patient_id | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
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 behavioral traits: ascending time order, and the restricted view for 'parent_assistant' (only trend direction and reference range status, no raw values). This adds meaningful transparency beyond the basic action, though it omits details like error handling or auth requirements.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is two sentences, extremely concise, and front-loaded with the main action. Every sentence serves a purpose: the first states the core function, the second explains an important conditional behavior. No wasted words.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's complexity (two params, output schema exists), the description covers the essential behavior and the caller-dependent view. It does not mention pagination, sorting beyond ascending, or error cases, but these are likely less critical for a read operation. The output schema presumably details return values, so the description need not repeat them.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema has no descriptions (0% coverage), so the description must compensate. It significantly clarifies the 'caller' parameter by explaining its effect on the returned data, adding value beyond the schema. The 'patient_id' parameter is implied but not detailed; however, the schema already marks it as required and its purpose is evident.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool returns all lab panels for a patient in ascending time order, using a specific verb ('返回') and resource ('检验面板'). It also differentiates behavior based on the caller parameter, distinguishing it from sibling tools like get_lab_trend.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description gives clear context on when to use the tool (to retrieve all lab panels) and specifies a conditional behavior for 'parent_assistant' callers. It does not explicitly mention alternatives or exclusions, but the context is sufficient for basic usage decisions.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_lab_trendB
单指标时间序列,含环比变化率与每 30 天斜率。analyte 如 scr_umol_L、k_mmol_L。
| Name | Required | Description | Default |
|---|---|---|---|
| caller | No | doctor_assistant | |
| analyte | Yes | ||
| patient_id | Yes | ||
| window_days | No |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
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 core behavioral details: returns a time series with computed metrics (环比变化率 and 30-day slope). However, it does not mention whether the operation is read-only, if any side effects occur, or how window_days affects the output. This is moderate transparency but leaves gaps.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, information-dense sentence, front-loading the core purpose and immediately adding value with analyte examples. There is no fluff or redundancy; every clause contributes to understanding the tool's output and key parameter.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The description explains the tool's primary output and gives an analyte example, which is adequate for initial selection. However, the presence of an output schema mitigates the need to document return values, but the description still lacks details on how window_days affects results and whether any patient-specific constraints exist. Given the tool's moderate complexity, the description is minimally sufficient but not comprehensive.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, so the description must compensate. It provides concrete examples for analyte (scr_umol_L, k_mmol_L), which is helpful, but does not explain patient_id, window_days, or caller. The meaning of window_days (time range filter) is entirely undocumented, leaving the agent guessing. The description only partially covers parameter semantics.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states the tool provides a single-indicator time series with period-over-period change rate and 30-day slope, which clearly identifies its function. It distinguishes itself from siblings like get_labs by focusing on trend analysis rather than raw lab values. However, it lacks an explicit verb like 'retrieve' or 'list', though the intent is unambiguous.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No explicit guidance is given on when to use this tool instead of siblings. The description implies it is for trend analysis, but it does not state when not to use it, prerequisites (e.g., lab data availability), or how it differs from get_labs or get_critical_values. The purpose is clear but the usage context is not.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
list_known_patientsA
列出本 LIS 数据集覆盖的 patient_id,供联调核对。
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
There are no annotations, so the description carries the burden. It discloses that it lists patient IDs covered by the dataset, which implies a read-only operation. However, it doesn't detail sorting, deduplication, or pagination behavior, though the output schema may cover return format.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, concise sentence that immediately states the action, scope, and purpose. Every word earns its place with no redundancy.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's simplicity (0 parameters) and the presence of an output schema, the description sufficiently explains the tool's purpose and use case. It doesn't need to elaborate on return values, as that is covered by the output schema.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The tool has zero parameters, so schema coverage is trivially 100%. The description doesn't need to explain parameters, and by baseline for 0-parameter tools, it gets a 4.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states '列出本 LIS 数据集覆盖的 patient_id' (list patient_ids covered by this LIS dataset), which is a specific verb+resource. It distinguishes itself from sibling tools like get_labs or get_critical_values by focusing on patient IDs rather than lab results.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description includes '供联调核对' (for joint debugging/verification), which provides a clear usage context. It doesn't explicitly exclude alternatives, but the purpose is evident and distinct from sibling tools.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
upsert_lab_resultA
新增一条检验采样。写权仅 doctor_assistant,其余 caller 返回 FORBIDDEN。
成功后 recommend_reevaluate=true,编排层须据此触发风险规则重评。 write_mode=False 为回滚模式,只校验不落盘。
| Name | Required | Description | Default |
|---|---|---|---|
| lab | Yes | ||
| caller | Yes | ||
| patient_id | Yes | ||
| write_mode | No |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden of behavioral disclosure. It reveals permission enforcement (FORBIDDEN for non-doctor_assistant), the side effect of setting recommend_reevaluate=true, and the rollback behavior of write_mode=False. This is comprehensive for the tool's core behaviors.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is brief, with the purpose in the first sentence and key behavioral notes in the second. Every sentence adds value, and the structure is clean.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given that an output schema exists, return values need no explanation. The description covers permission, success side effects, and rollback mode, but lacks guidance on preconditions (e.g., patient existence) and does not reference sibling tools for read alternatives. It's adequate for most usage, but not fully complete.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 0%, so the description must compensate. It does explain write_mode's rollback behavior and implies caller is permission-tied, but it doesn't describe patient_id or the lab object structure beyond '新增一条检验采样'. Partially compensates but has gaps.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description explicitly states '新增一条检验采样' (add a new lab sample), which clearly identifies the operation as creating/upserting a lab result. It distinguishes from sibling tools by being the only write operation among read/list tools.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides clear context: it specifies that only doctor_assistant has write permissions, implying usage is restricted to that caller. It also explains the rollback mode for validation, but it doesn't explicitly mention alternatives or when not to use. Still, it gives sufficient context for an orchestration layer.
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.
5 tool updates
v0.1.0- First observed
get_critical_values - First observed
get_lab_trend - First observed
get_labs - First observed
list_known_patients - First observed
upsert_lab_result
TDQS
Scored across 5 tools
Each tool targets a distinct operation: one write (upsert_lab_result), one patient listing (list_known_patients), and three distinct read views (get_labs for all panels, get_critical_values for urgent flags, get_lab_trend for single-analyte time series). No two tools overlap in purpose; the descriptions clearly separate them.
All tool names follow a consistent snake_case verb_noun pattern: upsert_lab_result, list_known_patients, get_labs, get_critical_values, get_lab_trend. The verbs (upsert, list, get) are appropriate for their actions, and the nouns are descriptive and consistent.
Five tools is a well-scoped size for a LIS MCP server. It covers the essential operations—write, patient lookup, general read, critical value alert, and trend analysis—without unnecessary redundancy or overwhelming the agent.
The tool set covers the core LIS lifecycle: inserting/updating results, retrieving patient panels, accessing critical values, and analyzing trends. The only minor gaps are lack of a delete operation and no granular single-result fetch by ID, but these are likely intentional and not critical for typical workflows.
Maintenance
Related MCP Connectors
MCP server for US nursing facility search and ownership lookup (NursingHomeDatabase).
MCP server for medicare-coverage
MCP server for querying and analyzing data from ad platforms, analytics tools, and spreadsheets
Related MCP Servers
- AlicenseAqualityCmaintenanceMock MCP server for pediatric CKD risk warning, enabling patient biochemical trend retrieval, deterministic risk rule evaluation, structured alert triggering, and clinical SOP lookup using simulated data.5MIT
- AlicenseAqualityBmaintenanceThis 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.13MIT
- FlicenseAqualityBmaintenanceRead-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-
- FlicenseAqualityBmaintenanceMCP server for pediatric CKD nutrition and food calculations, enabling energy/protein targets, food nutrient lookup, substitutions, meal summaries, and drug-nutrient interaction checks.8-