freshcrate
Skin:/
Home > MCP Servers > clinicaltrialsgov-mcp-server

clinicaltrialsgov-mcp-server

MCP server for the ClinicalTrials.gov v2 API. Search trials, retrieve study details and results, and match patients to eligible trials.

Why this rank:Strong adoptionRecent releaseHealthy release cadence

Description

MCP server for the ClinicalTrials.gov v2 API. Search trials, retrieve study details and results, and match patients to eligible trials.

README

clinicaltrialsgov-mcp-server

MCP server for the ClinicalTrials.gov v2 API. Search trials, retrieve study details and results, and match patients to eligible trials.

7 Tools ยท 1 Resource ยท 1 Prompt


Overview

Seven tools for searching, discovering, analyzing, and matching clinical trials:

Tool Name Description
clinicaltrials_search_studies Search studies with full-text queries, filters, pagination, sorting, and field selection.
clinicaltrials_get_study_record Fetch a single study by NCT ID. Returns the full record: protocol, eligibility, outcomes, arms, interventions, contacts, and locations.
clinicaltrials_get_study_count Get total study count for a query without fetching data. Fast statistics and breakdowns.
clinicaltrials_get_field_values Discover valid values for API fields (status, phase, study type, etc.) with per-value counts.
clinicaltrials_get_field_definitions Browse the study data model field tree โ€” piece names, types, nesting. Supports subtree navigation and keyword search.
clinicaltrials_get_study_results Extract outcomes, adverse events, participant flow, and baseline from completed studies. Optional summary mode reduces ~200KB payloads to ~5KB.
clinicaltrials_find_eligible 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
clinicaltrials://{nctId} Fetch a single clinical study by NCT ID. Full JSON.
Prompt Description
analyze_trial_landscape Adaptable workflow for data-driven trial landscape analysis using count + search tools.

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 transport
  • Structured 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=3010

Prerequisites

Installation

  1. Clone the repository:

    git clone https://github.com/cyanheads/clinicaltrialsgov-mcp-server.git
  2. Navigate into the directory:

    cd clinicaltrialsgov-mcp-server
  3. Install dependencies:

    bun install

Configuration

All configuration is optional โ€” the server works with defaults and no API keys.

Variable Description Default
CT_API_BASE_URL ClinicalTrials.gov API base URL. https://clinicaltrials.gov/api/v2
CT_REQUEST_TIMEOUT_MS Per-request timeout in milliseconds. 30000
CT_MAX_PAGE_SIZE Maximum page size cap. 200
MCP_TRANSPORT_TYPE Transport: stdio or http. stdio
MCP_HTTP_PORT Port for HTTP server. 3010
MCP_AUTH_MODE Auth mode: none, jwt, or oauth. none
MCP_LOG_LEVEL Log level (RFC 5424). info
LOGS_DIR Directory for log files (Node.js only). <project-root>/logs
OTEL_ENABLED Enable OpenTelemetry tracing. false

Running the Server

Local Development

  • Build and run the production version:

    bun run build
    bun run start:http   # or start:stdio
  • Run in dev mode (with watch):

    bun run dev:http     # or dev:stdio
  • Run 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-server

Project Structure

Directory Purpose
src/mcp-server/tools/ Tool definitions (*.tool.ts).
src/mcp-server/resources/ Resource definitions (*.resource.ts).
src/mcp-server/prompts/ Prompt definitions (*.prompt.ts).
src/services/clinical-trials/ ClinicalTrials.gov API client and types.
src/config/ Environment variable parsing and validation with Zod.
tests/ Unit and integration tests.

Development Guide

See CLAUDE.md for development guidelines and architectural rules. The short version:

  • Handlers throw, framework catches โ€” no try/catch in tool logic
  • Use ctx.log for request-scoped logging, no console calls
  • Register new tools and resources in the index.ts barrel files

Contributing

Issues and pull requests are welcome. Run checks before submitting:

bun run devcheck
bun run test

