clinicaltrialsgov-mcp-server
公共托管服务器: https://clinicaltrials.caseyjhand.com/mcp
概述
用于搜索、发现、分析和匹配临床试验的七个工具:
工具名称 | 描述 |
| 使用全文查询、过滤器、分页、排序和字段选择来搜索研究。 |
| 通过 NCT ID 获取单项研究。返回完整记录:方案、资格、结果、分组、干预措施、联系人和地点。 |
| 获取查询的研究总数,无需获取数据。快速统计和细分。 |
| 发现 API 字段(状态、阶段、研究类型等)的有效值,并提供每个值的计数。 |
| 浏览研究数据模型字段树 — 片段名称、类型、嵌套。支持子树导航和关键字搜索。 |
| 从已完成的研究中提取结果、不良事件、参与者流程和基线。可选的摘要模式可将约 200KB 的有效载荷减少至约 5KB。 |
| 将患者人口统计学信息和疾病状况与符合条件的招募试验进行匹配。提供年龄、性别、疾病状况和地点,以查找具有匹配资格标准、联系人和招募地点的研究。 |
资源 | 描述 |
| 通过 NCT ID 获取单项临床研究。完整 JSON。 |
提示词 | 描述 |
| 使用计数 + 搜索工具进行数据驱动的试验全景分析的自适应工作流。 |
Related MCP server: ClinicalTrials.gov MCP Server
工具
clinicaltrials_search_studies
具有完整 ClinicalTrials.gov 查询功能的主要搜索工具。
全文和特定字段查询(疾病状况、干预措施、申办方、地点、标题、结果)
具有类型化枚举值的状态和阶段过滤器
按坐标和距离进行的地理邻近度过滤
支持复杂查询的高级 AREA[] Essie 表达式
字段选择以减小有效载荷大小(完整记录每条约 70KB)
使用游标令牌进行分页,按任意字段排序
clinicaltrials_get_study_results
获取已完成研究的已发布结果数据。
包含统计数据、不良事件、参与者流程、基线特征的结果指标
节级过滤(仅请求您需要的数据)
可选的摘要模式将完整结果(约 200KB)压缩为基本元数据(每项研究约 5KB)
每次调用可批量处理多个 NCT ID,并提供部分成功报告
对无结果的研究和获取错误进行单独跟踪
clinicaltrials_find_eligible
将患者资料与符合条件的招募试验进行匹配。
将年龄、性别、疾病状况和地点作为患者人口统计学信息
使用人口统计学过滤器(年龄范围、性别、健康志愿者)构建优化的 API 查询
返回包含资格和地点字段的研究,供调用者评估
当没有匹配的研究时提供可操作的提示(扩大疾病状况范围、调整过滤器)
特性
基于 @cyanheads/mcp-ts-core 构建:
具有 Zod 模式和格式化函数的声明式工具/资源/提示词定义
统一的错误处理 — 处理程序抛出异常,框架捕获并分类
双重传输:来自同一代码库的 stdio 和 Streamable HTTP
用于 HTTP 传输的可插拔身份验证(
none、jwt、oauth)具有可选 OpenTelemetry 追踪功能的结构化日志记录
ClinicalTrials.gov 特定功能:
针对 ClinicalTrials.gov REST API v2 的类型安全客户端
公共 API — 无需身份验证或 API 密钥
指数退避重试(3 次尝试)和速率限制(约 1 次请求/秒)
HTML 错误检测和结构化错误工厂
入门指南
公共托管实例
公共实例位于 https://clinicaltrials.caseyjhand.com/mcp — 无需安装。通过 Streamable HTTP 将任何 MCP 客户端指向它:
{
"mcpServers": {
"clinicaltrialsgov-mcp-server": {
"type": "streamable-http",
"url": "https://clinicaltrials.caseyjhand.com/mcp"
}
}
}自托管 / 本地
添加到您的 MCP 客户端配置中(例如 claude_desktop_config.json):
{
"mcpServers": {
"clinicaltrialsgov-mcp-server": {
"type": "stdio",
"command": "bunx",
"args": ["clinicaltrialsgov-mcp-server@latest"],
"env": {
"MCP_TRANSPORT_TYPE": "stdio"
}
}
}
}或者对于 Streamable HTTP:
MCP_TRANSPORT_TYPE=http
MCP_HTTP_PORT=3010先决条件
Bun v1.2.0 或更高版本(或 Node.js >= 22.0.0)
安装
克隆仓库:
git clone https://github.com/cyanheads/clinicaltrialsgov-mcp-server.git进入目录:
cd clinicaltrialsgov-mcp-server安装依赖:
bun install
配置
所有配置均为可选 — 服务器使用默认值且无需 API 密钥。
变量 | 描述 | 默认值 |
| ClinicalTrials.gov API 基础 URL。 |
|
| 每次请求的超时时间(毫秒)。 |
|
| 最大页面大小上限。 |
|
| 传输方式: |
|
| HTTP 服务器端口。 |
|
| 身份验证模式: |
|
| 日志级别 (RFC 5424)。 |
|
| 日志文件目录(仅限 Node.js)。 |
|
| 启用 OpenTelemetry 追踪。 |
|
运行服务器
本地开发
构建并运行生产版本:
bun run build bun run start:http # or start:stdio在开发模式下运行(带监视):
bun run dev:http # or dev:stdio运行检查和测试:
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项目结构
目录 | 用途 |
| 工具定义 ( |
| 资源定义 ( |
| 提示词定义 ( |
| ClinicalTrials.gov API 客户端和类型。 |
| 使用 Zod 进行环境变量解析和验证。 |
| 单元测试和集成测试。 |
开发指南
请参阅 CLAUDE.md 获取开发准则和架构规则。简而言之:
处理程序抛出异常,框架捕获 — 工具逻辑中不使用
try/catch使用
ctx.log进行请求范围的日志记录,不使用console调用在
index.ts桶文件中注册新工具和资源
贡献
欢迎提交问题和拉取请求。提交前请运行检查:
bun run devcheck
bun run test许可证
Apache-2.0 — 详情请参阅 LICENSE。
Available Tools
7 toolsclinicaltrials_find_eligibleClinicaltrials Find EligibleARead-onlyIdempotentInspect
Find candidate clinical trials for a patient profile. Provide age, sex, conditions, and location to get studies with their demographic limits, contact information, and recruiting locations. Candidates are matched on age, sex, location, recruitment status, and ClinicalTrials.gov's fuzzy condition search only — inclusion/exclusion criteria are not checked, and a candidate can exclude the requested condition, so review each one's criteria with clinicaltrials_get_study_record before treating it as a match. Results are re-ranked so studies whose own condition matches a requested condition surface above tangential matches from ClinicalTrials.gov's fuzzy condition search. Each candidate returns only the sites matching the requested location (capped by locationLimit), not the study's full registered site list — a large trial can register hundreds of sites worldwide. Give location.near (the patient's lat, lon, and a radiusMi) in place of city and state to match by travel distance: candidates then return their sites within the radius, nearest first, each with distanceMi from the patient. When none of a candidate's matched sites is recruiting, one recruiting site is added so an enrollable site is never hidden behind a closer closed one: the one nearest the matched sites (under location.near, the patient) by their published coordinates, in the requested country whenever a site there recruits, carrying distanceMi, or the first in match order when coordinates are missing. Under location.near that one site is also added when none of a candidate's listed sites is in location.country and one of its sites there recruits, so a recruiting site in the patient's country is never hidden behind sites across a border. Fetch a study's complete record with clinicaltrials_get_study_record.
Inputs: age (required), sex (required), location (required), conditions (required), +5 more. Returns: cap, near, error, shown, +6 more
clinicaltrials_get_field_definitionsClinicaltrials Get Field DefinitionsARead-onlyIdempotentInspect
Resolve valid field names from the ClinicalTrials.gov data model — the canonical PascalCase identifiers (OverallStatus, EnrollmentCount, LeadSponsorName) the other tools take. Every record piece works in clinicaltrials_search_studies fields; a leaf piece (sourceType other than STRUCT) also works in AREA[…] expressions in advancedFilter and the query parameters, and as input to clinicaltrials_get_field_values (LocationGeoPoint aside); a leaf of a date or integer type (NormalizedDate, PartialDate, DateTimeMinutes, integer, long, short) also works in sort. An index-only piece (drill with includeIndexedOnly, e.g. NumLocations) works wherever a leaf does except fields. Select a mode: "search" — keyword search returning ranked matches (pass query, e.g. "enrollment", "sponsor", "adverse events"); "drill" — drill into a specific section by dot-notation path (pass path, e.g. "protocolSection.designModule"); "overview" — top-level summary of all sections (no additional args).
Inputs: mode (required), path, limit, query, +1 more. Returns: cap, error, shown, fields, +6 more
clinicaltrials_get_field_valuesClinicaltrials Get Field ValuesARead-onlyIdempotentInspect
Discover valid values for ClinicalTrials.gov fields with study counts per value. Use to explore available filter options before building a search — e.g., valid OverallStatus, Phase, InterventionType, StudyType, or LeadSponsorClass values.
Inputs: fields (required). Returns: error, notice, fieldStats
clinicaltrials_get_study_countClinicaltrials Get Study CountARead-onlyIdempotentInspect
Get total clinical trial study count from ClinicalTrials.gov matching a query, without fetching study data. Fast and lightweight. Use for quick statistics or to build breakdowns by calling multiple times with different filters (e.g., count by phase, count by status, count recruiting vs completed for a condition).
Inputs: query, titleQuery, phaseFilter, outcomeQuery, +7 more. Returns: error, notice, totalCount, searchCriteria
clinicaltrials_get_study_recordClinicaltrials Get Study RecordARead-onlyIdempotentInspect
Fetch a single clinical trial study by NCT ID from ClinicalTrials.gov. Returns the full study record including protocol details, eligibility criteria, outcomes, arms, interventions, contacts, and locations. Optional locationLimit / outcomeLimit / referenceLimit / nearLocation parameters trim locations, outcomes, and references — original totals are preserved in filtersApplied only when a cap actually trims the set.
Inputs: nctId (required), nearLocation, outcomeLimit, locationLimit, +1 more. Returns: error, study, filtersApplied, resultsSummary
clinicaltrials_get_study_resultsClinicaltrials Get Study ResultsARead-onlyIdempotentInspect
Fetch clinical trial results data from ClinicalTrials.gov for completed studies — outcome measures with statistics, adverse events, participant flow, baseline characteristics, and results metadata (limitations & caveats, certain-agreement disclosure restrictions, results point of contact). Posted results exist only for studies where hasResults is true; the entry for a study without them names, in resultPublications, the journal articles its record lists as reporting its results (RESULT references, with PMID and citation), when it lists any. Use clinicaltrials_search_studies first to find studies with results. Each call fetches up to 20 distinct NCT IDs and returns any further IDs in deferredNctIds for a follow-up call. A results-rich record can exceed 500KB per study in full mode — bound it with summary=true, narrower sections, or the outcomeLimit / adverseEventLimit caps; outcomeLimit / outcomeOffset also page summarized outcomes. A bounded list is resumable: outcomeOffset / seriousEventOffset / otherEventOffset start the next window, and each study's filtersApplied reports what was trimmed and the next offset for every list left short. A previous (alias) NCT ID resolves to its canonical study, named in canonicalNctId.
Inputs: nctIds (required), summary, sections, outcomeLimit, +4 more. Returns: error, results, truncated, fetchErrors, +2 more
clinicaltrials_search_studiesClinicaltrials Search StudiesARead-onlyIdempotentInspect
Search for clinical trial studies from ClinicalTrials.gov. Supports full-text and field-specific queries, status/phase/geographic filters, pagination, sorting, and field selection. Returns a compact per-study index by default; pass the fields parameter to get specific leaves at full fidelity — full study records are ~70KB each.
Inputs: sort, query, fields, nctIds, +14 more. Returns: cap, error, shown, notice, +8 more
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 7 tools
The seven tools cover distinct facets: lightweight counting, compact index search, full single-record fetch, results-only fetch, schema introspection (definitions vs. values), and patient-oriented candidate matching. The main soft spots are search_studies vs. find_eligible (both surface studies) and get_study_record vs. get_study_results (results are a subset of the record), but descriptions explicitly state the boundaries and cross-reference each other, so an agent can pick correctly.
Every tool uses the same clinicaltrials_ prefix with a snake_case verb_noun form: search_studies, get_study_results, get_study_count, get_field_definitions, get_field_values, get_study_record, find_eligible. The lone 'find_' verb in find_eligible is a meaningful semantic choice (candidate matching, not lookup) rather than an inconsistency.
Seven tools is well within the ideal range and each earns its place: search, count, record, results, two schema helpers, and eligibility matching. There is no redundant or filler tool, and the granularity (count vs. index search vs. full record) avoids forcing agents to over-fetch large payloads.
The surface covers the domain lifecycle well: discover/filter, count, inspect valid fields and values, retrieve full records, retrieve posted results, and eligibility screening, with pagination and trimming controls throughout. The notable gap is batch retrieval of full study records — get_study_results accepts up to 20 NCT IDs while get_study_record is single-study only, so multi-study analysis requires repeated calls.
Maintenance
Related MCP Connectors
Clinical trial search and status from ClinicalTrials.gov
Search ClinicalTrials.gov by condition, drug, location and status, with full trial details
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
- AlicenseAqualityAmaintenanceProvides LLMs with structured access to critical biomedical databases including PubTator3 (PubMed/PMC), ClinicalTrials.gov, and MyVariant.info through the Model Context Protocol.4635840 PyPI685MIT
- FlicenseNot gradedqualityDmaintenanceEnables searching and retrieving information from the ClinicalTrials.gov database of over 400,000 clinical studies, including trial details, eligibility criteria, locations, and results across 220+ countries.5-
- FlicenseNot gradedqualityDmaintenanceEnables AI agents to search and analyze clinical trial data from ClinicalTrials.gov using both structured SQL queries for filtering trials by status, phase, and conditions, and semantic vector search for exploring detailed protocol information like exclusion criteria.-
- AlicenseAqualityDmaintenanceEnables conversational access to 400,000+ clinical trials on ClinicalTrials.gov, allowing users to search, compare, and retrieve trial details using plain English through MCP-compatible clients like Cursor and Claude Desktop.53MIT