mcp-agentic-rag
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
MCP Agentic RAG
A production-ready Retrieval-Augmented Generation (RAG) system exposed as an MCP tool. The system searches a local vector knowledge base first; if the query doesn't match well enough, it falls back to live web search. Either way, an LLM generates a grounded, cited answer.
Architecture
User query (via MCP client e.g. Cursor, Claude Desktop)
│
▼
┌───────────────────┐
│ MCP Server │ server.py
│ ask_ml_knowledge │
└────────┬──────────┘
│
▼
┌───────────────────┐
│ Embed query │ nomic-embed-text-v1.5
└────────┬──────────┘
│
▼
┌───────────────────┐
│ Search Qdrant │ cosine similarity
└────────┬──────────┘
│
score >= 0.45?
/ \
YES NO
│ │
▼ ▼
RAG context Bright Data
(local KB) web search
│ │
└──────┬───────┘
▼
┌─────────────────┐
│ LLM generates │ OpenAI / local model
│ grounded answer│
└────────┬────────┘
▼
Answer + numbered sourcesRelated MCP server: MCP RAG Server
Project Structure
mcp-agentic-rag/
├── data/ # Knowledge base documents
│ ├── machine_learning.txt
│ ├── deep_learning.txt
│ ├── neural_networks.txt
│ ├── cnn.txt
│ ├── rnn.txt
│ ├── transformers.txt
│ ├── optimization.txt
│ └── regularization.txt
├── eval/
│ └── eval_retrieval.py # Recall@3 evaluation (30 questions)
├── rag_code.py # EmbedData, QdrantVDB, Retriever, AnswerGenerator
├── ingest.py # One-time ingestion script
├── server.py # MCP server entry point
├── docker-compose.yml # Qdrant vector database
├── requirements.txt
├── .env.example # Copy to .env and fill in credentials
└── notebook.ipynb # Interactive exploration notebookSetup
1. Prerequisites
Python 3.11+
2. Install dependencies
pip install -r requirements.txt3. Configure environment
cp .env.example .envEdit .env and fill in at minimum:
Variable | Required | Description |
| Yes | OpenAI API key for answer generation |
| No | Model name (default: |
| No | Custom endpoint for local LLMs (Ollama, LM Studio) |
| No | Qdrant URL (default: |
| No | Similarity cutoff for web fallback (default: |
| No | Bright Data SERP credentials (web fallback only) |
| No | Bright Data SERP credentials (web fallback only) |
4. Start Qdrant
docker compose up -dQdrant dashboard: http://localhost:6333/dashboard
5. Ingest the knowledge base
python ingest.pyThis embeds all documents in data/ and uploads them to Qdrant.
Re-run with --reset after updating documents:
python ingest.py --reset6. Register the MCP server
Add the following to your MCP client configuration (e.g. Cursor mcp.json,
Claude Desktop claude_desktop_config.json):
{
"mcpServers": {
"mcp-agentic-rag": {
"command": "python",
"args": ["/absolute/path/to/server.py"]
}
}
}The server is now available. Your AI assistant will automatically call
ask_ml_knowledge_base when relevant.
Using a Local LLM (no OpenAI account needed)
Install Ollama and pull a model:
ollama pull llama3.2Set in .env:
OPENAI_BASE_URL=http://localhost:11434/v1
OPENAI_API_KEY=ollama
OPENAI_MODEL=llama3.2Evaluation
Run the built-in Recall@3 evaluation on 30 domain-specific questions (requires Qdrant running with the collection ingested):
python eval/eval_retrieval.pySave full results to JSON:
python eval/eval_retrieval.py --output eval/results.jsonExample output:
============================================================
Results Summary
============================================================
Total questions : 30
Correct (hit) : 26
Missed : 4
Recall@3 : 26/30 = 86.7%
============================================================Adding More Documents
Create a
.txtfile indata/with this header format:
TITLE: Your Document Title
SOURCE: your_file.txt
URL: https://optional-reference-url.com
---
First chunk of text goes here.
---
Second chunk of text goes here.Re-ingest:
python ingest.py --resetLicense
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Search your knowledge bases from any AI assistant using hybrid RAG.
Private, multimodal knowledge store for agents: hybrid search with cited, provenance-backed results.
Agent-native search engine with live web research optimized for AI agents.
Cloud or self-hosted knowledge for AI agents: hybrid search, reranking, GraphRAG, scoped MCP tools.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to search through structured databases and unstructured content (documents, videos, files) using natural language queries with semantic understanding.MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to search and retrieve information from your knowledge base using RAG (Retrieval-Augmented Generation) with hybrid search, document indexing, and ChromaDB vector storage.35 npmMIT
- AlicenseNot gradedqualityDmaintenanceEnables AI coding assistants to search and retrieve information from a locally ingested knowledge base using hybrid search, grounded in user-curated documentation.17MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to perform semantic, hybrid, and filtered search on indexed local documentation with RAG capabilities.2MIT