For the complete documentation index, see llms.txt. This page is also available as Markdown.

MCP Worked Example

Example workflow for querying via the MCP including sample responses you would get from the agent.

This example project uses a synthetic OMOP CDM dataset at two sites (1,000 patients each): the standard clinical tables and curated tables for patient_analytics (one row per patient: demographics, labs, cost, outcome flags) and survival_analysis (followup_days, event, covariates).


Step 0: Prerequisites

  1. Confirm your MCP connection:

    Example Prompt

    Confirm who I am, whether Rhino is reachable, and which projects and sites I can use.

  2. Build a semantic layer using your data dictionary, then have a subject-matter expert review it:

    Example Prompt

    Using the attached data dictionary, enrich the data schemas in my OMOP project. Set each column's type (Integer for IDs and flags, String for categories and ISO dates, Float for measures) and describe: what it is; valid values and units; the metric parameter it maps to; join key; key concept IDs. Show me the proposed schemas before creating new versions.


Step 1: Get an overview of the data

Loading dataset information into the LLM's context offers an effective initial step for enabling your agent to explore available project data.

Example Prompt

Give me an overview of my OMOP project so I can plan a COPD analysis: which tables each site holds and their row counts, and which code objects have run and what datasets they produced.

Example Output

Your OMOP project has 30 datasets —15 matching tables at each site—with no code objects, runs, or lineage.

Table Name
Site 1 Row Count
Site 2 Row Count

person

1,000

1,000

observation_period

1,000

1,000

visit_occurrence

5,122

4,844

condition_occurrence

2,133

1,798

drug_exposure

3,691

3,399

procedure_occurrence

1,752

1,619

measurement

7,000

7,000

observation

1,000

1,000

death

28

15

concept

39

39

concept_ancestor

4

4

patient_analytics

1,000

1,000

survival_analysis

1,000

1,000

multiclass_ranking_predictions

1,000

1,000

lesion_detection_predictions

1,397

1,332


Step 2: Profile the dataset

Example Prompt

Profile Site 1 patient_analytics as a Table 1: return the mean (SD) and median [IQR] for age, FEV1 % predicted and eosinophil count; n (%) for sex, treatment arm, COPD flag (detected) and outcome.

Example Output

Variable (Site 1, n = 1,000)

Summary

Age, years

mean 66.3 (SD 9.9) · median 66 [60–73]

FEV1 % predicted

mean 77.9 · median 79.3 [67.2–89.4]

Eosinophils, cells/µL

mean 230.7 · median 197.3 [115.9–308.7]

COPD (detected) / outcome

311 (31.1%) / 223 (22.3%)


Step 3: Explore across sites

Example Prompt

Compare Site 1 and Site 2 patient_analytics for age, COPD flag, outcome and FEV1 % predicted, then give me the pooled mean age.

Example Output

Variable
Site 1
Site 2

Age, mean (SD)

66.3(9.9)

60.3(9.6)

Age, median [IQR]

66 [60, 73]

60 [54, 67]

COPD flag (detected), n (%)

311 (31.1)

201 (20.1)

Outcome, n (%)

223 (22.3)

141 (14.1)

FEV1 % predicted, mean (SD)

77.9 (15.1)

81.2 (13.8)

FEV1 % predicted, median [IQR]

79.3 [67.2, 89.4]

82.4 [71.9, 90.9]

Pooled mean age is 63.3, computed from each site's aggregates. Site 1 is older and sicker, you should take that into account when building the cohort.


Step 4: Build the cohort

This is where specificity matters most. Compare a one-line request with a protocol-level one:

Example Prompt (vague)

Find older COPD patients on inhalers with exacerbations.

Example Output (vague)

"Older", "COPD", "inhalers" and "exacerbations" each hide a decision: ≥ 65 or > 65? Parent concept only or descendants too? Which drugs? How many events, and in what window? The assistant will choose for you, and the choices won't be visible. For agentic cohort building, a good prompt includes details such as:

  • Execution scope: State the project, sites, and if a code object is needed.

  • Inputs: Specify datasets, input order, join keys, and base population table.

  • Population & join rules: Detail retention rules, unmatched record handling, and output row structure.

  • Eligibility criteria: Define explicit thresholds, concept sets, date windows, and exclusions.

  • Criterion sources: Name the exact table and column for each eligibility rule.

  • Funnel logic: Separate individual eligibility flags from sequential filtering and exclusion logging.

  • Output specifications: List each required dataset, its columns, and carried-through variables.

  • Pre-execution validation: Instruct Rhino MCP to verify schemas, flag ambiguities, and show a code preview.

  • Verifiable results: Require execution status, dataset references, final cohort size, and step counts.

