ClinicalTrials.gov MCP Server

Local setup required. This server has to be cloned and prepared on your machine before you register it in Claude Code.
1

Set the server up locally

Run this once to clone and prepare the server before adding it to Claude Code.

Run in terminal
git clone <your-repo-url> .
npm install
npm run build
2

Register it in Claude Code

After the local setup is done, run this command to point Claude Code at the built server.

Run in terminal
claude mcp add clinical-trials -- node "<FULL_PATH_TO_MCP_CLINICALTRIAL>/dist/index.js"

Replace <FULL_PATH_TO_MCP_CLINICALTRIAL>/dist/index.js with the actual folder you prepared in step 1.

README.md

Analyze clinical trial data and adverse event profiles via ClinicalTrials.gov

ClinicalTrials.gov 不良事件对照 MCP 服务器

一个用于分析临床试验不良事件数据的MCP(Model Context Protocol)服务器,专为药物安全性评估和不良事件对照分析设计。通过ClinicalTrials.gov API v2提供临床试验数据的智能分析功能。

功能特性

  • 临床试验搜索: 使用ClinicalTrials.gov API v2搜索临床试验数据
  • 不良事件对照分析: 对比分析特定药物与安慰剂/阳性对照药的不良事件风险
  • 安全性特征分析: 提供药物安全性的基线参考和证据补强
  • 剂量-反应关系: 分析不同剂量下的风险差异验证
  • 研究详情获取: 获取特定NCT ID的详细临床试验信息

可用工具

1. search_clinical_trials

搜索临床试验,支持多种查询条件。

参数:

  • condition (string): 医疗条件或疾病,如 "lung cancer", "diabetes"
  • intervention (string): 药物或干预措施名称,如 "Vemurafenib", "chemotherapy"
  • outcome (string): 结果指标,如 "overall survival", "adverse events"
  • sponsor (string): 研究赞助方,如 "National Cancer Institute"
  • status (string): 研究状态,如 "RECRUITING", "COMPLETED"
  • location (string): 研究地点,如 "New York", "United States"
  • nct_id (string): 特定NCT ID,如 "NCT04267848"
  • pageSize (number): 返回记录数限制 (1-1000)
  • countTotal (boolean): 是否统计总数

2. get_study_details

获取特定临床试验的详细信息。

参数:

  • nct_id (string, 必需): 研究的NCT ID,如 "NCT04267848"

3. compare_adverse_events

核心功能: 对比分析特定药物的不良事件数据,提供基线参考和安全性评估。

参数:

  • drug_name (string, 必需): 要分析的药物名称
  • control_type (string): 对照类型
    • "placebo": 与安慰剂对比(默认)
    • "active_control": 与其他药物对比
    • "dose_comparison": 不同剂量对比
  • condition (string): 医疗条件,用于聚焦搜索
  • limit (number): 分析的研究数量限制 (1-50)

4. analyze_safety_profile

核心功能: 分析药物的安全性特征,提供风险评估和剂量-反应关系。

参数:

  • drug_name (string, 必需): 要分析的药物名称
  • condition (string): 医疗条件背景
  • include_completed_only (boolean): 仅包含已完成的研究(默认true)
  • limit (number): 分析的研究数量限制 (1-100)

核心功能说明

不良事件对照分析

本服务器的核心功能是通过对比分析特定药物临床试验中的不良事件数据,为药物安全性特征提供科学依据:

  1. 基线参考: 与安慰剂或阳性对照药的风险对比
  2. 证据补强: 不同剂量下的风险差异验证
  3. 风险评估: 基于多项研究的综合安全性分析
  4. 统计分析: 不良事件发生率、严重程度分级等

API数据源

安装和运行

本地开发

# 安装依赖
npm install

# 开发模式运行
npm run dev

# 构建
npm run build

# 生产模式运行
npm start

Ubuntu服务器部署

1. 环境准备
# 更新系统
sudo apt update && sudo apt upgrade -y

# 安装Node.js 18+
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs

# 验证安装
node --version
npm --version
2. 部署MCP服务器
# 创建项目目录
mkdir -p ~/mcp-servers/clinicaltrials
cd ~/mcp-servers/clinicaltrials

# 上传项目文件(使用scp或git clone)
# 方法1: 使用git
git clone <your-repo-url> .

# 方法2: 使用scp从本地上传
# scp -r /path/to/mcp-openfda/* user@your-server:~/mcp-servers/openfda/

# 安装依赖
npm install

