# Clinical Doc Intelligence

> AI-powered FDA drug label intelligence platform — production RAG with 5-stage retrieval, multi-agent orchestration, clinical guardrails, and 54 automated tests

- **Type:** MCP server
- **Install:** `agentstack add mcp-erickyegon-clinical-doc-intelligence`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [erickyegon](https://agentstack.voostack.com/s/erickyegon)
- **Installs:** 0
- **Category:** [AI & ML](https://agentstack.voostack.com/c/ai-and-ml)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [erickyegon](https://github.com/erickyegon)
- **Source:** https://github.com/erickyegon/clinical-doc-intelligence

## Install

```sh
agentstack add mcp-erickyegon-clinical-doc-intelligence
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Clinical Document Intelligence Platform

[](https://github.com/erickyegon/clinical-doc-intelligence/actions/workflows/ci.yml)
[](LICENSE)
[](https://www.python.org/downloads/)

**AI-powered FDA drug label intelligence system for regulatory analysis, formulary decision support, and competitive intelligence.**

> Built by [Erick K. Yegon, PhD](https://linkedin.com/in/erickyegon) — Director-level Data Scientist & Epidemiologist with 17+ years in global health analytics.

---

## The Problem

Pharmaceutical HEOR teams, formulary committees, and regulatory analysts spend **40+ hours per drug** manually reviewing FDA labels, comparing safety profiles across drug classes, and tracking label changes. This work is repetitive, error-prone, and doesn't scale.

## The Solution

A production-grade RAG (Retrieval-Augmented Generation) system that:

- **Ingests** 70,000+ FDA drug labels from the openFDA API and clinical trial data from ClinicalTrials.gov
- **Indexes** content with section-aware chunking that never splits safety-critical sections (Black Box Warnings, Contraindications)
- **Retrieves** relevant information using hybrid search: dense vector retrieval → metadata filtering → section priority boosting → MMR diversification → cross-encoder re-ranking
- **Generates** citation-grounded answers with source traceability back to specific label sections
- **Compares** drug labels across products for competitive intelligence and formulary decisions
- **Guards** against PHI exposure, prompt injection, unsupported clinical claims, and hallucination

---

## Architecture

```
┌─────────────────────────────────────────────────────────────────────┐
│                        FastAPI REST API                              │
│              /query    /compare    /drugs    /health                 │
├────────────┬────────────────────────────────────┬───────────────────┤
│  INPUT     │        RAG PIPELINE                │    OUTPUT         │
│ GUARDRAILS │                                    │   GUARDRAILS      │
│            │  ┌──────────────────────────────┐  │                   │
│ • PHI      │  │  Query Rewrite (Module 6)    │  │ • Confidence      │
│   Detection│  │  ↓                           │  │   threshold       │
│ • Injection│  │  Hybrid Retrieval (Module 7) │  │ • Citation        │
│   Defense  │  │  • Dense vector search       │  │   validation      │
│ • Schema   │  │  • Metadata filtering        │  │ • Unsupported     │
│   Validate │  │  • Section priority boost    │  │   claim detection │
│            │  │  • MMR diversification       │  │ • Clinical        │
│            │  │  • Cross-encoder re-rank     │  │   disclaimer      │
│            │  │  ↓                           │  │                   │
│            │  │  Context Assembly (Module 8)  │  │                   │
│            │  │  ↓                           │  │                   │
│            │  │  LLM Generation (Module 3)   │  │                   │
│            │  │  • Provider switching         │  │                   │
│            │  │  • Cost tracking             │  │                   │
│            │  │  • Automatic fallback        │  │                   │
│            │  │  ↓                           │  │                   │
│            │  │  Citation Extraction         │  │                   │
│            │  └──────────────────────────────┘  │                   │
├────────────┴────────────────────────────────────┴───────────────────┤
│                     DATA LAYER                                       │
│  ┌──────────────┐  ┌──────────────┐  ┌────────────────────────────┐ │
│  │ openFDA API  │  │ ClinicalTrial│  │ ChromaDB Vector Store      │ │
│  │ 70K+ labels  │  │ .gov API V2  │  │ Section-aware chunks       │ │
│  │              │  │ 400K+ trials │  │ Metadata: drug, section,   │ │
│  │              │  │              │  │ therapeutic area, safety    │ │
│  └──────────────┘  └──────────────┘  └────────────────────────────┘ │
├─────────────────────────────────────────────────────────────────────┤
│                    EVALUATION (Module 10)                             │
│  Faithfulness | Relevance | Citation Accuracy | Safety Completeness  │
│  Latency | Token Cost | Error Rate                                   │
└─────────────────────────────────────────────────────────────────────┘
```

---

## Key Features

### 1. Clinical Q&A with Citations
Ask questions about any FDA-approved drug and receive answers grounded in official label data with section-level citations.

```
Query: "What are the contraindications for empagliflozin?"

Answer: Empagliflozin (JARDIANCE) is contraindicated in patients with severe 
renal impairment (eGFR  0.85 |
| Faithfulness | Answer grounded in retrieved context | > 0.90 |
| Citation Accuracy | All citations valid and traceable | > 0.95 |
| Safety Completeness | Safety info included when relevant | > 0.95 |
| Latency (p95) | End-to-end response time | < 5s |
| Cost per Query | Average LLM cost | < $0.03 |

---

## Project Structure

```
clinical-doc-intel/
├── app.py                       # Streamlit interactive frontend
├── .streamlit/config.toml       # Streamlit theme & config
├── .github/workflows/ci.yml     # GitHub Actions CI/CD pipeline
├── Makefile                     # One-command operations
├── config/
│   ├── settings.py              # Central configuration
│   └── prompts.yaml             # Jinja2 prompt templates
├── src/
│   ├── ingestion/
│   │   ├── fda_labels.py        # openFDA API client
│   │   ├── clinical_trials.py   # ClinicalTrials.gov V2 client
│   │   └── pipeline.py          # Ingestion orchestration
│   ├── processing/
│   │   ├── chunker.py           # Section-aware chunking
│   │   └── metadata.py          # Metadata enrichment
│   ├── retrieval/
│   │   ├── vector_store.py      # ChromaDB management
│   │   └── hybrid_search.py     # Multi-stage retrieval + re-ranking
│   ├── generation/
│   │   └── rag_chain.py         # RAG pipeline with citations
│   ├── orchestration/
│   │   └── model_router.py      # Multi-provider LLM routing
│   ├── guardrails/
│   │   └── validators.py        # Input/output safety validation
│   ├── evaluation/
│   │   └── evaluator.py         # RAG evaluation framework
│   └── api/
│       └── main.py              # FastAPI application
├── scripts/
│   ├── seed_data.py             # Download FDA label data
│   └── ingest.py                # Index data into vector store
├── tests/
│   └── test_platform.py         # Comprehensive test suite
├── docs/adr/
│   ├── 001-vector-store-selection.md
│   └── 002-llm-provider-strategy.md
├── deployment/
│   └── (AWS ECS task definitions, CI/CD configs)
├── Dockerfile                   # Multi-stage production build
├── docker-compose.yml           # Local dev + production profiles
├── requirements.txt
├── .env.example
└── README.md
```

---

## Course Module Coverage

This project implements concepts from across the Full Stack Generative AI BootCamp:

| Module | Topic | Implementation |
|--------|-------|---------------|
| 1 | Foundations of GenAI | Embeddings, vector space, similarity |
| 3 | API for Accessing LLMs | Multi-provider router (OpenAI/Groq/Bedrock) |
| 5 | LLM Hosting & API | FastAPI endpoint exposure |
| 6 | Prompt Engineering | YAML prompt library, Jinja2 templates, CoT |
| 7 | RAG Systems | Full pipeline: ingest → chunk → embed → retrieve → generate |
| 8 | Advanced RAG | Query rewriting, re-ranking, caching, multimodal |
| 10 | Evaluation | Faithfulness, relevance, safety metrics, cost tracking |
| 11 | Guardrails | PHI detection, injection defense, output validation |
| 12 | MCP | Standardized tool interfaces (extensible) |
| 16 | E2E Deployment | Docker, FastAPI, cloud-native architecture |

---

## Related Projects

- **[Medicare RAF Pipeline](https://github.com/erickyegon/medicare-raf-prototypes)** — Risk adjustment factor prediction for Medicare Advantage (ATT −$391/member)
- **RWE Evidence Synthesis Agent** — Multi-agent system for systematic literature review automation (coming soon)
- **HEDIS/STARS Quality Agent** — Automated care gap identification for managed care (coming soon)

---

## License

MIT

---

## Contact

**Erick K. Yegon, PhD**  
Director-Level Data Science & Epidemiology  
📧 keyegonaws@gmail.com  
🔗 [LinkedIn](https://linkedin.com/in/erickyegon) | [GitHub](https://github.com/erickyegon) | [ORCID](https://orcid.org/0000-0002-7055-4848)

## Source & license

This open-source MCP server is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [erickyegon](https://github.com/erickyegon)
- **Source:** [erickyegon/clinical-doc-intelligence](https://github.com/erickyegon/clinical-doc-intelligence)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** yes
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** yes
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/mcp-erickyegon-clinical-doc-intelligence
- Seller: https://agentstack.voostack.com/s/erickyegon
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
