Skip to main content

raglocal

NOTE – Any legacy ragkit or rag-local configuration has been removed. Use the new raglocal settings in ~/.config/raglocal/config.toml.

Local-first RAG (Retrieval-Augmented Generation) toolkit designed as an MCP server. Index your code, journals, books, and docs once — query them from Claude, OpenCode, or any MCP-capable AI tool with minimal tokens per session.

  • Zero daemons — embedded LanceDB, no Docker, no Qdrant
  • Local embeddings — three size profiles, no API key required
  • Two MCP tools — search returns ranked 250-char snippets; expand fetches full text on demand
  • Heterogeneous content — code, markdown, PDFs, EPUB, DOCX, JSON/YAML, journal entries
  • Portable corpora — bundle and share an indexed corpus as a single zip file

Installation

pip install raglocal[local-embed]   # recommended — includes sentence-transformers

Optional extras:

pip install raglocal[local-embed,books]    # adds EPUB/MOBI/PDF book parsing
pip install raglocal[local-embed,office]   # adds DOCX/ODT support

Requires Python 3.12+.


Quick start

rag init                        # interactive wizard — picks embedder profile, sets paths
rag index ~/journals/ ~/code/   # index your content (incremental, re-run any time)
rag stats                       # verify chunks were indexed
rag mcp                         # start the MCP server

Then point your AI tool at the server (see MCP setup below).


Embedder profiles

Chosen once during rag init. To switch profiles later, edit ~/.config/raglocal/config.toml and run rag reindex — raglocal detects the mismatch via the on-disk manifest and refuses to mix incompatible vectors. See DESIGN.md §11 Hot-swap for details.

Profile Model Dim Disk RAM Backend
lean all-MiniLM-L6-v2 384 90 MB 400 MB sentence-transformers
balanced nomic-embed-text-v1.5 768 270 MB 1 GB sentence-transformers
powerful bge-m3 1024 2.3 GB 4 GB Ollama (must be running)

Indexing content

# Index a directory (all supported file types, recursive)
rag index ~/notes/

# Index multiple paths
rag index ~/code/myproject ~/journals ~/books/

# Target a specific collection
rag index ~/books/ --collection books

# Check what was indexed
rag stats

Indexing is incremental — files are skipped if unchanged since last run (mtime + content hash).

Supported file types

Category Extensions
Code .py .js .ts .go .rs .java .c .cpp .rb .swift and more
Docs .md .txt .pdf .json .yaml
Office .docx .odt (requires raglocal[office])
Books .epub .mobi (requires raglocal[books])
Journal .md / .txt with ISO date in filename or frontmatter
Sessions .json (OpenCode/Claude conversation exports)
Web .html .htm

MCP setup

OpenCode

Add to ~/.config/opencode/config.json:

{
  "mcp": {
    "raglocal": {
      "command": "rag",
      "args": ["mcp"],
      "type": "stdio"
    }
  }
}

Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "raglocal": {
      "command": "rag",
      "args": ["mcp"]
    }
  }
}

Restart your AI tool after editing. The search and expand tools will appear automatically.


MCP tools

Semantic + keyword hybrid search. Returns up to top_k ranked snippets (≤250 chars each) with chunk IDs for use with expand.

{
  "query": "rust ownership model",
  "top_k": 10,
  "filter": {
    "collection": "code",
    "type": "code",
    "language": "rust",
    "since": "2025-01-01"
  }
}

Response includes hits array — each hit has id, snippet, score, source, collection.

expand

Fetch full text of specific chunks by ID. Use on hits from search that look worth reading in full.

{
  "ids": ["abc-123", "def-456"],
  "before": 1,
  "after": 1
}

before/after include neighbouring chunks for context. Response includes full text per chunk.

Note: chunk ID resolution was broken prior to v0.2.0 and is now fixed.

Token cost

Item Tokens (approx)
Tool schemas ~400
Per search hit ~60
10-hit search ~1,000
expand (1 chunk) ~300–800

A typical session costs ~1,200–2,000 tokens for retrieval, vs. ~4,000+ for full-chunk RAG.


CLI reference

rag init                    Interactive setup wizard
rag index <path...>         Index files/directories into the store
rag reindex [--collection]  Rebuild index after switching embedder profile
rag stats                   Show chunk counts per collection
rag mcp                     Start the MCP server
rag debug "<query>"         Debug search — print results to stderr
rag export <output.zip>     Bundle corpus for sharing
rag import <input.zip>      Import a shared corpus
rag models                  List configured model aliases
rag collections             List collections and chunk counts
rag doctor                  Health check (config, store, Ollama, model)

Configuration

rag init writes ~/.config/raglocal/config.toml. See config.toml.example for all options.

Key sections:

[store]
backend = "lance"
path = "~/.local/share/raglocal/lance"

[embedder]
profile = "balanced"       # lean | balanced | powerful

[collections.docs]
chunk_size = 800
chunk_overlap = 100
chunk_strategy = "token"   # token | sentence | code-aware | chapter

[collections.code]
chunk_size = 500
chunk_overlap = 50
chunk_strategy = "code-aware"

Portable corpora

Share an indexed corpus without requiring re-indexing on the recipient's machine:

# Export
rag export ~/my-corpus.zip

# Recipient imports
rag import ~/my-corpus.zip
# or: unzip and run the self-contained bootstrap script
bash run.sh

Development

git clone https://github.com/gpid007/raglocal
cd raglocal
uv sync --all-extras --dev
uv run pytest
uv run rag --help

Further reading

Metadata

Release files for raglocal 0.2.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for raglocal 0.2.5
File Size Uploaded Provenance Actions
raglocal-0.2.5.tar.gz 273.1 kB With provenance Details for raglocal-0.2.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for raglocal 0.2.5
File Interpreter ABI Platform Actions
raglocal-0.2.5-py3-none-any.whl Python 3 none any Details for raglocal-0.2.5-py3-none-any.whl

Total release size: 328.9 kB

Release files / raglocal-0.2.5.tar.gz

Download URL raglocal-0.2.5.tar.gz
Size 273.1 kB
Tags Source
SHA-256 checksum
How to use checksums
a7ae6f8c4618279d0edf4bae6b951efb300b11265e295dcc5b74f168582a823a
BLAKE2b-256 checksum
How to use checksums
5da33d6fe225cfcbc227455f57699bb53fdd107827dcd5252094350a640281fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 27, 2026.

Transparency log

Release files / raglocal-0.2.5-py3-none-any.whl

Download URL raglocal-0.2.5-py3-none-any.whl
Size 55.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c79a7e64f647d66ec2476b3dee14b6a4b8fc47ae524bfe4d8e81147b61ce3058
BLAKE2b-256 checksum
How to use checksums
ef2fbc93322e2012f7bcb199c2f6c95162768658d6e85b937d1c2bff7630ed87
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 27, 2026.

Transparency log

Security for raglocal 0.2.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for raglocal-0.2.5.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page