Skip to main content

Local-first, provider-agnostic RAG toolkit

Project description

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 toolssearch 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

search

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

raglocal-0.2.5.tar.gz (273.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

raglocal-0.2.5-py3-none-any.whl (55.8 kB view details)

Uploaded Python 3

File details

Details for the file raglocal-0.2.5.tar.gz.

File metadata

  • Download URL: raglocal-0.2.5.tar.gz
  • Upload date:
  • Size: 273.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for raglocal-0.2.5.tar.gz
Algorithm Hash digest
SHA256 a7ae6f8c4618279d0edf4bae6b951efb300b11265e295dcc5b74f168582a823a
MD5 59b1bcb2a633a93e3a966b97d2c357cc
BLAKE2b-256 5da33d6fe225cfcbc227455f57699bb53fdd107827dcd5252094350a640281fc

See more details on using hashes here.

Provenance

The following attestation bundles were made for raglocal-0.2.5.tar.gz:

Publisher: workflow.yaml on gpid007/raglocal

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file raglocal-0.2.5-py3-none-any.whl.

File metadata

  • Download URL: raglocal-0.2.5-py3-none-any.whl
  • Upload date:
  • Size: 55.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for raglocal-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 c79a7e64f647d66ec2476b3dee14b6a4b8fc47ae524bfe4d8e81147b61ce3058
MD5 a5e8dda78f0815d9b1331b76f0e264d1
BLAKE2b-256 ef2fbc93322e2012f7bcb199c2f6c95162768658d6e85b937d1c2bff7630ed87

See more details on using hashes here.

Provenance

The following attestation bundles were made for raglocal-0.2.5-py3-none-any.whl:

Publisher: workflow.yaml on gpid007/raglocal

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page