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.
ClinicalTrials.gov MCP Server
Empower your AI agents with direct access to the official ClinicalTrials.gov database!
An MCP (Model Context Protocol) server providing a robust, developer-friendly interface to the official ClinicalTrials.gov v2 API. Enables LLMs and AI agents to search, retrieve, and analyze clinical study data programmatically.
Built on the cyanheads/mcp-ts-template
, this server follows a modular architecture with robust error handling, logging, and security features.
🚀 Core Capabilities: ClinicalTrials.gov Tools 🛠️
This server equips your AI with specialized tools to interact with the ClinicalTrials.gov database:
Tool Name | Description | Key Features |
---|---|---|
clinicaltrials_list_studies | Searches for clinical studies using a combination of query terms and filters. (See Example) | - query : Search by condition, term, location, title, intervention, outcomes, sponsor, or ID.- filter : Refine results by NCT IDs, study status, geographic distance, or advanced Essie expressions.- pagination : Control result sets with pageSize and pageToken .- fields : Specify which data fields to return for efficiency. |
clinicaltrials_get_study | Retrieves detailed information for a single clinical study by its NCT number. (See Example) | - nctId : Fetches a study using its unique identifier (e.g., "NCT03934567").- fields : Select specific fields to retrieve.- markupFormat : Choose between markdown or legacy for formatted content.- Uses ClinicalTrials.gov REST API v2. |
Table of Contents
| Overview | Features | Installation |
| Configuration | Project Structure |
| Tools | Resources | Development | License |
Overview
The ClinicalTrials.gov MCP Server acts as a bridge, allowing applications (MCP Clients) that understand the Model Context Protocol (MCP) – like advanced AI assistants (LLMs), IDE extensions, or custom research tools – to interact directly and efficiently with the official ClinicalTrials.gov database.
Instead of complex API integration or manual searches, your tools can leverage this server to:
- Automate clinical research workflows: Search for clinical trials, fetch detailed study metadata, and analyze trial characteristics programmatically.
- Gain research insights: Access comprehensive trial data including study protocols, eligibility criteria, outcomes, sponsors, and locations without leaving the host application.
- Integrate clinical trial data into AI-driven research: Enable LLMs to conduct clinical trial reviews, analyze research trends, and support evidence-based decision making.
- Support regulatory and compliance workflows: Retrieve structured data for regulatory submissions, competitive intelligence, and market research.
Built on the robust mcp-ts-template
, this server provides a standardized, secure, and efficient way to expose ClinicalTrials.gov functionality via the MCP standard. It achieves this by integrating with the official ClinicalTrials.gov v2 API, ensuring compliance with rate limits and providing comprehensive error handling.
Developer Note: This repository includes a .clinerules file that serves as a developer cheat sheet for your LLM coding agent with quick reference for the codebase patterns, file locations, and code snippets.
Features
Core Utilities
Leverages the robust utilities provided by the mcp-ts-template
:
- Logging: Structured, configurable logging (file rotation, stdout JSON, MCP notifications) with sensitive data redaction.
- Error Handling: Centralized error processing, standardized error types (
McpError
), and automatic logging. - Configuration: Environment variable loading (
dotenv
) with comprehensive validation. - Input Validation/Sanitization: Uses
zod
for schema validation and custom sanitization logic. - Request Context: Tracking and correlation of operations via unique request IDs using
AsyncLocalStorage
. - Type Safety: Strong typing enforced by TypeScript and Zod schemas.
- HTTP Transport: High-performance HTTP server using Hono, featuring session management with garbage collection, CORS, and IP-based rate limiting.
- Authentication: Robust authentication layer supporting JWT and OAuth 2.1, with fine-grained scope enforcement.
- Deployment: Multi-stage
Dockerfile
for creating small, secure production images with native dependency support.
ClinicalTrials.gov Integration
- Official API Integration: Comprehensive access to ClinicalTrials.gov v2 API endpoints with automatic JSON parsing.
- Advanced Search Capabilities: Complex query construction with filters for study status, geographic location, conditions, interventions, and sponsors.
- Full Study Metadata: Retrieve complete trial data including protocols, eligibility criteria, study design, outcomes, sponsors, and contact information.
- Flexible Field Selection: Choose specific data fields to retrieve for efficient API usage and reduced response sizes.
- Pagination Support: Handle large result sets with built-in pagination using
pageSize
andpageToken
parameters. - Multiple Query Types: Support for condition-based, intervention-based, location-based, and sponsor-based searches.
- Data Format Options: Choose between
markdown
andlegacy
markup formats for study descriptions. - Rate Limiting Compliance: Built-in request throttling to comply with ClinicalTrials.gov API guidelines.
Installation
Prerequisites
- Node.js (>=18.0.0)
- npm (comes with Node.js)
MCP Client Settings
Add the following to your MCP client's configuration file (e.g., cline_mcp_settings.json
). This configuration uses npx
to run the server, which will automatically install the package if not already present:
If running manually (not via MCP client for development or testing)
Install via npm
Alternatively Install from Source
- Clone the repository:
- Install dependencies:
- Build the project:
Configuration
Environment Variables
Configure the server using environment variables. These environmental variables are set within your MCP client config/settings (e.g. claude_desktop_config.json
for Claude Desktop)
Variable | Description | Default |
---|---|---|
MCP_TRANSPORT_TYPE | Transport mechanism: stdio or http . | stdio |
MCP_HTTP_PORT | Port for the HTTP server (if MCP_TRANSPORT_TYPE=http ). | 3010 |
MCP_HTTP_HOST | Host address for the HTTP server (if MCP_TRANSPORT_TYPE=http ). | 127.0.0.1 |
MCP_ALLOWED_ORIGINS | Comma-separated list of allowed origins for CORS (if MCP_TRANSPORT_TYPE=http ). | (none) |
MCP_LOG_LEVEL | Logging level (debug , info , notice , warning , error , crit , alert , emerg ). | debug |
LOG_OUTPUT_MODE | Logging output mode: file or stdout . | file |
MCP_AUTH_MODE | Authentication mode for HTTP: jwt or oauth . | jwt |
MCP_AUTH_SECRET_KEY | Required for jwt auth. Minimum 32-character secret key for JWT authentication. | (none) |
CLINICALTRIALS_DATA_PATH | Directory for caching ClinicalTrials.gov API data. | data/ (in project root) |
LOGS_DIR | Directory for log file storage (if LOG_OUTPUT_MODE=file ). | logs/ |
NODE_ENV | Runtime environment (development , production ). | development |
Project Structure
The codebase follows a modular structure within the src/
directory:
For a detailed file tree, run npm run tree
or see docs/tree.md.
Tools
The ClinicalTrials.gov MCP Server provides a comprehensive suite of tools for clinical trial research, callable via the Model Context Protocol.
Tool Name | Description | Key Arguments |
---|---|---|
clinicaltrials_list_studies | Searches for clinical studies using queries, filters, and pagination. | query? , filter? , fields? , sort? , pageSize? , pageToken? , countTotal? |
clinicaltrials_get_study | Fetches detailed information for a single study by NCT number. | nctId , markupFormat? , fields? |
Note: All tools support comprehensive error handling and return structured JSON responses.
Examples
Comprehensive usage examples are available in the examples/
directory:
Development
Build and Test
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
This server cannot be installed
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.
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 -9PythonGPL 3.0
- -securityFlicense-qualityA 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 -10Python
- -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 -9PythonGPL 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 -PythonMIT License