License

Apache-2.0 โ€” see LICENSE for details.

Release History

VersionChangesUrgencyDate
v2.10.1Workload caps served, same-site location match, subyear ages - `search_studies` `pageSize`, `find_eligible` `maxResults`, and `get_study_results` `nctIds` accept up to 1000 / 1000 / 500 and serve at the per-call cap (200 / 50 / 20 distinct IDs) with `truncated` / `shown` / `cap` or `deferredNctIds`; `CT_MAX_PAGE_SIZE` bounds only `search_studies` pages (#153) - Output-only limits (`get_study_record`, `get_study_results`, `find_eligible` `locationLimit`, `get_field_definitions` `limit`) lose theHigh10/23/2026
v2.10.0Input normalization, candidate framing, summary-mode results - BREAKING: phaseFilter entries naming no phase fail as `enum_invalid`; case, spacing, and `,`/`|` variants normalize to canonical phases (#144) - BREAKING: find_eligible rejects quote-only and zero-width-only values as `blank_value` (#145) - find_eligible returns candidates with a notice that inclusion/exclusion criteria were not checked; its description, labels, and the package metadata say "candidate trials" (#147) - find_eligible High10/14/2026
v2.9.11mcp-ts-core 0.13.12 adoption and template catch-up - **mcp-ts-core ^0.13.6 โ†’ ^0.13.12** โ€” error `data` no longer carries stack traces (0.13.7) or request context (0.13.8); an argument sent as a JSON-stringified object, or an integer sent for a string, is repaired before validation (0.13.9); MCP SDK 2.1 transport rules (0.13.9); tool error results carry `data.requestId` and close with `request <id>` (0.13.10); `ctx.log` notifications honor `MCP_LOG_LEVEL` (0.13.11); every call logs under a frameHigh10/5/2026
v2.9.10per-group adverse events, distance-ranked site admission - `get_study_results` summary-mode adverse events report per-group `byGroup` counts against an `eventGroups` roster, ranked by the largest single group, not a pooled `numAffected`/`numAtRisk` that double-counts overlapping groups (#137) - `find_eligible`'s fallback recruiting site is admitted by haversine distance to the matched tier (requested country preferred), carrying `distanceMi`, instead of upstream list order; without coordinates High9/22/2026
v2.9.8mcp-ts-core 0.13.4, declared stateless session mode - **Declared stateless session mode** โ€” `createApp` now sets `sessionMode: 'stateless'`; `.env.example` sets `MCP_SESSION_MODE=stateless` actively, and the README config table documents it; an explicit `MCP_SESSION_MODE` still overrides the declared default (#115) - **Argument rejections carry a `Recovery:` hint and `data.reason: "invalid_arguments"`**, client-injected root keys (`_meta`, `tool_call_description`, `toolCallId`) are dropped and High9/18/2026
v2.9.7mcp-ts-core 0.13.0: blank config values fall back to defaults - Blank or unsubstituted `${...}` config values read as unset, so defaults apply (mcp-ts-core 0.13.0, cyanheads/mcp-ts-core#427) - `manifest.json` wires its MCPB `user_config` options (`CT_API_BASE_URL`, `CT_REQUEST_TIMEOUT_MS`, `CT_MAX_PAGE_SIZE`, `MCP_LOG_LEVEL`) into `mcp_config.env`; a value set in the install UI previously never reached the server - Development skills moved from `skills/` to `framework-skills/`, so installing thHigh9/13/2026
v2.9.3Caller cancellation, mcp-ts-core ^0.12.5 - A caller that disconnects mid-request now surfaces `RequestCancelled` immediately instead of being retried, or walked one ID at a time in the batch-results fallback - `@cyanheads/mcp-ts-core` ^0.12.3 โ†’ ^0.12.5 โ€” upstream 500/501 responses classify as `ServiceUnavailable`, a disconnected client reports as a cancellation, and server identity resolves from the served package rather than the working directory - SSRF DNS guard (inherited from the framework High9/3/2026
v2.9.2mcp-ts-core 0.12.3 โ€” MCP SDK v2 migration - `@cyanheads/mcp-ts-core` `^0.11.5` โ†’ `^0.12.3` โ€” MCP SDK v2 migration, runtime package split (`@modelcontextprotocol/server`) - `find_eligible`'s `location` and `get_study_record`'s `nearLocation` reject an undeclared key by name instead of silently stripping it - `MCP_SESSION_MODE` defaults to `auto`; added HTTP resumability env vars for replaying a dropped SSE stream - Docker build stage pinned to $BUILDPLATFORM (bun `1.3.14` โ†’ `1.4.0`) โ€” QEMU emulaMedium8/21/2026
v2.9.1suggestion floor, blank_value hint, dead Worker script cleanup - nearestPieces field/sort suggestions require a similarity floor instead of always returning three unrelated names (#112) - blank_value recovery hint and blankValueMessage lead with the supply action, offering omission only for optional parameters (#113) - dropped test:conformance, build:worker, deploy:dev, deploy:prod and the @cloudflare/workers-types devDependency; wired toolContractSuite as tests/mcp-server/tools/tool-contract.tHigh8/18/2026
v2.8.5format() completeness โ€” get_study_record and get_study_results - clinicaltrials_get_study_record renders leaves structuredContent already carried but format() dropped, including the full observational-study subtree (#18) - clinicaltrials_get_study_results full mode walks the complete classes -> categories -> measurements tree instead of sampling the first class/category (#63) [CHANGELOG v2.8.5](https://github.com/cyanheads/clinicaltrialsgov-mcp-server/blob/main/changelog/2.8.x/2.8.5.md)High7/26/2026
v2.8.2get_field_definitions recovery-hint regression path_not_found no longer points callers at the removed no-args overview call. Fixed: - `path_not_found` recovery hint now names mode="search"/mode="overview" instead of the removed no-args overview (#87) 569 tests pass; `bun run devcheck` clean. [CHANGELOG v2.8.2](https://github.com/cyanheads/clinicaltrialsgov-mcp-server/blob/main/changelog/2.8.x/2.8.2.md)High7/9/2026
v2.8.0search_studies output-channel parity, js-yaml advisory clear search_studies bounds structuredContent to a compact per-study index by default; find_eligible condition re-rank drops shared-word false friends. Changed: - search_studies structuredContent.studies is now a compact per-study index by default (nctId, briefTitle, overallStatus, phases, enrollmentCount, leadSponsor, conditions, bounded total/nearest locations) instead of the full ~70KB record. BREAKING โ€” pass fields for full-fidelity lHigh7/1/2026
v2.7.4geoFilter site re-ranking, multi-valued field flag, concise parse errors Added: - search_studies: with an active geoFilter, each study's locations[] is re-ranked by proximity to the filter center so the matched site leads and renders with distanceMi; sites without a geoPoint are kept (re-rank only, never filter). New shared geo-helpers.ts (#84) - get_field_values: array-typed fields (Phase, Condition) carry multiValued: true plus a format() note, so callers don't read the per-value buckets as High6/21/2026
v2.7.2Outcome rendering and filter-disclosure correctness Corrects misleading output across five tools: not-reached arms no longer vanish from outcome summaries, truncation and cap flags fire only on real overflow, and an empty field list is rejected instead of dumping the full catalog. Changed: - `get_study_count` echoes `sentinelFilterActive: true` when the default unknown-enrollment exclusion is in effect, matching `search_studies` (#78) - `get_study_record` `filtersApplied` records a cap and itHigh6/14/2026
v2.7.0Condition re-rank, referenceLimit, sort guidance find_eligible now stable-sorts results so studies whose own condition names a requested condition rank above tangential MeSH-umbrella matches from the upstream fuzzy query.cond search. Recall unchanged โ€” nothing dropped. get_study_record gains referenceLimit mirroring locationLimit/outcomeLimit. search_studies sort description guides EnrollmentCount:desc toward AREA[StudyType]INTERVENTIONAL. Added: - get_study_record: referenceLimit caps refereHigh6/11/2026
v2.6.4Remove SQLite study mirror; fix find_eligible recruiting filter Removes the opt-in local SQLite study mirror (CT_MIRROR_*). The FTS5 index cannot reproduce ClinicalTrials.gov's server-side field-scoped search โ€” condition counts diverged 4โ€“5ร— from live (#68), fields selection was silently dropped and pagination was broken (#66), and the metadata-only schema could not return resultsSection at all (#65). Search, count, and record lookups now always use the live API. Removed: - Local SQLite mirroHigh6/5/2026
v2.5.4Two bug fixes: dead error contract, status-label misses The batch-fallback for get-study-results converts batch errors to per-ID fetchErrors, making the ids_not_found contract dead documentation. The field-values validator misdirected agents reaching for common status labels. Fixed: - **get-study-results**: drop unreachable ids_not_found error contract โ€” invalid NCT IDs surface in fetchErrors, not as a thrown error (#55) - **get-field-values**: auto-correct RecruitmentStatus/RecruitingStatus High5/31/2026
v2.4.12mcp-ts-core ^0.9.1 โ†’ ^0.9.6, zod added, manifest.json + .mcpbignore scaffolded, install badges, action-first descriptionsHigh5/23/2026
main@2026-05-16Latest activity on main branchHigh5/16/2026
v2.1.0Latest release: v2.1.0High4/6/2026

Dependencies & License Audit

Loading dependencies...

Similar Packages

resonantOpen-source relational AI framework with identity persistence, memory, and MCP integration. Build relationship-aware AI agents that remember, grow, and maintain continuity. Built on Claude Agent SDK.v3.0.0
node9-proxyThe Execution Security Layer for the Agentic Era. Providing deterministic "Sudo" governance and audit logs for autonomous AI agents.v2.38.0
TomoriBotA highly customizable personal AI assistant for Discord featuring smart agentic AI features such as memory, personas, tool usage, and more! ๏ฝœ ้•ทๆœŸ่จ˜ๆ†ถใ‚„ใƒšใƒซใ‚ฝใƒŠใ€ใƒ„ใƒผใƒซ้€ฃๆบใ‚’ๅฎŒๅ‚™ใ€‚ ๆฌกไธ–ไปฃใฎใ€Œ่‡ชๅพ‹ๅž‹AIใ‚จใƒผใ‚ธใ‚งใƒณใƒˆใ€Discordใƒœใƒƒใƒˆ๏ผv0.8.1.00
mcp-ts-coreAgent-native TypeScript framework for building MCP servers. Build tools, not infrastructure.v0.13.16
activepiecesAI Agents & MCPs & AI Workflow Automation โ€ข (~400 MCP servers for AI agents) โ€ข AI Automation / AI Agent with MCPs โ€ข AI Workflows & AI Agents โ€ข MCPs for AI Agents0.92.3-hotfix.1

More from cyanheads

mcp-ts-coreAgent-native TypeScript framework for building MCP servers. Build tools, not infrastructure.

More in MCP Servers

litellmPython SDK, Proxy Server (AI Gateway) to call 100+ LLM APIs in OpenAI (or native) format, with cost tracking, guardrails, loadbalancing and logging. [Bedrock, Azure, OpenAI, VertexAI, Cohere, Anthropi
ruflo๐ŸŒŠ The leading agent orchestration platform for Claude. Deploy intelligent multi-agent swarms, coordinate autonomous workflows, and build conversational AI systems. Features enterprise-grade archit
@claude-flow/cliRuflo CLI - Enterprise AI agent orchestration with 60+ specialized agents, swarm coordination, MCP server, self-learning hooks, and vector memory for Claude Code
claude-plugins-officialOfficial, Anthropic-managed directory of high quality Claude Code Plugins.