GitHub Get synrag

Documentation

synrag is one executable: it parses documents, builds a hybrid index (BM25 + the Synapse embedding model + an optional reranker), and serves search and LLM-ready context over HTTP. Everything below runs on a laptop.

Quickstart

# 1. install the binary (~3 MB) and the models (~86 MB) into ~/.local/bin and ~/.synrag
curl -fsSL https://ai.synlabs.pro/install.sh | sh

# 2. index a folder of PDFs, Office files, HTML, Markdown...
synrag index ./docs -o docs.syn --student ~/.synrag/models/synapse.synm

# 3. ask from the command line
synrag search docs.syn "how do refunds work" -k 5 --student ~/.synrag/models/synapse.synm
synrag context docs.syn "how do refunds work" --budget 600 --student ~/.synrag/models/synapse.synm

# 4. or serve it over HTTP
synrag serve docs.syn --student ~/.synrag/models/synapse.synm --port 7878
curl 'localhost:7878/search?q=how+do+refunds+work&k=5'
--student loads Synapse, the embedding model. Without it synrag runs BM25 only (smaller, faster, lower quality). Add --rerank ~/.synrag/models/rerank.synr for the best quality.

Install

The installer downloads the binary and models from this site, verifies their SHA-256 checksums, and installs them for the current user (no root). Read it first if you like: install.sh. Manual download: Download.

Index documents

synrag index <path>... -o <index.syn> [--student synapse.synm] [--learn] [--chunk-words 160]
synrag add    <index.syn> <path>...      # add or replace (same source = new version)
synrag delete <index.syn> <source>...    # remove by source
synrag parse  <file> [--chunks]           # see what the parser extracts

Formats: PDF, DOCX, XLSX, PPTX, ODT/ODS/ODP, HTML, Markdown, CSV, JSON / JSONL, ZIP (nested up to 4 levels), plain text. Scanned documents: --ocr-cmd "tesseract {} - -l eng" runs any OCR command for pages without a text layer. --learn additionally trains a small corpus model on your documents (~3 s per 50K documents) — slightly better on some corpora, optional.

Serve and query

synrag serve docs.syn --student synapse.synm [--rerank rerank.synr] [--host 127.0.0.1] [--port 7878]
synrag serve --data ./data --api-keys keys.json          # collections + authentication

On a non-loopback address the server refuses to start without authentication (API keys or SSO tokens) unless you pass --insecure-no-auth. Updates are journaled and fsynced before they are applied; a crash loses nothing that was acknowledged.

HTTP API

Single-index mode serves the paths below at the root; with --data every collection has them under /c/{name}/. Authenticate with Authorization: Bearer <key or token>.

RequestWhat it does
GET /search?q=…&k=10Hybrid search. One hit per document (best chunk) with source, title, heading, page, text, score, version; chunks=1 returns all chunks.
GET /context?q=…&budget=1500The sentences that answer the query under a token budget, with [n] citations and the list of sources.
POST /add {"docs":[{"source","title","text","acl"?}]}Add or replace documents; searchable immediately.
POST /upload?source=report.pdf (file bytes)Parse a file on the server (any supported format) and index it.
POST /delete {"sources":[…]}Delete documents.
POST /saveWrite a snapshot and empty the journal (also automatic).
GET /collections, POST|DELETE /collections/{name}List, create, drop collections (role admin).
GET /health, GET /ready, GET /metricsLiveness, readiness, Prometheus metrics.
GET /licenseEdition, license, chunks in use (role admin).
curl -s localhost:7878/context --get --data-urlencode 'q=what is the notice period?' -d budget=400
{"context": "The notice period is two months [1]…", "tokens": 58,
 "sources": [{"cite": 1, "source": "hr/handbook.pdf", "title": "Employee handbook", "heading": "Termination", "page": 14, "score": 0.91}]}

Python SDK

pip install synrag
import os
from synrag import Server, Client
model = os.path.expanduser("~/.synrag/models/synapse.synm")

# start a local server (builds the index on first run) …
with Server("docs.syn", build_from=["./docs"], student=model) as rag:
    for h in rag.search("refund window", k=5):
        print(h.rank, h.source, h.page, h.text[:80])
    ctx = rag.context("how do refunds work?", budget=800)
    print(ctx.text, ctx.sources)
    rag.add([{"source": "faq.md", "title": "FAQ", "text": "…"}])
    rag.upload("contract.pdf", open("contract.pdf", "rb").read())

# … or connect to a running one
kb = Client("http://10.0.0.5:7878", api_key="sk_…", collection="kb")

# OpenAI-style tool for any function-calling LLM
tool = kb.tool()                 # {"type": "function", "function": {...}}
answer_context = kb.call_tool({"query": "notice period"})

Connectors (incremental sync with access lists): S3 and S3-compatible storage, Confluence, SharePoint / OneDrive, Google Drive, any SQL database, local folders — synrag.connectors. Access lists need a license with the acl feature.

MCP server

uvx synrag-mcp (or pip install synrag-mcp, then synrag-mcp) speaks the Model Context Protocol over stdio. Tools: search_documents, get_context, list_collections; with --allow-writes also add_document, add_file, delete_documents.

Claude Desktop (claude_desktop_config.json), Cursor (.cursor/mcp.json) and other clients:

{
  "mcpServers": {
    "synrag": {
      "command": "uvx",
      "args": ["synrag-mcp", "--index", "/home/me/notes.syn", "--build-from", "/home/me/notes"]
    }
  }
}

Claude Code: claude mcp add synrag -- uvx synrag-mcp --index ~/notes.syn --build-from ~/notes. The server is on PyPI and in the official MCP Registry as io.github.Synlabs-ai/synrag; it finds the installed engine and the Synapse model by itself. To use a shared server instead: --url http://host:7878 --api-key KEY --collection kb.

Models and modes

ModeFlags57.6K docs ready inQuery p50English nDCG@10
BM25(none)0.45 s0.03–0.36 ms0.424
Fast (default recommendation)--student synapse.synm1.6 s0.55 ms0.441
Fast + reranker--student … --rerank rerank.synr1.6 s2.9 ms0.451
Full + reranker--learn --student … --rerank …4.8 s~3 ms0.455

The reranker costs ~11.5 ms of CPU per query (throughput ~0.5K queries/s instead of thousands); use it when quality matters more than volume.

Collections and API keys

synrag keygen --id ingest --roles write                  # prints the key once + its record
synrag keygen --id bot --roles read --collections kb
echo '{"keys":[<record>, <record>]}' > keys.json
synrag serve --data ./data --api-keys keys.json --host 0.0.0.0
curl -X POST -H "Authorization: Bearer $ADMIN" localhost:7878/collections/kb

Roles: read, write, admin, metrics, read-all. Only SHA-256 hashes of keys are stored. SSO tokens (OIDC: Keycloak, Entra ID, Okta, Auth0, Google), per-document access lists, audit, encryption and the cluster are described in the production guide.

Editions and licenses

Without a license file synrag runs as the Community edition: up to 1,000,000 chunks per organization (the binary counts them per server across all collections), every search feature. A license (--license-file acme.license or SYNRAG_LICENSE_FILE) raises the limit and enables SSO, document ACLs, audit, encryption at rest and the cluster coordinator. synrag license shows what is active.

Plans: Pricing.