ClinicalTrials.gov MCP server

Integrates with ClinicalTrials.gov REST API to search clinical trials by conditions, interventions, locations, and status, plus retrieve detailed study information by NCT ID with automatic data cleaning and local backup storage.
Back to servers
Setup instructions
Provider
cyanheads
Release date
Jun 18, 2025
Stats
14 stars

The ClinicalTrials.gov MCP server empowers AI agents with programmatic access to the ClinicalTrials.gov database. This server implements the Model Context Protocol (MCP) to provide a robust interface for searching, retrieving, and analyzing clinical study data from the official ClinicalTrials.gov v2 API.

Installation

Prerequisites

  • Node.js (>=18.0.0)
  • npm (comes with Node.js)

MCP Client Configuration

Add the following to your MCP client's configuration file (e.g., cline_mcp_settings.json):

{
  "mcpServers": {
    "clinicaltrialsgov-mcp-server": {
      "command": "npx",
      "args": ["clinicaltrialsgov-mcp-server"],
      "env": {
        "MCP_LOG_LEVEL": "info"
      }
    }
  }
}

Manual Installation

Install via npm

npm install clinicaltrialsgov-mcp-server

Install from Source

git clone https://github.com/cyanheads/clinicaltrialsgov-mcp-server.git
cd clinicaltrialsgov-mcp-server
npm install
npm run build

Configuration

Environment Variables

Variable Description Default
MCP_TRANSPORT_TYPE Transport mechanism: stdio or http stdio
MCP_HTTP_PORT Port for the HTTP server (if using HTTP transport) 3010
MCP_HTTP_HOST Host address for the HTTP server 127.0.0.1
MCP_ALLOWED_ORIGINS Comma-separated list of allowed origins for CORS (none)
MCP_LOG_LEVEL Logging level (debug, info, etc.) debug
MCP_AUTH_MODE Authentication mode for HTTP: jwt or oauth jwt
MCP_AUTH_SECRET_KEY Secret key for JWT authentication (minimum 32 characters) (none)
CLINICALTRIALS_DATA_PATH Directory for caching ClinicalTrials.gov API data data/
LOGS_DIR Directory for log file storage logs/
NODE_ENV Runtime environment (development, production) development

Available Tools

The server provides three main tools for interacting with ClinicalTrials.gov:

Search Studies

The clinicaltrials_search_studies tool searches for clinical studies with various filters and pagination options.

Key Parameters:

  • query: Free-text search terms
  • filter: Structured filters (status, location, etc.)
  • fields: Specific data fields to retrieve
  • sort: Sorting criteria
  • pageSize: Number of results per page
  • pageToken: Token for pagination
  • countTotal: Whether to include total result count

Get Study

The clinicaltrials_get_study tool fetches detailed information for specific studies by their NCT IDs.

Key Parameters:

  • nctIds: Array of NCT identifiers (e.g., "NCT04368728")
  • summaryOnly: Return concise study information if true
  • markupFormat: Format for formatted text fields
  • fields: Specific data fields to retrieve

Analyze Trends

The clinicaltrials_analyze_trends tool performs statistical analysis on clinical trials.

Key Parameters:

  • analysisType: Type of analysis (e.g., "status", "country", "sponsor", "phase")
  • query: Free-text search terms to filter studies
  • filter: Structured filters for the analysis

Running the Server

# Start with stdio transport (default)
npm start

# Start with HTTP transport
npm run start:http

# Test locally with the MCP inspector tool
npm run inspector

Example Usage

To use these tools, send appropriate MCP requests to the server with the required parameters. The server will process these requests and return structured data from ClinicalTrials.gov.

For example, to search for COVID-19 vaccine trials in Phase 3:

{
  "tool": "clinicaltrials_search_studies",
  "parameters": {
    "query": "COVID-19 vaccine",
    "filter": {
      "phase": ["Phase 3"],
      "status": ["Recruiting", "Active, not recruiting"]
    },
    "pageSize": 10
  }
}

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "clinicaltrialsgov-mcp-server" '{"command":"npx","args":["clinicaltrialsgov-mcp-server"],"env":{"MCP_LOG_LEVEL":"info"}}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "clinicaltrialsgov-mcp-server": {
            "command": "npx",
            "args": [
                "clinicaltrialsgov-mcp-server"
            ],
            "env": {
                "MCP_LOG_LEVEL": "info"
            }
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "clinicaltrialsgov-mcp-server": {
            "command": "npx",
            "args": [
                "clinicaltrialsgov-mcp-server"
            ],
            "env": {
                "MCP_LOG_LEVEL": "info"
            }
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later