Clinical Trials MCP Server
This MCP server gives an LLM structured, keyless access to the public ClinicalTrials.gov API v2 through four typed tools.
search_trials— Find studies by condition, intervention, location, phase, or status; paginated (1–50 per page) with total count and a next-page token.get_trial— Fetch one study by NCT id in a normalized shape: titles, status, phases, conditions, interventions, eligibility summary with full criteria text, location counts, sponsor, enrollment, and key dates.eligibility_check— Check a patient's age and sex against a study's structured criteria, returningmeets/does_not_meet/cannot_determinewith a plain-language reason per check, plus the unparsed free-text criteria for human review.recruiting_sites— List a study's actively recruiting sites, filterable by city, state, or country, with facility and contact details where the registry provides them.
Caveats: only age and sex are evaluated; free-text criteria are never interpreted, and the verdict is not a final eligibility decision or medical advice.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Clinical Trials MCP Server Find recruiting Phase 3 trials for breast cancer in Texas"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Clinical Trials MCP Server
An MCP (Model Context Protocol) server that gives an LLM structured access to the public ClinicalTrials.gov API v2. It wraps the registry in four typed tools: search studies, read one study in a normalized shape, check the deterministic part of a study's eligibility criteria for a patient, and list the sites that are actively recruiting. The registry needs no API key, and neither does this server.
Problem
Clinical trial data is public and rich, but it sits behind a registry API that models cannot use directly. Eligibility is the risky part: a tool that guesses at criteria it cannot evaluate can mislead a patient or a researcher.
Related MCP server: Clinical Trials MCP Server
Approach
A FastMCP server over the public ClinicalTrials.gov API v2, with four tools: search trials, fetch one trial, check eligibility from a patient profile, and list recruiting sites. Eligibility is split on purpose. Deterministic fields (age, sex) are decided by the server. The inclusion and exclusion text is returned for the calling model to judge, and the server says which is which. The server runs over stdio for local clients and streamable HTTP for hosted use, with a short TTL cache on upstream calls.
Results
73 tests, 92 percent coverage, ruff clean, green CI
Released as v1.0.0, with a container image published to GHCR: https://github.com/users/Sairajiv-13/packages/container/package/clinical-trials-mcp-server
No API key is needed at any point; the upstream API is public
Tech stack
Python, FastMCP, httpx, pydantic, Docker, GitHub Actions
Architecture
The tool layer is thin. Each tool builds query parameters, calls one async client, and parses the response into a pydantic model. Everything except server.py is plain Python with no framework dependency, so the parsing and eligibility logic can be tested without starting a server.
flowchart LR
Host["MCP host (LLM)"] -->|stdio or HTTP| Server["FastMCP server<br/>server.py"]
Server --> Client["TrialsClient<br/>client.py"]
Client --> Cache[("In-memory TTL cache")]
Client -->|HTTPS, retries on 5xx| API["ClinicalTrials.gov<br/>API v2"]
Server --> Models["Parsers and models<br/>models.py"]
Server --> Elig["Eligibility checks<br/>eligibility.py"]client.py: async httpx client with a timeout, bounded retries on 5xx and network errors, and a small in-memory TTL cache. Upstream failures become typed errors with short messages written for the calling model.models.py: pydantic output models and the parsers that flatten the API's nestedprotocolSectionmodules into them.eligibility.py: age and sex checks only. See the design decisions below for why the scope stops there.errors.py: the error types the client raises, kept separate so tool code never formats raw HTTP failures.
Tools
search_trials
Search the registry. At least one filter should be given; results come back with a total count and a page token for the next page. Page size is capped at 50 to keep responses small enough for a model context.
Input | Type | Notes |
| string, optional | Condition or disease, matched by the API's own search |
| string, optional | Drug, device, or procedure name |
| string, optional | City, state, or country text matched against study sites |
| list of string, optional | For example |
| list of string, optional | For example |
| int | 1 to 50, default 10 |
| string, optional | From a previous result's |
Output: total_count, returned_count, page_size, next_page_token, and trials, where each trial has an NCT id, title, status, phases, conditions, intervention names, lead sponsor, and key dates.
get_trial
Fetch one study by NCT number and return it in a normalized, readable shape.
Input | Type | Notes |
| string, required | For example |
Output: titles, status, a short summary, phases, conditions, interventions with types and descriptions, an eligibility summary including the full criteria text, total and recruiting location counts, lead sponsor and collaborators, enrollment, and start, completion, and last update dates.
eligibility_check
Check the deterministic eligibility criteria of a study for one patient.
Input | Type | Notes |
| string, required | Study to check against |
| number, optional | Patient age in years (0.5 means 6 months) |
| string, optional |
|
Output: a verdict of meets, does_not_meet, or cannot_determine, one result per check with a plain-language reason, and the study's full free-text criteria for human review. Only age and sex are checked, because those are the fields the registry reports in structured form. The verdict is not a final eligibility decision.
recruiting_sites
List the sites of a study that are currently recruiting, with contact details where the registry provides them.
Input | Type | Notes |
| string, required | Study to list sites for |
| string, optional | Only sites in this city |
| string, optional | Only sites in this state or region |
| string, optional | Only sites in this country |
Output: the study status, how many sites the registry lists in total, and the matching sites with facility, city, state, country, status, and contact name, phone, and email where listed. A site with no status of its own counts as recruiting when the study overall is recruiting, which matches how the registry presents it.
Quickstart
Install and run locally (Python 3.11 or newer):
git clone https://github.com/Sairajiv-13/clinical-trials-mcp-server.git
cd clinical-trials-mcp-server
make setup
make test # run the offline test suite
make run # serve over stdiomake run starts the server on stdio. To connect a desktop MCP host, point it at the installed command:
{
"mcpServers": {
"clinical-trials": {
"command": "/path/to/clinical-trials-mcp-server/.venv/bin/clinical-trials-mcp"
}
}
}Run it over HTTP with Docker instead:
docker build -t clinical-trials-mcp-server .
docker run --rm -p 8000:8000 clinical-trials-mcp-serverThe HTTP server listens on port 8000 at the /mcp path. Without Docker, make run-http does the same on 127.0.0.1.
A minimal client that lists the tools and runs one search lives in examples/minimal_client.py:
.venv/bin/python examples/minimal_client.pyConfiguration
All configuration is through environment variables. Defaults work against the public API with nothing set. See .env.example.
Variable | Default | Meaning |
|
| API base URL |
|
| Per-request timeout |
|
| How long a successful GET is cached; 0 disables the cache |
|
| Extra attempts after a 5xx response or a network error |
Testing
make testThe suite runs fully offline. HTTP calls are mocked with respx against response fixtures built from the documented API v2 schema, so no test needs network access or the live registry. The suite currently has 73 tests at 92% coverage of the package, covering search normalization and the page size cap, study parsing, the eligibility cases (below minimum, above maximum, sex mismatch, missing data), site filtering, and the failure paths (upstream 500s, retries, timeouts, unknown NCT numbers).
Design decisions
Two architecture decision records live in docs/adr:
ADR 0001: why FastMCP, and why the server ships both stdio and HTTP transports.
ADR 0002: why eligibility checks stop at the structured fields and return the free-text criteria for human review instead of trying to interpret them.
Limitations
Eligibility free text is returned, never parsed. Diagnosis requirements, lab thresholds, and prior treatment rules are in that text, so a
meetsverdict means the patient passes the age and sex fields only.Registry data is maintained by sponsors and can lag behind a study's actual state. Site recruiting status in particular changes without notice.
The ClinicalTrials.gov API is a public service with rate limits and no uptime commitment. The client's retries and cache reduce load, but sustained heavy use should be discussed with the registry, not worked around.
This server reads public registry data only. It does not handle protected health information, and the tools are not a substitute for a study team's eligibility review. Nothing here is medical advice.
License
MIT. Copyright (c) 2026 Sai Rajiv Nagula. See LICENSE.
Available Tools
4 toolseligibility_checkEligibility CheckA
Check the deterministic eligibility criteria of a study for a patient.
Only age range and sex are checked, because those are the fields the registry reports in structured form. The verdict is 'meets', 'does_not_meet', or 'cannot_determine', with a reason per check. The full free-text criteria are included in the result for human review; they are never interpreted by this tool, and the verdict is not a final eligibility decision.
Inputs: nct_id (required), age, sex. Returns: Outcome of the deterministic part of an eligibility check.
get_trialGet TrialA
Get one study by NCT number, normalized into a readable structure.
Returns titles, status, phases, conditions, interventions, an eligibility summary (including the full criteria text), location counts, sponsor, enrollment, and key dates.
Inputs: nct_id (required). Returns: One study, normalized into a readable structure.
recruiting_sitesRecruiting SitesA
List the sites of a study that are currently recruiting.
A site counts as recruiting when the registry gives it a RECRUITING status, or when it has no status of its own and the study overall is RECRUITING. Contact details are included where the registry lists them for a site.
Inputs: nct_id (required), city, state, country. Returns: sites, nct_id, study_status, sites_returned, +1 more
search_trialsSearch TrialsA
Search ClinicalTrials.gov for studies matching the given filters.
At least one filter should be supplied; an unfiltered search returns the whole registry one page at a time. Ordering is whatever the API returns for the query; this tool does not re-sort.
Inputs: phases, location, statuses, condition, +3 more. Returns: One page of search results.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool targets a clearly distinct operation: discovery (search_trials), single-record retrieval (get_trial), structured eligibility verdict (eligibility_check), and site listings (recruiting_sites). The search-vs-get boundary is explicit (filters vs NCT number), so an agent can select unambiguously.
search_trials and get_trial follow a clean verb_noun pattern, but eligibility_check and recruiting_sites are noun-heavy phrases rather than verb-led. All are snake_case and readable, with only a minor stylistic deviation.
Four tools is a focused, cohesive set for a read-only clinical trials lookup server, with no redundant or filler tools. It is slightly thin—no location- or intervention-based filtering beyond the search tool's filters—but each tool earns its place.
The surface covers the natural read-only lifecycle: find studies, inspect a study, check structured eligibility, and locate recruiting sites. Since the registry is public and read-only, the absence of write operations is correct; only minor gaps (e.g. no multi-trial comparison) remain.
Maintenance
Related MCP Connectors
Clinical trial search and status from ClinicalTrials.gov
Search ClinicalTrials.gov: find studies, retrieve results, match patients to candidate trials.
Search and read ClinicalTrials.gov studies, sites and outcomes.
Provide structured access to ClinicalTrials.gov data for searching, retrieving, and analyzing clin…
Related MCP Servers
- AlicenseBqualityDmaintenanceProvides programmatic access to ClinicalTrials.gov API with 18 specialized tools for searching, analyzing, and retrieving detailed information about 400,000+ clinical trials worldwide, including filtering by condition, location, phase, sponsor, eligibility criteria, and outcomes.1720 npm4MIT
- FlicenseNot gradedqualityDmaintenanceEnables searching and retrieving detailed clinical trial information from ClinicalTrials.gov via the official API.1-
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to search and retrieve clinical trial data from ClinicalTrials.gov, supporting filters, study details, metadata, and statistics.ISC
- FlicenseNot gradedqualityDmaintenanceEnables searching clinical trials, retrieving trial details, matching patient profiles to recruiting trials, and extracting eligibility criteria from ClinicalTrials.gov.-