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.
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"
}
}
}
}
npm install clinicaltrialsgov-mcp-server
git clone https://github.com/cyanheads/clinicaltrialsgov-mcp-server.git
cd clinicaltrialsgov-mcp-server
npm install
npm run build
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 |
The server provides three main tools for interacting with ClinicalTrials.gov:
The clinicaltrials_search_studies
tool searches for clinical studies with various filters and pagination options.
Key Parameters:
query
: Free-text search termsfilter
: Structured filters (status, location, etc.)fields
: Specific data fields to retrievesort
: Sorting criteriapageSize
: Number of results per pagepageToken
: Token for paginationcountTotal
: Whether to include total result countThe 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 truemarkupFormat
: Format for formatted text fieldsfields
: Specific data fields to retrieveThe 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 studiesfilter
: Structured filters for the analysis# 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
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
}
}
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.
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.
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"
}
}
}
}
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.
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.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.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