Skip to main content
Glama
johnylira

RAG MCP Server

by johnylira

MCP RAG with Python, LangChain, LangGraph and LlamaIndex

Model Context Protocol (MCP) server project for indexing documents and answering questions with RAG (Retrieval-Augmented Generation). The server uses FastMCP via SSE, LlamaIndex + ChromaDB for retrieval, LangGraph for orchestration and LangChain for generation.

Architecture

Cliente MCP -> SSE (/sse) -> FastMCP
                           -> ingest_documents(paths)
                           -> ask_rag(question)
                                  -> LangGraph
                                     -> recuperar contexto (LlamaIndex/Chroma)
                                     -> gerar resposta (LangChain/OpenAI)
                                     -> validar citações

Related MCP server: Antigravity PDF MCP Server

Quick start

cp .env.example .env
# Edite .env e informe OPENAI_API_KEY
docker compose up --build

The MCP SSE endpoint is at http://localhost:8000/sse.

Documents

To make a local folder available to the container, uncomment the ./docs:/workspace/docs:ro volume in docker-compose.yml. Then call the tool with a path such as /workspace/docs/manual.md.

MCP Tools

ingest_documents

Indexes .txt, .md and .pdf files.

{"paths": ["/workspace/docs/manual.md"]}

ask_rag

Retrieves the most relevant excerpts and answers with [S1], [S2] references.

{"question": "Quais são os procedimentos de backup?", "top_k": 5}

Environment variables

Variable

Usage

OPENAI_API_KEY

API key compatible with OpenAI

OPENAI_MODEL

LangChain generation model

OPENAI_EMBEDDING_MODEL

LlamaIndex embeddings model

OPENAI_BASE_URL

Optional base URL of compatible endpoint

RAG_DATA_DIR

Persistent ChromaDB directory

RAG_COLLECTION

Vector collection name

RAG_CHUNK_SIZE

Size of indexed excerpts

RAG_CHUNK_OVERLAP

Overlap between excerpts

Security

Do not expose SSE publicly without TLS and authentication. Mount only authorized document directories, since the ingestion tool reads the paths provided.

Related MCP Connectors

Related MCP Servers