Clinical Trials MCP Server
Enables searching and retrieving detailed clinical trial information from ClinicalTrials.gov via the official API.
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
-
Clone or download this repository to your local machine
-
Create a virtual environment (recommended):
python -m venv .venv
.venv\Scripts\Activate.ps1
- 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
-
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
-
Import errors:
- Ensure virtual environment is activated
- Run
pip install -r requirements.txt
-
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
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
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.
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.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
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.
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.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
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.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.