Local-first, provider-agnostic RAG toolkit
Project description
raglocal
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 —
searchreturns ranked 250-char snippets;expandfetches 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
- Hot-swap embedder — switching profiles on an existing index
- OpenCode integration guide
- Troubleshooting
- Architecture & design
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file raglocal-0.2.4.tar.gz.
File metadata
- Download URL: raglocal-0.2.4.tar.gz
- Upload date:
- Size: 273.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b7505218ad30e29c6993af9184661d34719c0297a9e5a2df2828b9364a1a4eb
|
|
| MD5 |
f1eda645a133df962267428dad9c65eb
|
|
| BLAKE2b-256 |
39adf626da2abd6b0f60c51f319ea85028eeb9df97b2eb8c3cbafc1462d4db6e
|
Provenance
The following attestation bundles were made for raglocal-0.2.4.tar.gz:
Publisher:
workflow.yaml on gpid007/raglocal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
raglocal-0.2.4.tar.gz -
Subject digest:
0b7505218ad30e29c6993af9184661d34719c0297a9e5a2df2828b9364a1a4eb - Sigstore transparency entry: 1395090328
- Sigstore integration time:
-
Permalink:
gpid007/raglocal@4275db9b4bf4fd2253b284ee6a85b8966f7a08dd -
Branch / Tag:
refs/tags/v0.2.4 - Owner: https://github.com/gpid007
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yaml@4275db9b4bf4fd2253b284ee6a85b8966f7a08dd -
Trigger Event:
push
-
Statement type:
File details
Details for the file raglocal-0.2.4-py3-none-any.whl.
File metadata
- Download URL: raglocal-0.2.4-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cad79f46fe1d1afe903e0d02c6b78fc2d791f29791fce42f3c63a8441cc5ab85
|
|
| MD5 |
b506ddcfb028a502811ffd888d54b37d
|
|
| BLAKE2b-256 |
2d10519373b7762272cbf431261b8286ac00dee7c64c11f64e4e750d9f4a0d22
|
Provenance
The following attestation bundles were made for raglocal-0.2.4-py3-none-any.whl:
Publisher:
workflow.yaml on gpid007/raglocal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
raglocal-0.2.4-py3-none-any.whl -
Subject digest:
cad79f46fe1d1afe903e0d02c6b78fc2d791f29791fce42f3c63a8441cc5ab85 - Sigstore transparency entry: 1395090385
- Sigstore integration time:
-
Permalink:
gpid007/raglocal@4275db9b4bf4fd2253b284ee6a85b8966f7a08dd -
Branch / Tag:
refs/tags/v0.2.4 - Owner: https://github.com/gpid007
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yaml@4275db9b4bf4fd2253b284ee6a85b8966f7a08dd -
Trigger Event:
push
-
Statement type: