Skip to main content
Glama
clinicaltrialsgov-mcp-server

clinicaltrialsgov-mcp-server

by cyanheads

npm Docker Version Framework

MCP SDK License TypeScript

공개 호스팅 서버: https://clinicaltrials.caseyjhand.com/mcp


개요

임상시험 검색, 발견, 분석 및 매칭을 위한 7가지 도구:

도구 이름

설명

clinicaltrials_search_studies

전체 텍스트 쿼리, 필터, 페이지네이션, 정렬 및 필드 선택을 사용하여 연구를 검색합니다.

clinicaltrials_get_study_record

NCT ID로 단일 연구를 가져옵니다. 프로토콜, 적격성, 결과, 암(arm), 중재, 연락처 및 위치를 포함한 전체 기록을 반환합니다.

clinicaltrials_get_study_count

데이터를 가져오지 않고 쿼리에 대한 총 연구 수를 가져옵니다. 빠른 통계 및 분석에 유용합니다.

clinicaltrials_get_field_values

값별 개수와 함께 API 필드(상태, 단계, 연구 유형 등)에 대한 유효한 값을 찾습니다.

clinicaltrials_get_field_definitions

연구 데이터 모델 필드 트리(항목 이름, 유형, 중첩)를 탐색합니다. 하위 트리 탐색 및 키워드 검색을 지원합니다.

clinicaltrials_get_study_results

완료된 연구에서 결과, 이상 반응, 참가자 흐름 및 기준선을 추출합니다. 선택적 요약 모드는 약 200KB의 페이로드를 약 5KB로 줄여줍니다.

clinicaltrials_find_eligible

환자의 인구 통계 및 상태를 적합한 모집 중인 임상시험과 매칭합니다. 나이, 성별, 상태 및 위치를 제공하여 일치하는 적격성 기준, 연락처 및 모집 위치를 가진 연구를 찾습니다.

리소스

설명

clinicaltrials://{nctId}

NCT ID로 단일 임상 연구를 가져옵니다. 전체 JSON 형식.

프롬프트

설명

analyze_trial_landscape

카운트 및 검색 도구를 사용하여 데이터 기반 임상시험 환경 분석을 위한 적응형 워크플로우입니다.

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 req/sec)을 통한 재시도

  • 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

사전 요구 사항

설치

  1. 저장소 복제:

    git clone https://github.com/cyanheads/clinicaltrialsgov-mcp-server.git
  2. 디렉토리로 이동:

    cd clinicaltrialsgov-mcp-server
  3. 의존성 설치:

    bun install

구성

모든 구성은 선택 사항입니다. 서버는 기본값으로 작동하며 API 키가 필요하지 않습니다.

변수

설명

기본값

CT_API_BASE_URL

ClinicalTrials.gov API 기본 URL.

https://clinicaltrials.gov/api/v2

CT_REQUEST_TIMEOUT_MS

요청당 타임아웃(밀리초).

30000

CT_MAX_PAGE_SIZE

최대 페이지 크기 제한.

200

MCP_TRANSPORT_TYPE

전송 방식: stdio 또는 http.

stdio

MCP_HTTP_PORT

HTTP 서버 포트.

3010

MCP_AUTH_MODE

인증 모드: none, jwt 또는 oauth.

none

MCP_LOG_LEVEL

로그 레벨 (RFC 5424).

info

LOGS_DIR

로그 파일 디렉토리 (Node.js 전용).

<project-root>/logs

OTEL_ENABLED

OpenTelemetry 추적 활성화.

false

서버 실행

로컬 개발

  • 프로덕션 버전 빌드 및 실행:

    bun run build
    bun run start:http   # or start:stdio
  • 개발 모드에서 실행 (watch 포함):

    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

프로젝트 구조

디렉토리

목적

src/mcp-server/tools/

도구 정의 (*.tool.ts).

src/mcp-server/resources/

리소스 정의 (*.resource.ts).

src/mcp-server/prompts/

프롬프트 정의 (*.prompt.ts).

src/services/clinical-trials/

ClinicalTrials.gov API 클라이언트 및 타입.

src/config/

Zod를 사용한 환경 변수 파싱 및 검증.

tests/

단위 및 통합 테스트.

개발 가이드

개발 지침 및 아키텍처 규칙은 CLAUDE.md를 참조하세요. 요약하자면:

  • 핸들러가 오류를 발생시키면 프레임워크가 포착함 — 도구 로직 내에서 try/catch 사용 금지

  • 요청 범위 로깅에는 ctx.log를 사용하고 console 호출 금지

  • 새로운 도구와 리소스는 index.ts 배럴 파일에 등록

기여

이슈 및 풀 리퀘스트를 환영합니다. 제출 전 검사를 실행하세요:

bun run devcheck
bun run test

라이선스

Apache-2.0 — 자세한 내용은 LICENSE를 참조하세요.

Available Tools

7 tools
clinicaltrials_find_eligibleClinicaltrials Find EligibleA
Read-onlyIdempotent
Inspect

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 DefinitionsA
Read-onlyIdempotent
Inspect

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 ValuesA
Read-onlyIdempotent
Inspect

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 CountA
Read-onlyIdempotent
Inspect

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 RecordA
Read-onlyIdempotent
Inspect

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 ResultsA
Read-onlyIdempotent
Inspect

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 StudiesA
Read-onlyIdempotent
Inspect

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

    A4.1/5.0

    Scored across 7 tools

    Disambiguation4/5

    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.

    Naming Consistency5/5

    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.

    Tool Count5/5

    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.

    Completeness4/5

    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

    ActivityActive
    ResponsivenessLimited data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      A
      maintenance
      Provides LLMs with structured access to critical biomedical databases including PubTator3 (PubMed/PMC), ClinicalTrials.gov, and MyVariant.info through the Model Context Protocol.
      46
      35
      840 PyPI
      685
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables 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.
      -
    • A
      license
      A
      quality
      D
      maintenance
      Enables 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.
      5
      3
      MIT