mcpField
C
clinical-trial-design

clinical-trial-design

Local
github.com/wei-ai-labHealth3Updated 25w ago

About clinical-trial-design

A TypeScript MCP server for clinical-trial teams that provides Phase 2 and Phase 3 confirmatory design calculations through the ClinicalTrialDesign R package. Its nine tools cover endpoint, multi-hypothesis, and meta designs.

Key features

  1. 01Nine trial-design tools
  2. 02Phase 2 and Phase 3 designs
  3. 03Endpoint design calculations
  4. 04Multi-hypothesis designs
  5. 05Meta-design calculations

Use cases

  1. 01Design a confirmatory clinical trial
  2. 02Calculate endpoint design parameters
  3. 03Assess multi-hypothesis designs

MCP support

Exposes nine clinical-trial design tools to MCP clients over stdio. Each tool call invokes Rscript to run the underlying R package.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

mcp.json · Universal config
{
"mcpServers": {
"wei-ai-lab-clinical-trial-design": {
"command": "npx",
"args": [
"-y",
"clinical-trial-design"
],
"env": {
"DESIGNR_RSCRIPT": "<DESIGNR_RSCRIPT>",
"DESIGNR_LAUNCHER": "<DESIGNR_LAUNCHER>"
}
}
}
}
Run commandnpx -y clinical-trial-design
Environment variables to set
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.

Local servers need a runtime on your machine (e.g. Node.js 18+). Config file locations differ by client; see your client’s docs.

Packages
npmclinical-trial-design0.0.12

Tools

9

Saved tool list · updated 2w ago

ParameterTypeRequiredDescription
kintegerNoNumber of planned analyses including the final one. Integer in [2, 10].
sflanyNoAlpha-spending function. OF = O'Brien-Fleming, Pocock = Pocock, HSD = Hwang-Shih-DeCani (needs sfupar), Power = power family (needs sfupar), LDOF / LDPocock = Lan-DeMets approximations (the standard), 'none' disables.
sfuenumNoAlpha-spending function. OF = O'Brien-Fleming, Pocock = Pocock, HSD = Hwang-Shih-DeCani (needs sfupar), Power = power family (needs sfupar), LDOF / LDPocock = Lan-DeMets approximations (the standard), 'none' disables.OF | Pocock | HSD | Power | LDOF | LDPocock | none
alphanumberNoType I error rate. For a standard two-sided 0.05 test use 0.025 with sided = 2.
powernumberNo1 - beta. Targeted power of the test (default 0.9).
sidedenumNo1 = one-sided test (default), 2 = two-sided. Many modern designs use sided = 1 with alpha = 0.025 to match the two-sided 0.05 convention.1 | 2
sflparnumberNoNumeric parameter for HSD / Power lower sf.
sfuparnumberNoNumeric parameter for HSD / Power upper sf.
timingarrayNoInformation fractions at each analysis, length k, strictly increasing in (0,1], last = 1. Defaults to equal spacing 1/k, 2/k, ..., 1.
ni_marginnumberNoNon-inferiority margin on the risk-difference scale. Required when comparison='non-inferiority'.
p_controlnumberYesEvent rate in the control arm (0,1).
test_typeintegerNogsDesign test.type. 1 = efficacy-only, 2 = symmetric efficacy+futility, 3 = non-binding futility, 4 = binding futility, 5/6 = same with lower beta-spending.
comparisonenumNoHypothesis type. 'superiority' (default) tests for a difference; 'non-inferiority' requires ni_margin; 'equivalence' requires equiv_margin.superiority | non-inferiority | equivalence
operationalobjectNoOptional operational kernel inputs. Supply any 0-4 of {accrual_rate, accrual_duration, follow_up_duration, total_trial_duration}; the solver fills in the missing values from rate*duration = N and A + F = T (plus target_events for survival). Result is attached as result.operational with audit fields (given, derived).
operational.accrual_ratenumberNo
operational.accrual_durationnumberNo
operational.follow_up_durationnumberNo
operational.total_trial_durationnumberNo
p_treatmentnumberYesEvent rate in the treatment arm (0,1).
design_classenumNoDesign class. 'fixed' = single final analysis; 'group-sequential' = interim looks with alpha-spending. Group-sequential params (k, timing, sfu/sfl, test_type) are ignored when design_class = 'fixed'.fixed | group-sequential
equiv_marginnumberNoTwo-sided equivalence margin (TOST). Required when comparison='equivalence'. Fixed-sample only.
allocation_rationumberNoTreatment / control allocation ratio. 1 = balanced 1:1.

Details

From the project README

clinical-trial-design MCP server

TypeScript MCP server that exposes the ClinicalTrialDesign R package as 9 trial-design tools over stdio (3 endpoint + 3 multi-hypothesis + 3 meta). One Rscript subprocess per tool call, JSON roundtrip, ~300 ms per call + R compute. Covers Phase 2 and Phase 3 confirmatory designs.

Published to npm as clinical-trial-design and to the official MCP registry as io.github.wei-ai-lab/clinical-trial-design.

Tools

See the top-level README for the full tool surface, SMOKE.md for the 18-prompt smoke matrix, and PUBLISH.md for the npm + registry publish steps.

Build

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)

The server is wired from the top-level .claude-plugin/plugin.json:

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

Smoke pass

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

Expected: 18 pass / 0 fail / 18 total. The R sources are loaded directly by r/inst/launcher.R (or ../r-package/ClinicalTrialDesign/inst/launcher.R in dev); no remotes::install_local step required.

Environment

  • DESIGNR_RSCRIPT — full path to Rscript if not on PATH.
  • DESIGNR_LAUNCHER — full path to launcher.R if you need to override the default. Wire-format identifier preserved as a stability commitment (see API_STABILITY.md).

Layout

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

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.