MCP 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 RAG — RAG Agent Tool
Servidor MCP (Model Context Protocol) con RAG (Retrieval-Augmented Generation) integrado: ingesta de documentos, embeddings con OpenAI, búsqueda semántica con pgvector sobre PostgreSQL, generación fundamentada y un contrato de tools tipado para agentes externos.
Producto mínimo útil: haz una pregunta en lenguaje natural y recibe una respuesta basada únicamente en tus documentos, con fuentes citadas. Sin alucinaciones.
✨ Características
🔌 Servidor MCP (stdio) con 4 tools:
rag_retrieve,rag_answer,rag_reingest,rag_status.📄 Ingesta multi-formato: PDF, DOCX, TXT, Markdown, CSV, XLSX, HTML y URLs (opcional).
🧩 Chunking inteligente con solapamiento y cortes por párrafo/frase.
🔍 Recuperación semántica con pgvector (PostgreSQL) + caché en la misma BD.
🤖 Generación determinista (temperatura 0) con prompt anti-alucinación.
🧭 Modo agéntico opcional (
agentic=true): recupera, evalúa el contexto y reescribe la consulta si hace falta.🙋 Human-in-the-loop: pausar antes de generar y aprobar/rechazar/editar (
hitl=true,POST /answer/resume).📊 Evaluación RAG con LLM-as-judge (Context Precision@k + Faithfulness), batch + CI +
POST /evaluate.📈 Observabilidad: logs JSON con
request-idcorrelacionado yGET /metrics(Prometheus: latencia, tokens/ coste, caché, tools).🛡️ Resiliencia: reintentos con backoff ante 429/5xx/timeouts.
🌐 API REST FastAPI con 10 endpoints listos para consumir.
🐳 5 Dockerfiles por capa +
docker-compose.⚙️ Cero hardcode: toda la configuración por variables
RAG_*.
Related MCP server: RAG Chat Assistant MCP Server
🚀 Despliegue rápido (por defecto)
1. Preparar entorno
cd diamond-mcp-rag
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt
cp .env.example .env # Windows: copy .env.example .env
# Edita .env y pon tu OPENAI_API_KEY real + RAG_DATABASE_URLBase de datos (PostgreSQL + pgvector)
Necesitas un PostgreSQL con la extensión pgvector. La forma más rápida es Docker:
docker run -d --name rag-pgvector -p 5432:5432 \
-e POSTGRES_DB=rag -e POSTGRES_USER=rag -e POSTGRES_PASSWORD=rag \
pgvector/pgvector:pg16Y en .env:
RAG_DATABASE_URL=postgresql+psycopg://rag:rag@localhost:5432/ragCompatibilidad con proveedores
El sistema es compatible con cualquier proveedor OpenAI-compatible (OpenAI, OpenRouter, Groq, Azure, Mistral, Ollama local, etc.) mediante:
RAG_LLM_BASE_URL=https://api.openai.com/v1
RAG_EMBEDDING_BASE_URL=https://api.openai.com/v1
RAG_LLM_API_KEY=
RAG_EMBEDDING_API_KEY=2. Añadir documentos y indexar
mkdir -p data/sources
# Copia tus PDF/DOCX/TXT/MD/CSV/XLSX a data/sources/
python -m rag_agent_tool.ingestion.ingest3. Arrancar la API
uvicorn api.app:app --host 0.0.0.0 --port 80004. Probar
curl -X POST http://localhost:8000/answer \
-H "Content-Type: application/json" \
-d '{"question": "¿Qué dice el contrato sobre los precios?"}'
# Modo agéntico (recupera, evalúa el contexto y reescribe si hace falta)
curl -X POST http://localhost:8000/answer \
-H "Content-Type: application/json" \
-d '{"question": "¿Qué cubre la garantía y qué excluye?", "agentic": true}'5. Usar como MCP (Claude Desktop / OpenCode / Cline)
python -m rag_agent_tool.serverO con Docker:
docker compose up --build🧰 Tools MCP
Tool | Descripción |
| Devuelve los chunks más relevantes para una consulta. |
| Genera respuesta fundamentada con contexto + fuentes. |
| Reindexa una fuente o todas. |
| Estado del índice, caché y modelos. |
🌐 Endpoints API
GET /health · GET /metrics · GET /sources · POST /retrieve · POST /answer · POST /answer/resume · GET /cache/stats · GET /tools · POST /ingest · POST /evaluate
POST /answeracepta"agentic": truey"hitl": true.POST /answer/resumereanuda tras aprobación humana. El resto del contrato no cambia.
📖 Documentación completa: docs/ — arquitectura, configuración avanzada, evaluación y despliegue.
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
Ingest, manage, and retrieve documents for RAG-powered AI applications
Private, multimodal knowledge store for agents: hybrid search with cited, provenance-backed results.
Hosted document tools for agents: extract, parse, classify, convert, OCR, sign, and redact.
Persistent memory and knowledge management for AI agents with semantic search and 50+ tools.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables ingestion and semantic search over text documents using PostgreSQL + pgvector and OpenAI-compatible embeddings, allowing any LLM agent to retrieve relevant chunks for grounded answers.41AGPL 3.0
- FlicenseNot gradedqualityDmaintenanceEnables document Q&A and knowledge retrieval through hybrid semantic and keyword search, with tools for document ingestion, chunking, summarization, PII redaction, and RAGAS-based evaluation.-
- AlicenseAqualityBmaintenanceEnables AI agents to ingest documentation from websites or local files and perform semantic search over the indexed content using pgvector-backed embeddings.5MIT
- FlicenseAqualityDmaintenanceProvides AI agents with multi-format document indexing, hybrid dense and sparse search with reranking, and relational SQL querying over extracted tables.12-