Agentic RAG MCP
This server provides a multi-agent Retrieval-Augmented Generation (RAG) system with three MCP tools for building and querying a pgvector knowledge base:
ingest— Scrape a URL, chunk and embed its content, and store it in the knowledge base for future retrieval.ask— Submit a question to trigger the full multi-agent pipeline (Planner → Retriever → optional Web Researcher → Synthesizer → Critic), returning a cited, self-critiqued answer with grounding verification and automatic revision if needed.search— Perform raw semantic retrieval against the knowledge base, returning the top-k most relevant chunks with similarity scores (no answer generation). Accepts an optionalkparameter (default: 5).
Provides tools for ingesting documents into a Supabase pgvector knowledge base and performing retrieval-augmented generation queries against it.
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., "@Agentic RAG MCP ask: explain the revision loop"
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
A multi-agent Retrieval-Augmented Generation system exposed as an MCP server. Ask a question and a LangGraph pipeline plans the retrieval, pulls evidence from a pgvector knowledge base, optionally augments it with live web research, drafts a cited answer, and then self-critiques it for grounding — revising until the answer is supported by the sources.
It plugs into any MCP client (Claude Code/Desktop, Cursor, Windsurf, …) as three tools:
ingest, ask, and search.
Why this design? A bare RAG endpoint is easy to copy; a multi-agent system that verifies its own answers and ships as an MCP server is not. The architecture is the moat — "easy to buy, hard to replicate."
Architecture
flowchart LR
Q([Question]) --> P[🧭 Planner<br/>plan + search queries]
P --> R[📚 Retriever<br/>pgvector top-k]
R --> W[🌐 Web Researcher<br/>Firecrawl • optional]
W --> S[✍️ Synthesizer<br/>cited answer]
S --> C{🔎 Critic<br/>grounded?}
C -- needs revision --> S
C -- grounded --> A([Answer + citations])
subgraph Stores
DB[(Supabase<br/>pgvector)]
end
R <-->|cosine search| DB
classDef agent fill:#1e293b,stroke:#7C3AED,color:#e2e8f0;
class P,R,W,S,C agent;Agent | Model / tool | Responsibility |
Planner | Claude ( | Decompose the question into focused search queries |
Retriever | Voyage embeddings + pgvector | Cosine top-k over the knowledge base |
Web Researcher | Firecrawl (optional) | Augment with live web results when a key is set |
Synthesizer | Claude | Draft an answer grounded in context, with |
Critic | Claude | Verify grounding; loop back for revision if unsupported |
Related MCP server: shared-docs-mcp
MCP tools
Tool | Arguments | Returns |
|
| Scrapes the URL, chunks + embeds it, stores it. |
|
| Runs the full pipeline. |
|
| Retrieval only — top-k chunks with similarity scores |
Quickstart
# 1. Install (Python 3.10+)
uv venv && uv pip install -e ".[dev]" # or: pip install -e ".[dev]"
# 2. Configure
cp .env.example .env # fill in ANTHROPIC_API_KEY, VOYAGE_API_KEY, DATABASE_URL
# 3. Create the vector table (Supabase SQL editor or psql)
psql "$DATABASE_URL" -f sql/schema.sql
# 4. Run the MCP server (stdio by default)
agentic-rag-mcpConnect it to Claude Code
claude mcp add agentic-rag -s user \
--env ANTHROPIC_API_KEY=sk-ant-... \
--env VOYAGE_API_KEY=pa-... \
--env DATABASE_URL=postgresql://... \
-- agentic-rag-mcpThen, from the client: "ingest https://example.com/docs" → "ask: how do I configure X?".
How it works
Plan — Claude turns the question into a short plan + 1–5 search queries.
Retrieve — each query is embedded (Voyage
voyage-3.5) and matched against pgvector by cosine distance; results are de-duplicated and ranked.Research — if
FIRECRAWL_API_KEYis set, live web results are added to the context.Synthesize — Claude writes an answer grounded only in the numbered context, citing each claim as
[n].Critique — a strict fact-checker pass decides whether the answer is fully supported. If not (and revisions remain), it loops back to the synthesizer with feedback.
Configurable via env: RAG_MODEL, RAG_TOP_K, RAG_MAX_REVISIONS, RAG_EMBED_MODEL.
Evaluation — the CI gate
📊 Live eval dashboard: enached134-ctrl.github.io/agentic-rag-mcp — the golden dataset and the latest green run (20/20 passing), in one screen.
Answer quality is measured with promptfoo on a golden dataset
(evals/golden.yaml — 20 seed cases: answerable / refusal /
adversarial, written against a committed corpus) and enforced in CI on every push: the
evals job spins up a pgvector service container, seeds it with evals/corpus/, and runs
every case through the real pipeline — planner, retriever, synthesizer, self-critique.
Nothing is mocked. A regression fails the build before it can reach a user.
Scored dimensions: citation presence (deterministic) · groundedness (LLM-as-judge) · refusal correctness (LLM-as-judge) · latency (threshold).
python evals/seed.py --schema --reset # seed the corpus into your vector store
make eval # run the suite locallySee evals/ for the corpus, the golden dataset, and the regression-capture rule:
every real-world failure becomes a new golden case, so no bug gets fixed twice.
The CI gate activates when the
ANTHROPIC_API_KEYandVOYAGE_API_KEYrepository secrets are configured; without them (e.g. on forks) the job skips with a visible notice.
Observability
Opt-in OpenTelemetry tracing to Arize Phoenix:
pip install -e ".[trace]"
phoenix serve # local Phoenix UI on :6006
PHOENIX_ENABLED=1 agentic-rag-mcpEvery ask run appears as a full trace — LangGraph node spans (plan → retrieve → research →
synthesize → critique) plus every Claude call with token usage and latency per span. Point
PHOENIX_COLLECTOR_ENDPOINT at a hosted collector to ship traces off-box.
Deploy
Containerised and ready for Railway (HTTP transport):
railway up # uses Dockerfile + railway.json; set RAG_TRANSPORT=httpExpose RAG_HTTP_PORT and connect over --transport http. A cloudflared tunnel works for
local demos.
Kubernetes
Production-shaped manifests — readiness/liveness probes, resource limits, secret-driven env —
live in deploy/k8s/, including a kind-based
local smoke test walkthrough.
Project layout
src/agentic_rag_mcp/
config.py # env-driven settings
llm.py # Anthropic (Claude) helper — adaptive thinking, JSON parsing
embeddings.py # Voyage embeddings
store.py # pgvector store (psycopg)
web.py # Firecrawl web research (optional)
ingest.py # chunking + ingestion
state.py # LangGraph state
nodes.py # planner / retriever / researcher / synthesizer / critic
graph.py # graph assembly
tracing.py # opt-in OpenTelemetry → Arize Phoenix
server.py # FastMCP server (ingest / ask / search)
sql/schema.sql # pgvector schema
evals/ # golden dataset + corpus + promptfoo suite (runs in CI)
deploy/k8s/ # Kubernetes manifests + kind smoke testLicense
MIT — see LICENSE.
Available Tools
3 toolsaskA
Answer a QUESTION with a written, source-cited answer (the full multi-agent RAG
pipeline: plan → retrieve → synthesize → self-critique). Use this when the user wants an
ANSWER. For raw matching documents instead of a written answer, use search.
Inputs: question (required). Returns: object
ingestA
Add a web page to the knowledge base: scrape the URL, chunk and embed its text, and
store it so future ask/search calls can use it. Use this to teach the system new
source material before querying it.
Inputs: url (required). Returns: object
searchA
Retrieve the raw top-k source chunks matching a QUERY, with similarity scores and no
synthesized answer. Use this when you want the underlying documents themselves. To get a
written, cited answer instead, use ask.
Inputs: query (required), k. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
Each tool has a distinct purpose: 'ask' provides synthesized answers, 'search' returns raw chunks, and 'ingest' adds content. There is no overlap or ambiguity between them.
All tool names are single-word verbs in lowercase, following a consistent and predictable pattern. No mixing of conventions.
Three tools is ideal for this RAG server: one for ingestion, one for answering, and one for raw retrieval. The scope is well-defined without unnecessary tools.
The tool set covers the core RAG workflow (ingest, ask, search). A potential minor gap is the lack of a delete or update tool, but for the stated purpose it is highly complete.
Maintenance
Related MCP Connectors
Agent-native MCP server over the public saagarpatel.dev corpus. Read-only, stateless.
Cloud or self-hosted knowledge for AI agents: hybrid search, reranking, GraphRAG, scoped MCP tools.
MCP server for langchain documentation, generated by doc2mcp.
Persistent memory, knowledge graph, task management and more for AI agents via MCP.
Related MCP Servers
- FlicenseAqualityDmaintenanceA multi-agent RAG MCP server that answers questions from your documents with a human-in-the-loop approval step, using a coordinator, retriever, and synthesizer agents.4-
- FlicenseNot gradedqualityDmaintenanceMCP server for a shared Postgres-backed knowledge base with hybrid retrieval and agentic RAG, enabling coding agents to upload, search, and ask questions over documents with cited answers.-
- FlicenseNot gradedqualityDmaintenanceExposes a RAG agent built with LangGraph, enabling retrieval-augmented question answering over a PostgreSQL/pgvector corpus via the MCP protocol.-
- AlicenseNot gradedqualityDmaintenanceMCP server that coordinates multiple AI specialists (SQL database, document RAG, and web research) using LangGraph, routing each question to the relevant agents and synthesizing their responses into a single answer with honest confidence flags.MIT