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
- 01Nine trial-design tools
- 02Phase 2 and Phase 3 designs
- 03Endpoint design calculations
- 04Multi-hypothesis designs
- 05Meta-design calculations
Use cases
- 01Design a confirmatory clinical trial
- 02Calculate endpoint design parameters
- 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.
npx -y clinical-trial-designDESIGNR_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.
Tools
9Saved tool list · updated 2w ago
| Parameter | Type | Required | Description |
|---|---|---|---|
| k | integer | No | Number of planned analyses including the final one. Integer in [2, 10]. |
| sfl | any | No | Alpha-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. |
| sfu | enum | No | Alpha-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 |
| alpha | number | No | Type I error rate. For a standard two-sided 0.05 test use 0.025 with sided = 2. |
| power | number | No | 1 - beta. Targeted power of the test (default 0.9). |
| sided | enum | No | 1 = 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 |
| sflpar | number | No | Numeric parameter for HSD / Power lower sf. |
| sfupar | number | No | Numeric parameter for HSD / Power upper sf. |
| timing | array | No | Information fractions at each analysis, length k, strictly increasing in (0,1], last = 1. Defaults to equal spacing 1/k, 2/k, ..., 1. |
| ni_margin | number | No | Non-inferiority margin on the risk-difference scale. Required when comparison='non-inferiority'. |
| p_control | number | Yes | Event rate in the control arm (0,1). |
| test_type | integer | No | gsDesign test.type. 1 = efficacy-only, 2 = symmetric efficacy+futility, 3 = non-binding futility, 4 = binding futility, 5/6 = same with lower beta-spending. |
| comparison | enum | No | Hypothesis type. 'superiority' (default) tests for a difference; 'non-inferiority' requires ni_margin; 'equivalence' requires equiv_margin.superiority | non-inferiority | equivalence |
| operational | object | No | Optional 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_rate | number | No | |
| operational.accrual_duration | number | No | |
| operational.follow_up_duration | number | No | |
| operational.total_trial_duration | number | No | |
| p_treatment | number | Yes | Event rate in the treatment arm (0,1). |
| design_class | enum | No | Design 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_margin | number | No | Two-sided equivalence margin (TOST). Required when comparison='equivalence'. Fixed-sample only. |
| allocation_ratio | number | No | Treatment / control allocation ratio. 1 = balanced 1:1. |
Details
From the project READMEclinical-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 toRscriptif not onPATH.DESIGNR_LAUNCHER— full path tolauncher.Rif 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
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.