Example Prompt (better!)

Build a Site 1 cohort with a Python code object (run at Site 1 only).

Inputs, in slot order (all "Site 1 - ..."):

0 patient_analytics

1 condition_occurrence

2 drug_exposure

3 survival_analysis

Join on person_id. Base population: every person_id in patient_analytics, one

output row per person, including people with no condition or drug records.

Left-join survival_analysis on person_id so nobody is dropped if there is no

match; unmatched people keep missing survival columns.

Criteria, evaluated in this order (flag = 1 if met, else 0):

1. flag_age: age >= 65 (age column in patient_analytics)

2. flag_copd: condition_concept_id in {2000001000, 2000001001, 2000001002,

2000001003} in condition_occurrence (explicit list, no concept_ancestor)

3. flag_therapy: drug_concept_id in {2000002001, 2000002006} in drug_exposure

(tiotropium or triple therapy; use drug records, not treatment_arm)

4. flag_exacerbation: condition_concept_id = 2000001070 in

condition_occurrence, at least one record, any time (no date window)

Compute all four flags independently for every person. Apply the criterion

order only when calculating funnel_step and dropped_at.

Derived columns:

- funnel_step: number of consecutive criteria passed starting from criterion 1,

stopping at the first failure (0-4)

- dropped_at: first failed criterion, one of age / copd / therapy /

exacerbation / none

- in_cohort: 1 if all four flags = 1, else 0

- male: 1 if sex = "Male", 0 if "Female", missing if sex is missing

Carry these columns through into both outputs:

- from patient_analytics: age, sex, treatment_arm, fev1_percent_predicted,

eosinophil_count, outcome

- from survival_analysis: followup_days, event, current_smoker,

comorbidity_score

(use age from patient_analytics only; do not carry survival_analysis age

or its male/copd columns)

Outputs:

- output 0, named "Site 1 - COPD candidates": all persons.

Columns: person_id, flag_age, flag_copd, flag_therapy, flag_exacerbation,

funnel_step, dropped_at, in_cohort, age, sex, male, treatment_arm,

fev1_percent_predicted, eosinophil_count, outcome, followup_days, event,

current_smoker, comorbidity_score

- output 1, named "Site 1 - COPD cohort": only in_cohort = 1

rows, same columns

Before running: check that the column names and concept IDs above exist in the

Site 1 tables, then show me the code object preview and wait for my OK.

After the run: confirm completion; give the final cohort size (rows in

output 1) and the persons remaining after each funnel step.

Because every person keeps their flags, you can iterate with quick filtered counts instead of rebuilding:

Example Prompt

Using the dataset "Site 1 - COPD candidates", filter to in_cohort = 1 and count how many patients have eosinophil_count of at least 300, at least 200, and at least 150?

That returned 16, 34 and 43. Re-running with eosinophils ≥ 150 cells/µL as a final criterion gives a 43-patient cohort (23 male, 20 female).


Step 5: Show the attrition funnel

Request the attrition funnel in a separate prompt after cohort creation. This lets you visualize the filtering steps directly from the newly created datasets.

Example Prompt

Count patients by funnel_step on the Site 1 - COPD candidates dataset and plot the attrition funnel with number and percent remaining. Include eosinophil_count of at least 150 as a criteria.

Example Output


Step 6: Kaplan–Meier survival analysis

Example Prompt

Using "Site 1 - COPD cohort", run a Kaplan-Meier by sex with

time = followup_days and event = event. Plot the curves with a number-at-risk

table. Show counts under 5 as "<5".

Example Output


Step 7: Cox regression

The cox metric expects a time column, an event column and a list of covariates, and returns one β and standard error per covariate in the order given (HR = e^β):

Example Prompt

Fit a Cox model on the Site 1 - COPD cohort dataset with time_variable followup_days, event_variable event and covariates age, male, current_smoker, and comorbidity_score. Report HR, 95% CI and p per covariate, and draw a waterfall plot of the sorted log hazard ratios.

Example Output

Covariate
HR
95% CI
p

Age (per year)

1.02

0.98–1.08

0.25

Male

0.91

0.63–2.60

0.70

Current smoker

1.49

0.46–1.91

0.16

Comorbidity score (per point)

1.70

1.07–2.46

<0.05

Last updated

Was this helpful?