mcpField
C
clinical-trial-design

clinical-trial-design

本地服务
github.com/wei-ai-lab健康医疗325 周前更新

关于 clinical-trial-design

这是面向临床试验团队的 TypeScript MCP 服务,通过 ClinicalTrialDesign R 包提供 Phase 2 和 Phase 3 确证性设计计算,涵盖终点、多假设和 Meta 设计。

主要功能

  1. 01提供 9 种试验设计工具
  2. 02支持 Phase 2 和 Phase 3 设计
  3. 03计算终点设计参数
  4. 04支持多假设设计
  5. 05支持 Meta 设计计算

适用场景

  1. 01设计确证性临床试验
  2. 02计算终点设计参数
  3. 03评估多假设设计

MCP 相关

通过 stdio 向 MCP 客户端提供 9 种临床试验设计工具。每次工具调用都会运行 Rscript,以执行底层 R 包。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

mcp.json · 通用配置
{
"mcpServers": {
"wei-ai-lab-clinical-trial-design": {
"command": "npx",
"args": [
"-y",
"clinical-trial-design"
],
"env": {
"DESIGNR_RSCRIPT": "<DESIGNR_RSCRIPT>",
"DESIGNR_LAUNCHER": "<DESIGNR_LAUNCHER>"
}
}
}
}
启动命令npx -y clinical-trial-design
需要配置的环境变量
DESIGNR_RSCRIPTOptional override for the Rscript binary path. Defaults to whatever 'Rscript' resolves to on the system PATH. Set this if R isn't on PATH or you need a specific R version.
DESIGNR_LAUNCHEROptional override for the R launcher path (the inst/launcher.R that sources the R sources and dispatches the JSON). Defaults to the bundled launcher. Set this only if you need to use a non-bundled R source tree.

本地服务需要在你的电脑上安装运行环境(如 Node.js 18+)。各客户端的配置文件位置不同,请参考客户端文档。

安装包
npmclinical-trial-design0.0.12

工具

9

收录的工具列表 · 更新于 2 周前

参数类型必填说明
kinteger否计划分析次数,包括最终分析。取值为 [2, 10] 内的整数。
sflany否Alpha-spending 函数。OF = O'Brien-Fleming,Pocock = Pocock,HSD = Hwang-Shih-DeCani(需要 sfupar),Power = power family(需要 sfupar),LDOF / LDPocock = Lan-DeMets 近似(标准选项),'none' 表示禁用。
sfuenum否Alpha-spending 函数。OF = O'Brien-Fleming,Pocock = Pocock,HSD = Hwang-Shih-DeCani(需要 sfupar),Power = power family(需要 sfupar),LDOF / LDPocock = Lan-DeMets 近似(标准选项),'none' 表示禁用。OF | Pocock | HSD | Power | LDOF | LDPocock | none
alphanumber否I 类错误率。标准双侧 0.05 检验使用 sided = 2 时,请设为 0.025。
powernumber否1 - beta。检验的目标功效(默认值为 0.9)。
sidedenum否1 = 单侧检验(默认值),2 = 双侧检验。许多现代设计使用 sided = 1 和 alpha = 0.025,以匹配双侧 0.05 的惯例。1 | 2
sflparnumber否HSD / Power 下边界 sf 的数值参数。
sfuparnumber否HSD / Power 上边界 sf 的数值参数。
timingarray否各次分析的信息比例,长度为 k,在 (0,1] 中严格递增,最后一个值为 1。默认等间距:1/k、2/k、...、1。
ni_marginnumber否风险差尺度上的非劣效界值。comparison='non-inferiority' 时必填。
p_controlnumber是对照组的事件率 (0,1)。
test_typeinteger否gsDesign test.type。1 = 仅疗效,2 = 对称疗效+无效性,3 = 非约束无效性,4 = 约束无效性,5/6 = 相同设置并采用较低的 beta 消费。
comparisonenum否假设类型。'superiority'(默认值)检验差异;'non-inferiority' 需要 ni_margin;'equivalence' 需要 equiv_margin。superiority | non-inferiority | equivalence
operationalobject否可选的操作性内核输入。提供 {accrual_rate, accrual_duration, follow_up_duration, total_trial_duration} 中任意 0–4 项;求解器会根据 rate*duration = N 和 A + F = T(生存分析还包括 target_events)填入缺失值。结果附加为 result.operational,并包含审计字段(given、derived)。
operational.accrual_ratenumber否
operational.accrual_durationnumber否
operational.follow_up_durationnumber否
operational.total_trial_durationnumber否
p_treatmentnumber是治疗组的事件率 (0,1)。
design_classenum否设计类别。'fixed' = 仅进行一次最终分析;'group-sequential' = 采用 alpha-spending 的中期分析。design_class = 'fixed' 时,group-sequential 参数(k、timing、sfu/sfl、test_type)将被忽略。fixed | group-sequential
equiv_marginnumber否双侧等效界值(TOST)。comparison='equivalence' 时必填。仅适用于固定样本量。
allocation_rationumber否治疗组 / 对照组分配比。1 = 1:1 均衡分配。

