The ClinicalTrials.gov MCP Server enables AI agents to programmatically access and analyze the ClinicalTrials.gov database through three core tools:
Search Studies (clinicaltrials_search_studies
) - Find clinical trials using query terms (conditions, interventions, locations, sponsors) and filters, with support for pagination, sorting, geographic filtering, and advanced Essie expression syntax.
Retrieve Study Details (clinicaltrials_get_study
) - Fetch comprehensive or summary information for specific studies by NCT ID, including protocols, eligibility criteria, outcomes, sponsors, and locations, with flexible field selection and markup format options.
Analyze Trends (clinicaltrials_analyze_trends
) - Perform statistical analysis on up to 5000 studies, aggregating data by status, country, sponsor type, or phase to identify research patterns and trends.
Key Applications:
Automate clinical research workflows and integrate trial data into AI-driven applications
Support regulatory submissions, compliance workflows, and competitive intelligence
Enable evidence-based decision making through comprehensive trial analysis
Streamline clinical trial reviews and market research
Technical Features: Built on the official ClinicalTrials.gov v2 API with robust error handling, rate limiting, data cleaning, input validation, and TypeScript type safety for reliable programmatic access.
Provides the project repository on GitHub for access to source code and documentation.
Uses Hono as a high-performance HTTP server featuring session management, CORS, and IP-based rate limiting.
Supports returning clinical trial data in markdown format for improved readability in AI responses.
Requires Node.js (>=18.0.0) as the runtime environment for the MCP server.
Distributes the server via npm package management system, allowing for easy installation.
Uses Prettier for consistent code formatting during development.
Built with TypeScript for type safety and robust error handling when interacting with the ClinicalTrials.gov database.
Implements input validation and sanitization using Zod schema validation for secure API interactions.
š ļø Tools Overview
This server provides five powerful tools for accessing and analyzing clinical trial data from ClinicalTrials.gov:
Tool Name | Description |
| Searches for clinical studies using query terms, filters, pagination, and sorting. Now includes geographic filtering. |
| Fetches one or more clinical studies by their NCT IDs, returning either full data or concise summaries. |
| Performs statistical analysis on up to 5000 studies, with new time-series analysis by year and month. |
| Performs a detailed side-by-side comparison of 2-5 clinical studies, highlighting commonalities and differences. |
| Matches patient profiles to eligible clinical trials, filtering by age, sex, conditions, and location. |
clinicaltrials_search_studies
Search and discover clinical trials using free-text queries and advanced filters.
Key Features:
Free-text search across all study fields (conditions, interventions, sponsors, titles)
Advanced filtering with ClinicalTrials.gov's official filter syntax
Pagination support for large result sets (up to 200 studies per page)
Sorting by enrollment count, update date, or other fields
Returns concise summaries with NCT IDs, titles, and recruitment status
Example Use Cases:
"Find all Phase 3 diabetes studies currently recruiting"
"Show me cancer immunotherapy trials in the United States"
"List studies by pharmaceutical companies sorted by size"
š View detailed examples ā
clinicaltrials_get_study
Retrieve detailed information for specific clinical trials by their NCT ID.
Key Features:
Fetch single or multiple studies (up to 5 at once)
Choice between full data (complete protocol, results, documents) or concise summaries
Full study data includes: protocol sections, results, adverse events, outcome measures, eligibility criteria, locations, and more
Automatic error handling for invalid or non-existent NCT IDs
Partial success reporting when fetching multiple studies
Example Use Cases:
"Get the full details for study NCT03372603"
"Show me a summary of these three studies: NCT12345678, NCT87654321, NCT11223344"
"What were the results and adverse events for NCT04280783?"
š View detailed examples ā
clinicaltrials_analyze_trends
Perform statistical analysis across thousands of clinical trials.
Key Features:
Aggregate up to 5,000 studies per analysis
Multiple analysis types: status distribution, geographic spread, sponsor types, trial phases
Combine multiple analysis types in a single request
Advanced filtering to focus analysis on specific subsets
Returns counts, percentages, and top categories
Example Use Cases:
"What's the status breakdown of all COVID-19 vaccine Phase 3 trials?"
"Which countries have the most Alzheimer's research studies?"
"Show me the phase distribution and sponsor types for cancer immunotherapy trials"
š View detailed examples ā
clinicaltrials_compare_studies
Compare and contrast multiple studies to identify key similarities and differences.
Key Features:
Side-by-side comparison of 2-5 studies by NCT ID
Extracts and contrasts eligibility, design, interventions, outcomes, sponsors, and more
Generates a summary of commonalities and differences
Handles partial failures gracefully if some studies cannot be fetched
Highly configurable to focus on specific fields of interest
Example Use Cases:
"Compare the study design and eligibility criteria for NCT04516746 and NCT04516759"
"What are the main differences in interventions and outcomes between these three leading Alzheimer's trials?"
"Show me a side-by-side of sponsor and location data for these competitor studies"
š View detailed examples ā
clinicaltrials_find_eligible_studies
Find relevant clinical trials based on a patient's specific medical profile and demographics.
Key Features:
Matches patients using age, sex, and a list of medical conditions
Filters studies by location (country, state, city) to find nearby trials
Ranks results by a relevance score based on how well the patient matches the study's criteria
Provides a clear summary of why a patient is a potential match for a study
Example Use Cases:
"Find recruiting migraine studies in Canada for a 35-year-old female"
"Are there any local clinical trials for a 68-year-old male with Type 2 Diabetes and Hypertension?"
"Search for healthy volunteer studies for a 25-year-old in California"
š View detailed examples ā
⨠Features
This server is built on the mcp-ts-template
and inherits its rich feature set:
Declarative Tools: Define agent capabilities in single, self-contained files. The framework handles registration, validation, and execution.
Robust Error Handling: A unified
McpError
system ensures consistent, structured error responses.Pluggable Authentication: Secure your server with zero-fuss support for
none
,jwt
, oroauth
modes.Abstracted Storage: Swap storage backends (
in-memory
,filesystem
,Supabase
,Cloudflare KV/R2
) without changing business logic.Full-Stack Observability: Deep insights with structured logging (Pino) and optional, auto-instrumented OpenTelemetry for traces and metrics.
Dependency Injection: Built with
tsyringe
for a clean, decoupled, and testable architecture.Edge-Ready: Write code once and run it seamlessly on your local machine or at the edge on Cloudflare Workers.
Plus, specialized features for ClinicalTrials.gov:
Official API Integration: Type-safe, comprehensive access to the ClinicalTrials.gov v2 API.
Advanced Search & Analysis: Tools for complex queries, filtering, and statistical aggregation of trial data.
Optimized Data Handling: Automatic cleaning and simplification of API responses for efficient agent consumption.
š Getting Started
MCP Client Settings/Configuration
Add the following to your MCP Client configuration file (e.g., cline_mcp_settings.json
).
Prerequisites
Bun v1.2.0 or higher.
Installation
Clone the repository:
Navigate into the directory:
Install dependencies:
š ļø Core Capabilities: ClinicalTrials.gov Tools
This server equips AI agents with specialized tools to interact with the ClinicalTrials.gov database.
āļø Configuration
All configuration is centralized and validated at startup in src/config/index.ts
. Key environment variables in your .env
file include:
Variable | Description | Default |
| The transport to use:
or
. |
|
| The port for the HTTP server. |
|
| Authentication mode:
,
, or
. |
|
| Storage backend:
,
,
,
,
. |
|
| Set to
to enable OpenTelemetry. |
|
| The minimum level for logging (
,
,
,
). |
|
| Required for A 32+ character secret key. |
|
| Required for URL of the OIDC provider. |
|
ā¶ļø Running the Server
Local Development
Build and run the production version:
# One-time build bun rebuild # Run the built server bun start:http # or bun start:stdioRun checks and tests:
bun devcheck # Lints, formats, type-checks, and more bun test # Runs the test suite
Cloudflare Workers
Build the Worker bundle:
Run locally with Wrangler:
Deploy to Cloudflare:
bun deploy:prod
š Project Structure
Directory | Purpose & Contents |
| Your tool definitions (
). This is where you add new capabilities. |
| Your resource definitions (
). This is where you add data sources. |
| Implementations for HTTP and STDIO transports, including auth middleware. |
|
abstraction and all storage provider implementations. |
| Integrations with external services (ClinicalTrials.gov, LLMs, Speech). |
| Dependency injection container registrations and tokens. |
| Core utilities for logging, error handling, performance, and security. |
| Environment variable parsing and validation with Zod. |
| Unit and integration tests, mirroring the
directory structure. |
š§āš» Agent Development Guide
For strict rules when using this server with an AI agent, refer to the .clinerules
file in this repository. Key principles include:
Logic Throws, Handlers Catch: Never use
try/catch
in your toollogic
. Throw anMcpError
instead.Pass the Context: Always pass the
RequestContext
object through your call stack for logging and tracing.Use the Barrel Exports: Register new tools and resources only in the
index.ts
barrel files within their respectivedefinitions
directories.
š¤ Contributing
Issues and pull requests are welcome! If you plan to contribute, please run the local checks and tests before submitting your PR.
š License
This project is licensed under the Apache 2.0 License. See the LICENSE file for details.
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Empowers AI agents with direct access to the official ClinicalTrials.gov database, enabling programmatic searching, retrieval, and analysis of clinical study data through a Model Context Protocol interface.
- clinicaltrials_search_studies
- clinicaltrials_get_study
- clinicaltrials_analyze_trends
- clinicaltrials_compare_studies
- clinicaltrials_find_eligible_studies
- ⨠Features
- š Getting Started
- š ļø Core Capabilities: ClinicalTrials.gov Tools
- āļø Configuration
- ā¶ļø Running the Server
- š Project Structure
- š§āš» Agent Development Guide
- š¤ Contributing
- š License
Related Resources
Related MCP Servers
- -securityAlicense-qualityProvides access to the ClinicalTrials.gov AACT database, enabling analysis of clinical trial data, tracking development trends, and generating therapeutic landscape insights.Last updated -16GPL 3.0
- AsecurityAlicenseAqualityA Model Context Protocol server providing AI assistants with access to healthcare data tools, including FDA drug information, PubMed research, health topics, clinical trials, and medical terminology lookup.Last updated -71450MIT License
- -securityAlicense-qualityProvides AI assistants with direct query access to the AACT (Aggregate Analysis of ClinicalTrials.gov) database, allowing structured retrieval and analysis of clinical trial data.Last updated -16GPL 3.0
- -securityAlicense-qualityA Model Context Protocol server that enables Claude Desktop to search clinicaltrials.gov for matching clinical trials based on genetic mutations provided in natural language queries.Last updated -MIT License