Metadata-Version: 2.4
Name: synrag
Version: 1.16.1
Summary: Python client for the synrag retrieval engine: search, agent-ready context with citations, live updates
License: Apache-2.0
Project-URL: Homepage, https://ai.synlabs.pro
Project-URL: Documentation, https://ai.synlabs.pro/docs/
Project-URL: Source, https://github.com/Synlabs-ai/synrag
Project-URL: Issues, https://github.com/Synlabs-ai/synrag/issues
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE
Dynamic: license-file

# synrag — Python client

Python client for the synrag retrieval engine (Rust, single binary). No dependencies.

```python
from synrag import Server

with Server("kb.syn", build_from=["./docs"]) as rag:          # starts `synrag serve`; builds the index if missing
    for h in rag.search("refund period", k=5):
        print(h.rank, h.source, h.score)
    ctx = rag.context("how many days for a refund?", budget=800)   # sentences that answer + [n] citations
    print(ctx.text, [s.source for s in ctx.sources])
    rag.add([{"source": "faq.md", "title": "FAQ", "text": "..."}])  # live add / replace (same source), journaled
    rag.delete(["old.md"])
    rag.save()                                                     # snapshot + empty the journal
```

- Connect to a running server instead: `Client("http://host:7878")`.
- Multilingual semantic channel: `Server(..., student="synapse.synm")`; reranker: `rerank="rerank.synr"`.
- Agents: `rag.tool()` is an OpenAI-style function definition, `rag.call_tool(arguments)` runs it
  (see `examples/agent_demo.py` — works with OpenAI, Ollama, vLLM, llama.cpp server).
- The binary is found via `binary=`, `$SYNRAG_BIN` or `PATH`.

Tests (need the release binary): `python3 -m unittest discover tests`.


## MCP server (Claude, Cursor, any MCP client)

`python -m synrag.mcp` (or `synrag-mcp` after `pip install`) gives an AI agent search over your documents: the tools
`search_documents`, `get_context` (compressed context with `[n]` citations) and `list_collections`; with
`--allow-writes` also `add_document`, `add_file`, `delete_documents` (off by default).

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

`--index` builds the index on first start and runs `synrag serve` locally; `--url http://host:7878 --api-key K
--collection kb` connects to a running server instead.
