pharma-rag-mcp
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@pharma-rag-mcpWhat are the clinical trial outcomes for Farxiga?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
pharma-rag-mcp
A fully local, end-to-end Retrieval-Augmented Generation (RAG) system for pharmaceutical sales intelligence — built with LangChain, ChromaDB, Ollama, and the Model Context Protocol (MCP).
The system ingests drug labels, clinical trial documents, and sales call notes into a local vector database, exposes them as MCP tools, and answers natural-language questions through a LangGraph ReAct agent backed by a locally-running LLM.
Architecture
data/sources/ ← raw .txt files (drug labels, trials, call notes)
│
▼
data/ingest.py ← loads, splits into chunks, embeds with all-MiniLM-L6-v2
│
▼
chroma_db/ ← persisted ChromaDB collections (384-dim vectors)
├── drug_info/
├── competitor_intel/
└── pitch_content/
│
▼
mcp_server/server.py ← MCP server over stdio — exposes 4 retrieval tools
│ (MCP JSON-RPC)
▼
agent/agent.py ← LangGraph ReAct agent (ChatOllama + MCP tools)
│
▼
ui/app.py ← Gradio chat interface (browser)Supporting modules
Module | Purpose |
| HuggingFace embedding model wrapper ( |
| ChromaDB collection builder / loader |
| Retrieval quality evaluation (Hit Rate, MRR, Context Precision) |
Related MCP server: DocAgent-MCP
Knowledge Base
11 drugs × 3 document types = 33 source files:
Collection | Source folder | Contents |
|
| FDA-style drug label summaries |
|
| Clinical trial outcomes |
|
| Sales rep call transcripts |
Drugs: Dupixent, Eliquis, Entresto, Farxiga, Fasenra, Jardiance, Rinvoq, Skyrizi, Trelegy Ellipta, Trulicity, Xarelto
Prerequisites
Python 3.13+
Ollama running locally with a model pulled:
ollama pull llama3.2A Python virtual environment with dependencies installed (see Setup).
Setup
# 1. Clone and enter the project
git clone <repo-url>
cd pharma-rag-mcp
# 2. Create and activate a virtual environment
python -m venv .venv
# Windows:
.venv\Scripts\activate
# macOS / Linux:
source .venv/bin/activate
# 3. Install dependencies
pip install -r requirements.txt
# 4. Configure environment (optional — defaults work out of the box)
cp .env.example .env
# Edit .env to set OLLAMA_MODEL and OLLAMA_BASE_URL if needed
# 5. Build the vector database (only needed once)
python -m data.run_ingestRunning the System
Each layer can be used independently. Start Ollama before using the agent or UI.
Agent (CLI)
python -m agent.agentInteractive command-line chat with two-tier memory:
Session memory — every turn's query, tools called, source mode, and answer are held in RAM for the current run.
Long-term memory — on exit, the session is appended (with timestamps) to
memory/long_term.jsonon disk.
Type any of bye, close, end, exit, goodbye, quit to exit — the agent will print a session summary and flush memory before quitting.
Answer source modes
The agent detects and labels how each answer was produced:
Badge | Meaning |
| Answer grounded entirely in retrieved chunks |
| Retrieved facts combined with general expertise; out-of-KB points marked |
| Tools returned nothing relevant; answered from general pharma/sales knowledge |
Multi-turn context
The agent passes the last N turns of conversation history to the LLM on each question, so follow-up questions like "he ignored me, how do I re-engage?" are answered in context. N is controlled by config.yaml:
agent:
history_window: 3 # number of prior turns to includeGradio UI (browser)
python -m ui.appOpens a chat interface at http://localhost:7860.
MCP Server only (stdio transport)
python -m mcp_server.serverLoads the three ChromaDB collections and waits for MCP JSON-RPC messages on stdin.
Registered tools:
Tool | Description |
| Search drug label documents |
| Search clinical trial data |
| Search sales call notes |
| Search all three collections, merged |
Retrieval Evaluation
# Evaluate all three collections
python -m eval.evaluate
# Evaluate one collection with k=5
python -m eval.evaluate --collection drug_info --k 5Prints Hit Rate, MRR, and Context Precision per collection and in aggregate.
Configuration
File | Purpose |
| Ollama model and base URL (copy from |
| Agent behaviour (conversation history window) |
.env
Variable | Default | Description |
|
| Ollama model name (must be pulled first) |
|
| Ollama HTTP daemon URL |
config.yaml
agent:
history_window: 3 # prior turns passed to LLM for multi-turn contextProject Structure
pharma-rag-mcp/
├── config.yaml # Agent configuration
├── data/
│ ├── ingest.py # IngestionPipeline class
│ ├── run_ingest.py # CLI: build + spot-check all collections
│ └── sources/
│ ├── drug_labels/ # 11 × drug label .txt files
│ ├── clinical_trials/# 11 × clinical trial .txt files
│ └── call_notes/ # 11 × sales call note .txt files
├── rag/
│ ├── embeddings.py # EmbeddingModel (all-MiniLM-L6-v2)
│ └── vectorstore.py # VectorStoreManager (ChromaDB)
├── mcp_server/
│ ├── server.py # MCP server entrypoint (stdio)
│ └── tools.py # 4 retrieval tool definitions
├── agent/
│ └── agent.py # PharmaAgent + CLI loop with memory
├── ui/
│ └── app.py # Gradio chat UI
├── eval/
│ └── evaluate.py # Hit Rate / MRR / Context Precision
├── memory/
│ └── long_term.json # Persisted session history (auto-created)
├── chroma_db/ # Persisted vector collections (git-ignored)
├── .env.example
├── pyproject.toml
└── requirements.txtKey Design Decisions
Local-first — no cloud APIs, no API keys. Embeddings via HuggingFace, vector storage via ChromaDB, generation via Ollama.
MCP as the retrieval layer — the MCP server cleanly separates retrieval from generation. Any MCP-compatible client can call the search tools.
Adaptive answer modes — the agent automatically detects whether a question can be answered from the knowledge base alone, requires blending with general expertise, or falls entirely outside the knowledge base. Each answer is clearly labelled so the user always knows the source.
Sliding history window — only the last N turns are sent to the LLM, keeping context window usage bounded while still supporting natural multi-turn conversations.
Two-tier memory — session memory (in RAM) is flushed to a persistent JSON log on exit, giving a full audit trail of every query, tool used, source mode, and answer across all runs.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- FlicenseNot gradedqualityCmaintenanceEnables natural language queries on technical specifications and automated code compliance checks using local RAG with vector search, integrated via MCP.
- FlicenseNot gradedqualityCmaintenanceEnables local document question-answering and retrieval via MCP, supporting multi-turn conversation, intent recognition, and tools for document search, Q&A, and summarization.5
- AlicenseNot gradedqualityCmaintenanceA privacy-preserving local RAG system integrated with MCP, enabling natural language queries over ingested documents and a SQLite database through vector search and local database tools.MIT
- FlicenseNot gradedqualityCmaintenanceProvides read-only, citation-backed semantic search and retrieval-augmented generation over enterprise documents via standardized MCP tools, with local embeddings for privacy.
Related MCP Connectors
Multi-engine search for AI agents. Trust scoring, local corpus, MCP-native. Self-hostable, BYOK.
Certified SEC EDGAR fact memory for AI agents with zero hallucination and filing provenance.
Hosted MCP server exposing US hospital procedure cost data to AI assistants
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/kartikeya788/pharma-rag-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server