clinicaltrialsgov-mcp-server
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.
Click on "Install 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., "@clinicaltrialsgov-mcp-serverfind Phase 3 diabetes studies currently recruiting"
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.
Public Hosted Server: https://clinicaltrials.caseyjhand.com/mcp
Overview
Seven tools for searching, discovering, analyzing, and matching clinical trials:
Tool Name | Description |
| Search studies with full-text queries, filters, pagination, sorting, and field selection. |
| Fetch a single study by NCT ID. Returns the full record: protocol, eligibility, outcomes, arms, interventions, contacts, and locations. |
| Get total study count for a query without fetching data. Fast statistics and breakdowns. |
| Discover valid values for API fields (status, phase, study type, etc.) with per-value counts. |
| Browse the study data model field tree — piece names, types, nesting. Supports subtree navigation and keyword search. |
| Extract outcomes, adverse events, participant flow, and baseline from completed studies. Optional summary mode reduces ~200KB payloads to ~5KB. |
| Match patient demographics and conditions to eligible recruiting trials. Provide age, sex, conditions, and location to find studies with matching eligibility criteria, contacts, and recruiting locations. |
Resource | Description |
| Fetch a single clinical study by NCT ID. Full JSON. |
Prompt | Description |
| Adaptable workflow for data-driven trial landscape analysis using count + search tools. |
Related MCP server: Healthcare MCP Server
Tools
clinicaltrials_search_studies
Primary search tool with full ClinicalTrials.gov query capabilities.
Full-text and field-specific queries (condition, intervention, sponsor, location, title, outcome)
Status and phase filters with typed enum values
Geographic proximity filtering by coordinates and distance
Advanced AREA[] Essie expression support for complex queries
Field selection to reduce payload size (full records are ~70KB each)
Pagination with cursor tokens, sorting by any field
clinicaltrials_get_study_results
Fetch posted results data for completed studies.
Outcome measures with statistics, adverse events, participant flow, baseline characteristics
Section-level filtering (request only the data you need)
Optional summary mode condenses full results (~200KB) to essential metadata (~5KB per study)
Batch multiple NCT IDs per call with partial-success reporting
Separate tracking of studies without results and fetch errors
clinicaltrials_find_eligible
Match a patient profile to eligible recruiting trials.
Takes age, sex, conditions, and location as patient demographics
Builds optimized API queries with demographic filters (age range, sex, healthy volunteers)
Returns studies with eligibility and location fields for the caller to evaluate
Provides actionable hints when no studies match (broaden conditions, adjust filters)
Features
Built on @cyanheads/mcp-ts-core:
Declarative tool/resource/prompt definitions with Zod schemas and format functions
Unified error handling — handlers throw, framework catches and classifies
Dual transport: stdio and Streamable HTTP from the same codebase
Pluggable auth (
none,jwt,oauth) for HTTP transportStructured logging with optional OpenTelemetry tracing
ClinicalTrials.gov-specific:
Type-safe client for the ClinicalTrials.gov REST API v2
Public API — no authentication or API keys required
Retry with exponential backoff (3 attempts) and rate limiting (~1 req/sec)
HTML error detection and structured error factories
Getting Started
Public Hosted Instance
A public instance is available at https://clinicaltrials.caseyjhand.com/mcp — no installation required. Point any MCP client at it via Streamable HTTP:
{
"mcpServers": {
"clinicaltrialsgov-mcp-server": {
"type": "streamable-http",
"url": "https://clinicaltrials.caseyjhand.com/mcp"
}
}
}Self-Hosted / Local
Add to your MCP client config (e.g., claude_desktop_config.json):
{
"mcpServers": {
"clinicaltrialsgov-mcp-server": {
"type": "stdio",
"command": "bunx",
"args": ["clinicaltrialsgov-mcp-server@latest"],
"env": {
"MCP_TRANSPORT_TYPE": "stdio"
}
}
}
}Or for Streamable HTTP:
MCP_TRANSPORT_TYPE=http
MCP_HTTP_PORT=3010Prerequisites
Bun v1.2.0 or higher (or Node.js >= 22.0.0)
Installation
Clone the repository:
git clone https://github.com/cyanheads/clinicaltrialsgov-mcp-server.gitNavigate into the directory:
cd clinicaltrialsgov-mcp-serverInstall dependencies:
bun install
Configuration
All configuration is optional — the server works with defaults and no API keys.
Variable | Description | Default |
| ClinicalTrials.gov API base URL. |
|
| Per-request timeout in milliseconds. |
|
| Maximum page size cap. |
|
| Transport: |
|
| Port for HTTP server. |
|
| Auth mode: |
|
| Log level (RFC 5424). |
|
| Directory for log files (Node.js only). |
|
| Enable OpenTelemetry tracing. |
|
Running the Server
Local Development
Build and run the production version:
bun run build bun run start:http # or start:stdioRun in dev mode (with watch):
bun run dev:http # or dev:stdioRun checks and tests:
bun run devcheck # Lints, formats, type-checks bun run test # Runs test suite
Docker
docker build -t clinicaltrialsgov-mcp-server .
docker run -p 3010:3010 clinicaltrialsgov-mcp-serverProject Structure
Directory | Purpose |
| Tool definitions ( |
| Resource definitions ( |
| Prompt definitions ( |
| ClinicalTrials.gov API client and types. |
| Environment variable parsing and validation with Zod. |
| Unit and integration tests. |
Development Guide
See CLAUDE.md for development guidelines and architectural rules. The short version:
Handlers throw, framework catches — no
try/catchin tool logicUse
ctx.logfor request-scoped logging, noconsolecallsRegister new tools and resources in the
index.tsbarrel files
Contributing
Issues and pull requests are welcome. Run checks before submitting:
bun run devcheck
bun run testLicense
Apache-2.0 — see LICENSE for details.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/cyanheads/clinicaltrialsgov-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server