Skip to main content
Glama

RAG Document Search — MCP Server

CI

A retrieval-augmented-generation backend that lets AI assistants search a document set and answer questions grounded in real sources. It's exposed as a Model Context Protocol (MCP) server, so any MCP-compatible client can call its search tool.

Two interchangeable backends:

  • SQLite FTS5 keyword search — the default, zero heavy dependencies.

  • Chroma vector database — semantic search (RAG_BACKEND=chroma).

Clean-room implementation written from scratch to demonstrate RAG + MCP engineering. Ships with no documents or data — you add your own.

How it works

documents/ ──▶ chunker ──▶ index (FTS5 or Chroma)
                                  │
      MCP client ──(search)──▶ server.py ──▶ ranked passages
                                  ▲
        ingest.py --incremental ──┘  only re-indexes changed files

Related MCP server: ragi

Quick start

python -m venv .venv
source .venv/bin/activate          # Windows: .venv\Scripts\activate
pip install -r requirements.txt

# 1) add your own .md/.txt files to ./documents  (none are included)
# 2) build the index
python ingest.py --rebuild
# 3) run the MCP server (stdio transport)
python server.py

Semantic mode instead of keyword:

pip install chromadb
RAG_BACKEND=chroma python ingest.py --rebuild
RAG_BACKEND=chroma python server.py

Register with an MCP client

{
  "mcpServers": {
    "rag-search": {
      "command": "/absolute/path/.venv/bin/python",
      "args": ["/absolute/path/server.py"]
    }
  }
}

Configuration

All tunables are in config.py: DOCS_DIR, BACKEND, CHUNK_SIZE, CHUNK_OVERLAP, DEFAULT_TOP_K. The document directory can also be set with the RAG_DOCS_DIR environment variable.

Design notes

  • Incremental ingestion: a manifest of file hashes means only new/edited files are re-processed — cheap to keep the index current (e.g. from CI or a timer).

  • Pluggable backends behind one get_store() factory: swap keyword ↔ vector search without touching the server or ingester.

  • Word-aligned overlapping chunks so passages stay readable and answers aren't split across a boundary.

Tests

python tests/test_chunker.py
python tests/test_store.py
# or: pytest -q

Tests use synthetic, generated text only — no datasets are bundled.

License

MIT © 2026 Wei-Ting Yen

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    B
    maintenance
    Enables any MCP-compatible AI assistant to search, filter, and retrieve information from a local document collection using a hybrid search pipeline with vector, BM25, reranking, and LLM enrichment.
    4
    -
  • A
    license
    A
    quality
    D
    maintenance
    Local-first RAG indexing and semantic search MCP server. Enables document retrieval and context-aware queries using local embedding models.
    3
    6 npm
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    A RAG service based on FastMCP that enables document indexing and retrieval (keyword/vector search) through the MCP protocol.
    -