Clinical Trials MCP Agent

Clinical Trials MCP Agent

Enables AI agents to search and analyze clinical trial data from ClinicalTrials.gov using both structured SQL queries for filtering trials by status, phase, and conditions, and semantic vector search for exploring detailed protocol information like exclusion criteria.

Category
Visit Server

README

Enterprise Clinical Trials Agent (MCP Architecture)

This project implements a robust Retrieval-Augmented Generation (RAG) agent using the Model Context Protocol (MCP) standard. It acts as an integration middleware that fetches real-world clinical data, stores it in hybrid databases (SQL + Vector), and exposes it to LLM clients for autonomous reasoning.

🚀 Key Features

  • REST API Integration: Implements a custom ETL pipeline (etl_pipeline.py) that consumes the ClinicalTrials.gov API with pagination and error handling.
  • Hybrid Data Architecture:
    • Structured (SQL): Uses SQLite for high-precision filtering (Trial Status, Phase, Conditions).
    • Unstructured (Vector DB): Uses ChromaDB with sentence-transformers for semantic search within medical protocols.
  • MCP Server: A centralized integration server (mcp_server.py) that standardizes tools for any AI client (Claude Desktop, Cursor, IDEs).

📸 Autonomous Agent Demo

1. Backend Verification (MCP Inspector)

The server exposes structured SQL tools and Vector RAG tools via standard JSON-RPC. MCP Inspector

2. Structured Reasoning (SQL Tool)

User asks for "Diabetes trials". The Agent autonomously selects the SQL tool to filter by disease. SQL Tool Use SQL Results

3. Semantic Reasoning (RAG Tool)

User asks for specific "kidney function exclusion criteria". The Agent switches tools to perform vector search on the protocol text. RAG Tool Use RAG Results


🛠️ Installation

  1. Clone the repository:

    git clone https://github.com/tonih23/clinical-trials-mcp-agent.git
    cd clinical-trials-mcp-agent

  2. Set up the environment:

    python -m venv venv

    Windows:

    venv\Scripts\activate

    Mac/Linux:

    source venv/bin/activate

    pip install -r requirements.txt

🔄 Usage Workflow

1. Data Ingestion (ETL)

Run the pipeline to fetch live data from the API and populate local databases. This demonstrates the REST integration pattern:

python etl_pipeline.py

This will fetch the latest trials related to Oncology, Cardiology, and Diabetes.

2. Run the MCP Server (Dev Mode)

Start the integration server to test connections:

mcp dev mcp_server.py

3. Connect to LLM Client (Production-like)

To use this with an MCP-compliant client (like Claude Desktop), add this configuration to your claude_desktop_config.json:

Note: Replace the path below with the absolute path to your project folder.
On Windows, use double backslashes (\\).

{
  "mcpServers": {
    "clinical-agent": {
      "command": "python",
      "args": ["C:\\Users\\YOUR_USER\\Desktop\\clinical-trials-mcp-agent\\mcp_server.py"]
    }
  }
}

🧠 Example Queries

Once connected, the Agent can perform autonomous tool calling:

Structured Query (SQL)

"Find active Phase 3 trials for Diabetes."
(The LLM will automatically route this to search_trials_sql.)

Semantic Query (RAG)

"For trial NCT00528879, what are the specific exclusion criteria regarding kidney function?"
(The LLM will automatically route this to get_protocol_details_rag.)


Developed as a Proof of Concept for Enterprise AI Integration.

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
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
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
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