Demrisk — Clinical Dementia Risk Assessment Agent
Inspiration
The world is getting older. Global life expectancy has increased by more than $20$ years since 1960, and by 2050, the number of people aged $60$ and over is projected to reach $2.1$ billion — more than double the figure in 2015. As a psychologist, this demographic I found this shift one of the greatest achievements of modern medicine, but it comes with a profound challenge: as people live longer, the prevalence of age-related conditions rises sharply, and dementia sits at the top of that list.
Today, approximately $55$ million people worldwide live with dementia. Every $3$ seconds, a new case is diagnosed. By 2050, that number is expected to reach $139$ million. The economic cost is already staggering — over $\$1.3$ trillion per year globally — but the human cost is immeasurable: loss of identity, loss of independence, and an enormous burden on families and caregivers.
What makes this particularly painful is that dementia is not entirely inevitable. Research consistently shows that up to $40\%$ of dementia cases may be preventable or delayable through early identification and targeted intervention. The problem is not a lack of knowledge about risk factors — age, cardiovascular health, lifestyle, genetics, and socioeconomic status are all well-documented contributors. The problem is that this knowledge rarely reaches the clinician at the right moment, for the right patient, in a usable form.
Primary care physicians see thousands of patients per year. They hold the data — blood pressure readings, cholesterol levels, medication histories, diagnoses — that together paint a picture of a patient's dementia trajectory. But synthesising that data into a meaningful risk estimate, in real time, during a consultation, is beyond what any busy clinician can reasonably do manually.
Demrisk was built to close that gap. Not to replace the clinician, but to sit beside them — quietly reading the patient's existing record, computing a validated risk score in seconds, and surfacing the information that could change the conversation: "This patient is at high risk. Here are the modifiable factors. Here is what you can do today."
A longer life should mean a better life. Early dementia risk assessment is one of the most powerful tools we have to make that possible — and every patient deserves access to it, regardless of whether their doctor has time to calculate a risk score by hand.
$$ \text{Better data} + \text{right moment} + \text{right clinician} = \text{earlier intervention} = \text{better quality of life} $$
What It Does
Demrisk is a clinical decision support agent that computes a validated dementia risk score from patient medical records. It operates as a specialized sub-agent within the Promptopinion.ai healthcare platform, accessible to clinicians through the Prompt.ai interface.
When a clinician selects a patient, Demrisk analyses their existing medical data and returns:
- A numeric risk score from $0$ to $100$
- A risk category: Low $(0\text{–}33)$, Moderate $(34\text{–}66)$, or High $(67\text{–}100)$
- The top 3 contributing risk factors identified from the patient's record
- A clinical recommendation for the next step
- A disclaimer confirming the output is for decision support only and does not constitute a diagnosis
The scoring methodology is based on the validated Dementia Risk Score (DRS) published by Hippisley-Cox et al. in BMC Medicine (2016), developed on over $1{,}000{,}000$ primary care patients in the UK. It evaluates age, sex, BMI, blood pressure, cholesterol, smoking status, history of stroke or TIA, atrial fibrillation, diabetes, depression, alcohol misuse, and socioeconomic deprivation.
How I Built It
The Problem I Solved First
Before building the actual solution, we encountered a critical infrastructure challenge. Promptopinion.ai uses Google Gemini Free Tier as its underlying LLM provider, which imposes a hard limit of $15$–$20$ requests per minute shared across all platform users. Every time the external agent on Prompt.ai consulted Demrisk, the system returned a 429 quota exceeded error, making the agent completely unusable in a real clinical workflow.
The Architecture Solution
To work around this limitation without leaving the Promptopinion platform, Virginia Neacsu implemented a custom MCP (Model Context Protocol) server as an external tool layer:
- Prompt.ai sends patient data to the Demrisk agent on Promptopinion.
- Demrisk calls an MCP tool — a lightweight Node.js server deployed on Render.com.
- The server forwards the data to the Groq API, running Llama 3.3 70B — free of charge and without strict rate limits.
- The computed score is returned through the MCP tool back to Demrisk, and finally to the clinician.
The Tech Stack
| Component | Technology |
|---|---|
| MCP Server | Node.js + Express |
| Protocol | JSON-RPC 2.0 |
| Hosting | Render.com (free tier) |
| LLM | Groq API — Llama 3.3 70B |
| Version Control | GitHub |
| Platform | Promptopinion.ai |
| Transport | Streamable HTTP |
The Clinical Intelligence
The predicted $5$-year dementia risk is computed as:
$$ \text{Risk}(\%) = 100 \times \left[1 - S^{\exp(P)}\right] $$
where $P$ is a linear combination of the weighted risk factors and $S$ is the baseline survival function at $5$ years.
The A2A Workflow
The system enforces a strict one-directional data flow to prevent recursive loops:
$$ \text{Prompt.ai} \xrightarrow{\text{patient data}} \text{Demrisk} \xrightarrow{\text{MCP call}} \text{Groq API} \xrightarrow{\text{score}} \text{Prompt.ai} $$
Demrisk is configured as a passive agent — it only receives data, computes a score, and returns it. It never initiates calls to other agents or external services.
Challenges We Ran Into
1. Quota exhaustion on the Free Tier
The most significant challenge was the 429 quota exceeded error from Google Gemini Free Tier. The limit of $15$–$20$ requests per minute, shared across all Promptopinion users, made the agent fail after processing just $2$ patients. Solving this required designing an entirely new infrastructure layer — the MCP server — that reroutes LLM calls away from the platform's internal quota.
2. MCP protocol implementation from scratch
Promptopinion expects a fully compliant MCP server implementing the JSON-RPC 2.0 protocol. Building this without prior experience required multiple iterations — from a simple REST API to a full MCP implementation with initialize, tools/list, and tools/call endpoints.
3. Platform limitations Promptopinion only supports Google Gemini Free Tier as a provider and does not allow connecting alternative LLM providers directly. Every workaround had to be implemented externally and connected back via the MCP layer.
4. Preventing A2A recursive loops In Agent-to-Agent architectures, there is a real risk of agents calling each other in infinite loops. Designing Demrisk as a strictly passive agent — one that never initiates outbound calls — required careful prompt engineering and architectural discipline.
Accomplishments That We're Proud Of
- Successfully built and deployed a fully functional A2A clinical agent that computes validated dementia risk scores from real patient data.
- Implemented a custom MCP server from scratch — without prior experience in the MCP protocol — that bridges Promptopinion with an external free LLM provider.
- Grounded the agent in peer-reviewed clinical methodology (DRS, Hippisley-Cox et al., 2016) rather than generic LLM reasoning.
- Achieved a working end-to-end demo where a clinician can select a patient on Prompt.ai and receive a structured dementia risk assessment in seconds.
- Solved a real infrastructure problem (quota exhaustion) with a zero-cost architectural solution.
What We Learned
- MCP is powerful but unforgiving. The Model Context Protocol requires strict adherence to JSON-RPC 2.0 — any deviation causes silent failures that are difficult to debug without detailed logs.
- Free Tier constraints shape architecture. Building within the limits of free infrastructure forces creative solutions that often turn out to be more robust than paid alternatives.
- Clinical AI requires grounding. Generic LLM reasoning is not sufficient for medical risk assessment. Anchoring the agent in a validated, published methodology was essential for clinical credibility.
- A2A workflows need explicit loop prevention. Without deliberate design choices — passive agent role, one-directional data flow — recursive loops can emerge naturally from agent-to-agent communication patterns.
- Platform lock-in is real. When a platform controls your LLM provider, your ability to optimise cost and performance is severely limited. External tool layers via MCP are a viable escape route.
What's Next for Demrisk
Short term:
- Upgrade the Groq API integration to use a model with a larger context window to support longer, more complex patient records.
- Add support for the 80–95 years age group model from the DRS methodology, which uses different risk weightings than the 60–79 years model currently implemented.
- Implement structured FHIR input so Demrisk can read directly from standardised electronic health records without manual data entry.
Medium term:
- OIn the mental healt field I +will expand beyond dementia to cover related neurodegenerative conditions — Parkinson's disease risk, mild cognitive impairment screening, and vascular dementia subtype differentiation. Also -she will create a similar agent for depression and connect the two,
- Build a longitudinal tracking layer: instead of a one-time score, Demrisk would track risk evolution over multiple consultations and flag patients whose score is increasing.
- Publish the MCP server as an open-source template for other clinical decision support agents built on the Promptopinion platform.
Long term:
- Validate Demrisk's outputs against a real patient cohort to measure concordance with specialist diagnoses.
- Pursue CE marking as a Class IIa medical device under EU MDR 2017/745 for use as a clinical decision support tool in primary care settings.
- Integrate with Romanian national health record systems to enable population-level dementia risk screening.
Reference: Hippisley-Cox J, et al. Predicting dementia risk in primary care: development and validation of the Dementia Risk Score using routinely collected data. BMC Medicine. 2016;14:6. doi:10.1186/s12916-016-0549-8

Log in or sign up for Devpost to join the conversation.