---
summary: find_eligible adds match-prioritized location sort + 3-stage funnel diagnostics; search/count default-filter the EnrollmentCount=99999999 sentinel; search format() lifts truncation cap when fields is explicit.
breaking: false
---

# 2.4.5 — 2026-05-03

Three findings from a 2026-05-03 test pass against realistic clinical workflows.

`clinicaltrials_find_eligible` now sorts each study's `locations[]` by match-score against the user's `location.{city,state,country}` so the patient's nearest site lands in the top 3, and a `funnel` block reports counts at three filter stages (`condition → +location → +demographics`) so callers can see where sparse results collapsed without a follow-up call.

`clinicaltrials_search_studies` and `clinicaltrials_get_study_count` now filter the upstream `EnrollmentCount=99999999` sentinel by default — `RANGE[N, MAX]` queries and `EnrollmentCount:desc` sorts no longer surface sentinel-polluted results. An `includeUnknownEnrollment: true` opt-in is available for data-quality audits.

`clinicaltrials_search_studies` `format()` lifts its per-study truncation cap when the caller passes an explicit `fields` list, and the dedup-vs-cap counter no longer reports phantom truncation when multiple array entries share a label.

## Added

- **`clinicaltrials_find_eligible`** — `funnel` block in the output schema reports `conditionMatched` (broadest), `locationMatched` (+ location), and `demographicsMatched` (full filter set; equals `totalCount`) so callers can diagnose where the filter pipeline collapsed when results are sparse. Costs two extra `searchStudies` calls (~2s additional latency at the upstream throttle). Fires on every response, not just empty ones.
- **`clinicaltrials_search_studies`** and **`clinicaltrials_get_study_count`** — `includeUnknownEnrollment: boolean` (default `false`) input parameter. Set `true` to opt out of the sentinel filter for data-quality audits or when targeting unknown-enrollment studies specifically.
- **`clinicaltrials_search_studies`** — `requestedFields` echo in the output schema. Present only when the caller passed `fields`; signals to `format()` that all requested leaves should render without the default truncation cap.

## Changed

- **`clinicaltrials_find_eligible` location surfacing** — each study's `locations[]` is now sorted in the handler by case-insensitive match-score against the user's `location.{city,state,country}` (city dominates, then state, then country; recruiting status breaks ties between geographically-equivalent sites). Both the structured payload and the `format()` markdown see the post-sort order. Resolves [#37](https://github.com/cyanheads/clinicaltrialsgov-mcp-server/issues/37).
- **`clinicaltrials_search_studies` and `clinicaltrials_get_study_count` default behavior** — studies whose `EnrollmentCount` is the upstream `99999999` sentinel ("unknown") are now filtered out unless `includeUnknownEnrollment: true`. Implemented at the service layer via an injected `AREA[EnrollmentCount]RANGE[0, 99999998]` advanced filter clause that ANDs with any caller-supplied `filterAdvanced`. Resolves [#41](https://github.com/cyanheads/clinicaltrialsgov-mcp-server/issues/41).
- **`clinicaltrials_find_eligible` and `getStudiesBatch` opt-out** — both pass `includeUnknownEnrollment: true` internally. Eligibility matching cares about who can enroll, not enrollment count quality; ID-targeted batch lookups must never silently filter the caller's selection.

## Fixed

- **`clinicaltrials_search_studies` `format()` truncation cap** — when the caller passes explicit `fields`, the per-study cap is lifted (`maxLines = Infinity`) so every requested leaf renders. The default cap remains in effect when no `fields` are passed. Resolves [#38](https://github.com/cyanheads/clinicaltrialsgov-mcp-server/issues/38).
- **`format-helpers.ts` truncation count honesty** — the per-study `… and N more fields` footer no longer counts dedup-dropped leaves as "uncovered." Pre-fix logic counted both cap-dropped and dedup-dropped leaves, lying about truncation whenever multiple array entries shared a label (e.g. 20 interventions all surfacing as `Interventions > Name`).
