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で単一の研究を取得します。プロトコル、適格性、結果、アーム、介入、連絡先、場所を含む完全なレコードを返します。

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リクエスト/秒)

  • 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
  • 開発モードで実行(ウォッチ機能付き):

    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 バレルファイルに登録する

貢献

Issueやプルリクエストを歓迎します。提出前にチェックを実行してください:

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