# 构建项目
npm run build

# 测试运行
npm start
3. 使用PM2管理进程(推荐)
# 全局安装PM2
sudo npm install -g pm2

# 创建PM2配置文件
cat > ecosystem.config.js << 'EOF'
module.exports = {
  apps: [{
    name: 'mcp-clinicaltrials',
    script: 'dist/index.js',
    cwd: '/home/ubuntu/mcp-servers/clinicaltrials',
    instances: 1,
    autorestart: true,
    watch: false,
    max_memory_restart: '1G',
    env: {
      NODE_ENV: 'production'
    }
  }]
}
EOF

# 启动服务
pm2 start ecosystem.config.js

# 设置开机自启
pm2 startup
pm2 save

# 查看状态
pm2 status
pm2 logs mcp-clinicaltrials
4. 配置防火墙(如果需要网络访问)
# 如果需要通过网络访问,可以配置nginx反向代理
sudo apt install nginx

# 创建nginx配置
sudo tee /etc/nginx/sites-available/mcp-clinicaltrials << 'EOF'
server {
    listen 80;
    server_name your-domain.com;  # 替换为你的域名或IP
    
    location / {
        proxy_pass http://localhost:3000;  # 如果MCP服务器监听3000端口
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_cache_bypass $http_upgrade;
    }
}
EOF

# 启用站点
sudo ln -s /etc/nginx/sites-available/mcp-clinicaltrials /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx

远程调用配置

方法1: 通过SSH隧道

在客户端机器上创建SSH隧道:

# 创建SSH隧道,将本地端口转发到服务器
ssh -L 3000:localhost:3000 user@your-server-ip

# 然后在MCP客户端配置中使用 localhost:3000

方法2: 网络MCP服务器

如果需要通过网络直接访问,需要修改MCP服务器以支持网络传输:

// 在src/index.ts中添加网络传输支持
import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";

// 替换stdio传输为网络传输
const transport = new SSEServerTransport("/message", response);

方法3: 使用Docker部署

# 创建Dockerfile
cat > Dockerfile << 'EOF'
FROM node:18-alpine

WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production

COPY dist/ ./dist/
COPY src/ ./src/

EXPOSE 3000

CMD ["npm", "start"]
EOF

# 构建和运行
docker build -t mcp-clinicaltrials .
docker run -d -p 3000:3000 --name mcp-clinicaltrials-server mcp-clinicaltrials

使用示例

在Claude Desktop中配置

在Claude Desktop的配置文件中添加:

{
  "mcpServers": {
    "clinicaltrials": {
      "command": "node",
      "args": ["/path/to/mcp-clinicaltrials/dist/index.js"],
      "env": {}
    }
  }
}

远程服务器配置

{
  "mcpServers": {
    "clinicaltrials": {

Tools (4)

search_clinical_trialsSearch clinical trials using various criteria like condition, intervention, and status.
get_study_detailsRetrieve detailed information for a specific clinical trial by its NCT ID.
compare_adverse_eventsCompare adverse event data for a specific drug against placebos or other controls.
analyze_safety_profileAnalyze the safety profile of a drug, including risk assessment and dose-response relationships.

Configuration

claude_desktop_config.json
{"mcpServers": {"clinicaltrials": {"command": "node", "args": ["/path/to/mcp-clinicaltrials/dist/index.js"]}}}

Try it

Search for all recruiting clinical trials for lung cancer involving Vemurafenib.
Get the full study details for NCT04267848.
Compare the adverse event profile of my drug against a placebo for diabetes.
Analyze the safety profile of chemotherapy in completed clinical trials.

Frequently Asked Questions

What are the key features of ClinicalTrials.gov MCP?

Search clinical trial data using ClinicalTrials.gov API v2. Perform comparative analysis of adverse events between drugs and controls. Evaluate drug safety profiles and dose-response relationships. Retrieve comprehensive study details using NCT identifiers.

What can I use ClinicalTrials.gov MCP for?

Researchers conducting meta-analyses on drug safety and efficacy. Medical professionals evaluating the risk profile of new interventions. Clinical trial coordinators monitoring competitive study statuses. Pharmacologists analyzing adverse event rates across different patient cohorts.

How do I install ClinicalTrials.gov MCP?

Install ClinicalTrials.gov MCP by running: git clone <your-repo-url> . && npm install && npm run build

What MCP clients work with ClinicalTrials.gov MCP?

ClinicalTrials.gov MCP works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep ClinicalTrials.gov MCP docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare