Skip to main content
Glama

sqlite-rag-mcp

100% offline RAG as an MCP server — index your documents into SQLite (sqlite-vec + FTS5, hybrid RRF search, local Ollama embeddings) and search them from Claude. Your documents never leave your machine.

🇺🇸 English

Why

Most RAG stacks ship your documents to a hosted vector database and an embeddings API. This one doesn't. Everything — storage, vectors, lexical index, embeddings — runs locally:

  • One SQLite file is the whole index. No services to run, nothing to babysit. Back it up with cp.

  • Hybrid search: sqlite-vec vector KNN + FTS5 BM25, fused with Reciprocal Rank Fusion (RRF) — better recall than either alone.

  • Local embeddings via Ollama (nomic-embed-text by default).

  • Graceful degradation: if Ollama isn't running, indexing and search still work in lexical (FTS5) mode with an explicit warning. Search never breaks.

Architecture

flowchart LR
    subgraph Claude["Claude Code / Claude Desktop"]
        C[MCP client]
    end
    subgraph Server["sqlite-rag-mcp (stdio)"]
        T1[index_documents]
        T2[search]
        T3[get_chunk]
        T4[stats]
        F{{RRF fusion}}
    end
    subgraph Local["Your machine only"]
        DB[(SQLite<br/>chunks + FTS5 + vec0)]
        O[Ollama<br/>nomic-embed-text]
        MD[/your .md / .txt files/]
    end
    C <-->|MCP over stdio| T1 & T2 & T3 & T4
    T1 --> MD
    T1 --> O
    T1 --> DB
    T2 --> F
    F -->|semantic KNN| DB
    F -->|lexical BM25| DB
    T2 -.->|embed query| O
    O -.->|offline? fall back to FTS5| F

Install

Requires Python ≥ 3.10. Not yet published to PyPI — install from a clone of this repository:

git clone https://github.com/giuseppeferretti/sqlite-rag-mcp
cd sqlite-rag-mcp
pip install .

For semantic search, also install Ollama and pull the embedding model:

ollama pull nomic-embed-text   # optional — lexical search works without it

Configure Claude Code / Claude Desktop

Add to your MCP settings (claude mcp add or claude_desktop_config.json):

{
  "mcpServers": {
    "sqlite-rag": {
      "command": "sqlite-rag-mcp",
      "env": {
        "SQLITE_RAG_DB": "~/.local/share/sqlite-rag-mcp/index.db"
      }
    }
  }
}

Or with Claude Code CLI:

claude mcp add sqlite-rag -- sqlite-rag-mcp

Environment variable

Default

Purpose

SQLITE_RAG_DB

~/.local/share/sqlite-rag-mcp/index.db

Index database path

OLLAMA_HOST

http://localhost:11434

Ollama endpoint

SQLITE_RAG_EMBED_MODEL

nomic-embed-text

Embedding model

SQLITE_RAG_CHUNK_TOKENS

800

Chunk size (approx. tokens)

SQLITE_RAG_CHUNK_OVERLAP

100

Chunk overlap (approx. tokens)

Tools

index_documents(path, glob="**/*.md") — index text/markdown files from a directory. Unchanged files (same SHA-256) are skipped, changed files are re-chunked and re-embedded.

"Index everything under ~/notes"index_documents(path="~/notes"){"files_indexed": 42, "chunks_added": 310, "chunks_embedded": 310, "warnings": []}

search(query, k=8, mode="hybrid") — search the index. Modes: hybrid (RRF fusion, default), semantic (vector KNN), lexical (FTS5 BM25). With Ollama offline, hybrid/semantic fall back to lexical and the response carries a warning — it never errors.

"How do I rotate API tokens?"{"mode_used": "hybrid", "results": [{"chunk_id": 17, "score": 0.0325, "snippet": "Generate a token with…", "source": "…/authentication.md", "title": "Authentication and API Tokens", "matched_by": "semantic+lexical"}]}

get_chunk(chunk_id) — full text + source of a chunk returned by search.

stats() — document/chunk/embedding counts, DB path and size, Ollama availability.

CLI indexing (outside MCP)

python -m sqlite_rag_mcp.index ~/notes --glob "**/*.md"
python -m sqlite_rag_mcp.index ~/docs --glob "**/*.txt" --db /tmp/docs.db

How search works

  1. The query is embedded locally (Ollama) and run against the vec0 KNN index; in parallel a sanitized, OR-expanded prefix query runs against FTS5 (BM25).

  2. Both rankings are fused with Reciprocal Rank Fusion: score(chunk) = Σ 1/(60 + rank + 1) across the two lists — a rank-based method that needs no score calibration between BM25 and cosine distance.

  3. Top-k fused chunks are returned with snippet, source path, and which ranker(s) matched them.

Provenance

This server is the extracted, genericized search core of a production RAG system that indexes and answers questions over a company's document corpus — fully offline, on commodity hardware. Case study at portfolio.iterlabs.com.br.

Development

pip install -e ".[dev]"
pytest   # includes a real stdio smoke test that spawns the server and drives it with the MCP SDK client

Related MCP server: Hoard

🇧🇷 Português

RAG 100% offline como servidor MCP — indexe seus documentos em SQLite (sqlite-vec + FTS5, busca híbrida RRF, embeddings locais via Ollama) e pesquise-os a partir do Claude. Seus documentos nunca saem da sua máquina.

