rag
Click on "Deploy 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., "@ragsearch my local documents for the 2025 product roadmap decisions"
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.
Agentic-RAG-MCP
Local-first RAG retrieval engine built as a plugin for agentic environments via the Model Context Protocol (MCP).
The agent's own model handles generation. This server retrieves relevant context — the agent reasons and answers. No redundant LLM loaded by the plugin.
Why
Agentic coding tools (opencode, Claude Desktop, Hermes, pi, …) are great at reasoning but have no memory of your documents. Agentic-RAG-MCP fills that gap:
Ingest PDFs, DOCX, code, notes → normalized Markdown → chunks → embeddings → local vector DB
Search via MCP tools with metadata filtering — the agent grounds answers in your data
Inspect exact evidence with
rag.get_chunkbefore answering
Everything runs locally. No cloud APIs, no data leaves your machine.
Related MCP server: DocAgent-MCP
Features
Area | Details |
MCP-native | 5 tools + 3 resources, works with opencode, Claude Desktop, any MCP client |
Instruction-aware embeddings | Qwen3-Embedding with separate document/query prefixes |
Pluggable backends | Embedding registry: local GGUF, SentenceTransformers, OpenAI, Cohere |
Local vector DB | Qdrant in-process/file persistence, cosine similarity |
Sandboxed ingestion | Relative paths only; rejects absolute paths, |
Metadata filtering | Filter search by |
ABC everywhere | Converter, chunker, embeddings, vector store, reranker, LLM all swappable |
Quick Start
git clone https://github.com/akshayvarala/Agentic-rag-mcp.git
cd Agentic-rag-mcp
pip install -e ".[gguf]"
cp .env.example .env # edit model pathspython -m rag.cli status
python -m rag.cli ingest notes.pdf
python -m rag.cli search "what is retrieval augmented generation?"
python -m rag.cli serve # start MCP server (stdio)MCP Integration
opencode
~/.config/opencode/opencode.jsonc:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"rag": {
"type": "local",
"command": ["python", "-m", "rag.cli", "serve"],
"cwd": "/path/to/Agentic-rag-mcp",
"environment": { "PYTHONPATH": "/path/to/Agentic-rag-mcp/src" },
"enabled": true
}
}
}Claude Desktop
claude_desktop_config.json:
{
"mcpServers": {
"rag": {
"command": "python",
"args": ["-m", "rag.cli", "serve"],
"cwd": "/path/to/Agentic-rag-mcp",
"env": { "PYTHONPATH": "/path/to/Agentic-rag-mcp/src" }
}
}
}Any MCP client (stdio)
PYTHONPATH=src python -m rag.cli serveMCP Tools
Tool | Description |
| Primary tool. Ranked chunks with scores + metadata |
| Convert → chunk → embed → store. Sandboxed to |
| Full chunk text + metadata for evidence inspection |
| Models, collection stats, config |
| Remove a document from the index |
Resources: rag://config, rag://models, rag://stats.
Configuration
.env (see .env.example):
# Embeddings (required) — pick ONE provider
EMBEDDING_PROVIDER=qwen_local
EMBEDDING_MODEL_PATH=C:\llama-cpp\Qwen3-Embedding-0.6B-Q8_0.gguf
EMBEDDING_DIMENSION=1024
EMBEDDING_BATCH_SIZE=32
# Vector store
QDRANT_PATH=./data/qdrant
QDRANT_COLLECTION=rag_documents
# Pipeline
DATA_DIR=./data
ALLOWED_INPUT_DIR=./data/original
CHUNK_SIZE=1024
CHUNK_OVERLAP=128
# MCP
MCP_HOST=127.0.0.1
MCP_PORT=3000
LOG_LEVEL=INFOEmbedding providers (EMBEDDING_PROVIDER): qwen_local (GGUF via llama-cpp),
st_local (SentenceTransformers), openai, cohere.
Architecture
src/rag/
├── config.py # Pydantic BaseSettings from .env
├── logging.py # Structured logging (stderr-safe for MCP stdio)
├── errors.py # RAGError + Conversion/Embedding/VectorStore/Security/Config/LLM/...
├── metadata.py # Index metadata tracking
├── pipeline.py # convert → chunk → embed → store → search
├── cli.py # ingest / search / get-chunk / status / serve
├── converters/ # DocumentConverter ABC + MarkItDown
├── chunking/ # Overlapping text chunker with positions
├── embeddings/ # base + qwen_local + st_local + openai + cohere + registry
├── llm/ # Optional standalone LLM (llama-cpp) — NOT used by agent
├── vectorstore/ # VectorStore ABC + Qdrant local
├── retrieval/ # Retriever + Reranker ABC
├── mcp/ # server (MCP 2.x API) + tools + security
└── agent/ # Thin RAGAgent adapter for harnessesKey design decisions:
Retrieval-only — saves ~559MB vs loading a second LLM; avoids model confusion.
Instruction-aware embeddings —
embed_documents()andembed_query()use different prefixes; never treat them identically.Separate search/inspect —
rag.searchfinds,rag.get_chunkreads deeply.MCP-first — no REST layer; agents consume tools directly.
Testing
PYTHONPATH=src python -m pytest tests/ -q
# 51 passedCovers: chunking, converters, embeddings, vector store, retrieval, reranker, security (traversal/absolute-path/null-byte/oversize), pipeline, MCP tools, LLM.
Requirements
Python 3.11+
A GGUF embedding model or one of the API providers
~1GB disk for Qdrant data (grows with corpus)
License
MIT — see LICENSE.
Contributors
@akshayvarala — owner
@manojkumar9121 — contributor
@bspk01 — contributor
This server cannot be deployed
Maintenance
Related MCP Connectors
Private-by-default, local-first memory/context/task orchestrator for MCP apps and agents.
Agentic search over your Dewey document collections from any MCP-compatible client.
Cloud or self-hosted knowledge for AI agents: hybrid search, reranking, GraphRAG, scoped MCP tools.
- docs2mcpOAuthcom.docs2mcp
Query your own PDFs and documents from any MCP client. Every answer cites the page it came from.
Related MCP Servers
- FlicenseAqualityDmaintenanceA local-first document retrieval engine that mounts as an MCP tool for agents to index files, search for relevant passages, and let the agent's own LLM answer.4-
- 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 gradedqualityBmaintenanceEnables AI tools to securely search and retrieve relevant, source-attributed chunks from private local documents via MCP, without sending document content to third-party services.1MIT
- FlicenseNot gradedqualityBmaintenanceEnables AI agents to manage, upload, chunk, and semantically search local documents through MCP tools and a REST API, with a built-in web dashboard and optional Gemini-powered AI search.1-