ClinicalTrials-MCP

ClinicalTrials-MCP

Enables searching clinical trials, retrieving trial details, matching patient profiles to recruiting trials, and extracting eligibility criteria from ClinicalTrials.gov.

Category
访问服务器

README

ClinicalTrials-MCP

An MCP server that grounds an LLM in the public ClinicalTrials.gov registry (API v2, no key required), built as a production-minded slice of the BioLit-MCP portfolio.

Beyond simple API wrappers, it adds the pieces a real clinical-AI platform needs: trial matching, LLM-powered eligibility extraction, a retrieval eval harness with regression detection, and per-tool observability.

Tools

Tool What it does
search_trials(condition, max_results) Keyword search over the registry.
get_trial(nct_id) Full detail for one study (status, phase, conditions, sponsor, summary).
match_patient_to_trials(condition, age, sex, keywords, max_results) Ranks recruiting trials for a patient profile: filters by age/sex eligibility, ranks by keyword (e.g. biomarker) overlap. Decision support, not medical advice.
extract_eligibility(nct_id) Parses free-text eligibility into structured inclusion/exclusion lists. Uses an LLM (Anthropic) when ANTHROPIC_API_KEY is set; falls back to a deterministic heuristic parser otherwise.
server_metrics() Live per-tool metrics: calls, error rate, p50/p95 latency.

Why these, for a clinical-AI role

This maps directly to the day-to-day of a clinical-AI ML engineer:

  • Trial matching — the core "connect patients to the right trial" problem.
  • LLM extraction — turning messy clinical free text into structured data.
  • Eval infrastructure — measuring output quality continuously and catching regressions before they ship (evals/).
  • Observability — metrics/logging/alerting for production tool calls (observability.py).

Quickstart

uv sync                      # or: pip install -e ".[dev,llm]"
uv run mcp dev server.py     # open the MCP Inspector to call tools interactively

Add to Claude Desktop (claude_desktop_config.json), then restart it:

{
  "mcpServers": {
    "clinicaltrials": {
      "command": "/abs/path/to/.venv/bin/python",
      "args": ["/abs/path/to/clinicaltrials-mcp/server.py"]
    }
  }
}

LLM extraction is optional — set ANTHROPIC_API_KEY (and optionally ANTHROPIC_MODEL) to enable it; without a key the heuristic parser is used.

Evals

The harness scores retrieval quality against a 20-case gold set and gates on regressions vs. a committed baseline.

python evals/run_evals.py                    # run + compare to baseline
python evals/run_evals.py --update-baseline  # record current scores as baseline

Metrics reported:

  • hit@k — fraction of cases where a relevant study appears in the top k.
  • avg precision — mean fraction of top-k results that are on-topic.
  • regression gate — non-zero exit if hit@k drops more than the tolerance (default 5%) below baseline; wired into CI.

Note: the evals hit the live public API, which rate-limits aggressive clients. Run locally to populate evals/baseline.json and evals/results.json (the committed copies are placeholders — the scaffolding environment was rate-limited).

Resilience

The API layer wraps every call to the public registry in exponential backoff (retrying rate-limit 429s and transient 5xxs, failing fast on 4xx) and a short-lived TTL cache, so repeated lookups — e.g. the many api_get calls inside match_patient_to_trials — don't re-hit the network. See _get / _ttl_cache in server.py.

Tests & CI

pytest -q                              # 14 unit tests, network mocked — fast & deterministic
RUN_INTEGRATION=1 pytest -q \
    tests/test_integration.py          # live contract tests against the real API

The unit tests mock the network, which keeps them fast but blind to upstream contract drift — a renamed query field makes every live call 400 while every mocked test still passes. The opt-in integration tests (tests/test_integration.py) exercise the real request/response contract so that breakage is caught, not shipped.

GitHub Actions (.github/workflows/ci.yml) runs the unit tests on every push/PR and runs the retrieval evals as a separate, non-blocking regression job.

Layout

clinicaltrials-mcp/
├── server.py            # MCP tools + core API layer
├── observability.py     # logging + metrics (@track decorator, snapshot())
├── evals/
│   ├── gold_set.json    # 20 labeled retrieval cases
│   ├── run_evals.py     # scoring + regression detection
│   ├── baseline.json    # committed baseline (populate locally)
│   └── results.json     # last run output (populate locally)
├── tests/
│   ├── test_server.py       # unit tests (mocked network) — logic + retry/cache
│   └── test_integration.py  # opt-in live API contract tests
├── .github/workflows/ci.yml
└── pyproject.toml

Disclaimer

Research/portfolio project. Not a medical device; output is not clinical advice. Always verify eligibility against the full protocol with a qualified clinician.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选