Por quê

  • Um único arquivo SQLite é o índice inteiro — sem serviços externos; backup com cp.

  • Busca híbrida: KNN vetorial (sqlite-vec) + BM25 (FTS5), fundidos com Reciprocal Rank Fusion.

  • Embeddings locais via Ollama (nomic-embed-text).

  • Degradação graciosa: sem Ollama, indexação e busca continuam funcionando em modo lexical (FTS5) com aviso explícito — a busca nunca quebra.

Instalação e configuração

Ainda não publicado no PyPI — instale a partir de um clone deste repositório:

git clone https://github.com/giuseppeferretti/sqlite-rag-mcp
cd sqlite-rag-mcp
pip install .
ollama pull nomic-embed-text   # opcional — busca lexical funciona sem

No Claude Code / Claude Desktop:

{
  "mcpServers": {
    "sqlite-rag": { "command": "sqlite-rag-mcp" }
  }
}

Banco em ~/.local/share/sqlite-rag-mcp/index.db por padrão (configurável via SQLITE_RAG_DB).

Ferramentas

  • index_documents(path, glob) — indexa arquivos texto/markdown de um diretório (arquivos inalterados são pulados).

  • search(query, k, mode)hybrid (padrão), semantic ou lexical; com Ollama offline, cai para lexical com aviso.

  • get_chunk(chunk_id) — texto completo de um trecho.

  • stats() — contagens e estado do índice.

CLI: python -m sqlite_rag_mcp.index <dir> --glob "**/*.md".

Origem

Núcleo de busca extraído e generalizado de um sistema RAG em produção que responde perguntas sobre o corpus documental de uma empresa — totalmente offline. Case em portfolio.iterlabs.com.br.


Built with AI-assisted development; designed, verified, and operated by Giuseppe Ferretti.

Available Tools

4 tools
get_chunkA

Fetch the full text and source of a chunk returned by search.

ParametersJSON Schema
NameRequiredDescriptionDefault
chunk_idYes

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A3.7/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, and the description is minimal, stating it fetches text and source but does not disclose any behavioral traits like auth requirements or lack of side effects.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A single, front-loaded sentence that conveys the purpose with no redundant words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Despite having only one parameter and an output schema (as per context), the description is fairly complete for a simple retrieval tool, though it could explicitly mention that it returns full text and source.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0% (no description for chunk_id), and the description does not add any information about the parameter beyond its existence.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly uses a specific verb ('Fetch') and resource ('chunk'), and distinguishes from siblings like search and index_documents by specifying it retrieves an already-returned chunk.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies use after search results are obtained ('returned by search'), but does not explicitly state when to use vs alternatives like search or index_documents.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

index_documentsA

Index text/markdown files from a directory into the local SQLite index.

Args: path: Directory to index (absolute or ~-expanded). glob: Glob pattern relative to the directory (default '/*.md'). Use e.g. '/.txt' or '**/' for other text files.

ParametersJSON Schema
NameRequiredDescriptionDefault
globNo**/*.md
pathYes

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A3.7/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description carries full burden. It does not disclose whether indexing is idempotent, overwrites existing index, or handles large files. Minimal transparency for a state-modifying tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise, front-loaded with the main purpose, then lists parameters in clear format. No wasted sentences.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given an output schema exists, return values are covered. However, the description lacks behavioral context (e.g., side effects, limits) and usage prerequisites, making it only moderately complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema has 0% description coverage, but description adds meaningful details: path can be absolute or ~-expanded, glob is relative with examples. This compensates effectively.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Index text/markdown files from a directory into the local SQLite index,' using a specific verb and resource. It distinguishes from siblings like search and get_chunk which are query tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for indexing before search but does not explicitly state when to use it vs alternatives, or any preconditions like ensuring files are accessible.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

statsB

Index statistics: document/chunk/embedding counts and configuration.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

B3.1/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description bears full responsibility for behavioral disclosure. It states that the tool returns counts and configuration, implying a read-only operation, but does not mention side effects, permissions, rate limits, or whether data is live or cached.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence with no extraneous words. It front-loads the purpose ('Index statistics') and immediately lists what is included.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description covers the return content adequately given the presence of an output schema. However, it lacks details such as the scope (global vs. per-index) or whether 'configuration' includes mutable settings.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has no parameters, so schema coverage is 100%. The description adds value by specifying the nature of the returned data (counts and configuration), which is not evident from the empty schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states that the tool provides index statistics including document/chunk/embedding counts and configuration. It distinguishes from siblings like get_chunk (retrieve a specific chunk) and search (query) by focusing on aggregate metrics, though it does not explicitly differentiate.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided about when to use this tool versus alternatives (get_chunk, index_documents, search). The agent is left to infer context from the name and description alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 4 tool updatesv0.1.0
    • First observedget_chunk
    • First observedindex_documents
    • First observedsearch
    • First observedstats

TDQS

A3.8/5.0
Disambiguation5/5

Each tool has a unique, clearly distinct purpose: indexing documents, searching, fetching chunk details, and statistics. No overlap or ambiguity.

Naming Consistency4/5

Most names follow a verb_noun pattern (get_chunk, index_documents), but 'search' and 'stats' are single words without an object, introducing minor inconsistency.

Tool Count5/5

4 tools is appropriate for a focused RAG server: indexing, querying with retrieval, chunk access, and monitoring. Each tool serves a necessary role.

Completeness4/5

Covers the core RAG workflow (index, search, retrieve). Missing a delete or clear index function, but not a major gap for typical usage.

Maintenance

ActivitySlowing
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • 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
    16
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Local MCP server that indexes folders of documents into a hybrid vector + keyword search index for Claude Desktop, with support for PDFs, Office files, and images via OCR.
    MIT

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/giuseppeferretti/sqlite-rag-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server