home / mcp / clinicaltrials nlp mcp server
Queries ClinicalTrials.gov with natural language, translating queries to API parameters and returning parsed results.
Configuration
View docs{
"mcpServers": {
"huaiyuzhang-clinical-trial-mcp": {
"url": "http://127.0.0.1:8000",
"headers": {
"OPENAI_API_KEY": "sk-..."
}
}
}
}You can query ClinicalTrials.gov with natural language through this MCP server. It uses a language model to translate your plain-English questions into API parameters and then returns both the parsed parameters and the resulting trials data in a structured format, making complex searches fast and approachable.
Start the MCP server locally and use a client to send natural language queries. Your client should send a plain text query to the server’s query endpoint, and you will receive a structured response that includes both the interpreted parameters and the matching ClinicalTrials.gov results.
# Prerequisites
- Python 3.8+
- Internet access
# Install dependencies
pip install -r requirements.txt
# Set your OpenAI API key
export OPENAI_API_KEY=sk-...
# Run the server
uvicorn server:app --reloadUsage notes: you can submit natural language questions like “Show me completed phase 3 diabetes trials in Canada” and receive results that include the parsed API parameters and the corresponding trials data.
Security: protect your OpenAI API key and limit access to the local server. Do not expose the key in client-side code or logs.
POST http://127.0.0.1:8000/query
Content-Type: application/json
{"query": "Show me completed phase 3 diabetes trials in Canada"}You can adjust the prompt or add more parameter mappings in the server code to support additional APIs or query types. This enables you to tailor the natural language interface to your data needs.
Converts natural language queries into ClinicalTrials.gov API parameters using an LLM, returning a structured parameter map.
Calls the ClinicalTrials.gov API with the translated parameters and returns raw results.