详细介绍

clinical-trial-design MCP 服务

TypeScript MCP 服务,通过 stdio 将 ClinicalTrialDesign R 包提供为 9 个试验设计工具(3 个终点、3 个多假设和 3 个荟萃分析工具)。每次工具调用都会启动一个 Rscript 子进程,进行 JSON 往返处理;每次调用约耗时 300 毫秒,另加 R 计算时间。涵盖 II 期和 III 期确证性设计。

已发布至 npm,包名为 clinical-trial-design;也已发布至官方 MCP 注册表,标识符为 io.github.wei-ai-lab/clinical-trial-design。

工具

完整的工具列表请参阅顶层 README,18 条提示词的冒烟测试矩阵请参阅 SMOKE.md,npm 和注册表的发布步骤请参阅 PUBLISH.md。

构建

npm install                  # pulls dev dependencies (esbuild, typescript)
npm run build                # esbuild bundle → dist/index.js (the publish artifact)
npm run build:dev            # tsc → build/*.js per-file (used by the smoke script)

该服务通过顶层 .claude-plugin/plugin.json 接入:

"mcpServers": { "clinical-trial-design": { "command": "node", "args": ["mcp-server/dist/index.js"] } }

冒烟测试

npm run build:dev            # required: smoke imports from build/r-bridge.js
node scripts/smoke.mjs

预期结果:18 pass / 0 fail / 18 total。R 源文件由 r/inst/launcher.R 直接加载(开发环境中则由 ../r-package/ClinicalTrialDesign/inst/launcher.R 加载);无需执行 remotes::install_local。

环境

  • DESIGNR_RSCRIPT — 如果 Rscript 不在 PATH 中,请设置为其完整路径。
  • DESIGNR_LAUNCHER — 如果需要覆盖默认值,请设置为 launcher.R 的完整路径。为保持稳定性承诺,保留了线格式标识符(参见 API_STABILITY.md)。

目录结构

src/
  index.ts                         # McpServer + stdio transport; registers 9 tools
  r-bridge.ts                      # spawns Rscript, JSON roundtrip, 60s timeout
  tools/
    common-schemas.ts              # shared zod fragments + ReasoningChainSchema
    design-binary.ts               # endpoint design (3 tools)
    design-continuous.ts
    design-survival.ts
    design-co-primary.ts           # multi-hypothesis (3 tools)
    design-multi-population.ts
    design-graphical-multiplicity.ts
    validate-benchmark.ts          # meta (3 tools)
    verify-design.ts
    design-report.ts
scripts/
  smoke.mjs                        # programmatic 18-prompt smoke pass
r/                                 # R sources staged for the npm tarball
  R/*.R
  inst/launcher.R
  DESCRIPTION
  NAMESPACE

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。