Clinical Trials MCP Server

Clinical Trials MCP Server

Enables searching and retrieving detailed clinical trial information from ClinicalTrials.gov via the official API.

Category
Visit Server

README

Clinical Trials MCP Server

A Model Context Protocol (MCP) server that provides access to clinical trials data from ClinicalTrials.gov. This server allows Claude Desktop to search for and retrieve detailed information about clinical trials using the official ClinicalTrials.gov API v2.

Features

  • šŸ” Comprehensive Search: Search clinical trials by condition, intervention, location, age group, study type, and recruitment status
  • šŸ“‹ Detailed Trial Information: Get complete details for specific trials by NCT ID
  • 🌐 ClinicalTrials.gov API v2: Uses the official API with proper parameter mapping and error handling
  • šŸ“„ Pagination Support: Handle large result sets efficiently with configurable page sizes
  • šŸ›”ļø Robust Error Handling: Comprehensive error handling and data validation
  • šŸ“Š Structured Data: Clean, structured output optimized for Claude Desktop integration

Installation

  1. Clone or download this repository to your local machine

  2. Create a virtual environment (recommended):

python -m venv .venv
.venv\Scripts\Activate.ps1
  1. Install dependencies:
pip install -r requirements.txt

Configuration for Claude Desktop

Add this server to your Claude Desktop configuration file:

Windows

Edit %APPDATA%\Claude\claude_desktop_config.json:

{
  "mcpServers": {
    "clinical-trials": {
      "command": "python",
      "args": ["c:\\Users\\%username%\\Dev Code\\Clinical Trial Gov - MCP\\mcp_server.py"],
      "env": {}
    }
  }
}

macOS

Edit ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "clinical-trials": {
      "command": "python",
      "args": ["/path/to/your/mcp_server.py"],
      "env": {}
    }
  }
}

Linux

Edit ~/.config/claude/claude_desktop_config.json:

{
  "mcpServers": {
    "clinical-trials": {
      "command": "python",
      "args": ["/path/to/your/mcp_server.py"],
      "env": {}
    }
  }
}

After configuration: Restart Claude Desktop to load the new server.

Available Tools

1. search_clinical_trials

Search for clinical trials with comprehensive filtering options.

Parameters (all optional):

  • condition: Medical condition or disease (e.g., "diabetes", "cancer", "heart disease")
  • intervention: Treatment or intervention (e.g., "insulin", "chemotherapy", "surgery")
  • location: Geographic location (e.g., "New York", "California", "United States")
  • age_group: Age group (e.g., "child", "adult", "older_adult")
  • study_type: Type of study ("interventional" or "observational")
  • status: Study recruitment status:
    • "recruiting" - Currently recruiting participants
    • "not_yet_recruiting" - Will recruit in the future
    • "active" - Active but not recruiting
    • "completed" - Study completed
    • "suspended" - Temporarily suspended
    • "terminated" - Terminated early
    • "withdrawn" - Withdrawn before enrollment
    • "enrolling" - Enrolling by invitation only
  • page_size: Results per page (1-100, default: 10)
  • max_pages: Maximum pages to retrieve (1-10, default: 2)

2. get_trial_details

Get comprehensive details for a specific clinical trial.

Parameters:

  • nct_id (required): NCT ID of the clinical trial (format: "NCT" + 8 digits, e.g., "NCT05123456")

Usage Examples

After configuring the server in Claude Desktop, you can ask Claude questions like:

  • Basic searches: "Find clinical trials for diabetes"
  • Location-specific: "Find recruiting cancer trials in California"
  • Intervention-focused: "Search for immunotherapy trials for melanoma"
  • Status filtering: "Show me completed trials for heart disease"
  • Age-specific: "Find pediatric studies for asthma"
  • Detailed lookup: "Get details for trial NCT05123456"
  • Complex queries: "Find recruiting interventional diabetes trials in New York for adults"

Development & Testing

Direct Testing

Test the server directly:

python mcp_server.py

API Testing

Test specific API endpoints:

python test_api.py

Debug Mode

The server includes comprehensive logging. Check console output for debugging information.

Project Structure

Clinical Trial Gov - MCP/
ā”œā”€ā”€ mcp_server.py           # Main MCP server implementation
ā”œā”€ā”€ ClinicalTrialsGovAPI.py # Original API client (reference)
ā”œā”€ā”€ test_api.py            # API parameter testing script
ā”œā”€ā”€ test_server.py         # Server testing utilities
ā”œā”€ā”€ requirements.txt       # Python dependencies
ā”œā”€ā”€ pyproject.toml        # Python project configuration
ā”œā”€ā”€ README.md             # This file
└── .gitignore           # Git ignore patterns

API Reference

  • ClinicalTrials.gov API v2: https://clinicaltrials.gov/data-api/api
  • Model Context Protocol: https://modelcontextprotocol.io/
  • Claude Desktop MCP Integration: https://claude.ai/docs/mcp

Troubleshooting

Common Issues

  1. Server not appearing in Claude Desktop:

    • Check the configuration file path and syntax
    • Restart Claude Desktop after configuration changes
    • Verify Python path in the configuration
  2. Import errors:

    • Ensure virtual environment is activated
    • Run pip install -r requirements.txt
  3. API errors:

    • Check internet connectivity
    • Review server logs for detailed error messages

Logs

The server provides detailed logging. Check the console output when running the server for debugging information.

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.

License

This project is open source and available under the MIT License.


Note: This server uses the official ClinicalTrials.gov API v2 and is designed to provide accurate, up-to-date clinical trial information for research and educational purposes.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured