MCP Lite
README.md
# hermes-bdc-memory
**English** · [Français](README.fr.md)
Self-hosted, persistent memory for [Hermes Agent](https://hermes-agent.nousresearch.com/):
notes arrive through an authorized raw intake, become a Markdown/Obsidian-compatible
wiki with a registry, are indexed in Qdrant, and are retrieved through a **read-only**
MCP server that always returns a source.
> **Status: milestone 2 of 4.** `doctor` (read-only detection), `plan` (dry run with
> diffs) and `apply` (idempotent, backup-first install) exist. `verify`,
> `backup`/`restore`/`rollback` and ingestion into Qdrant are planned, not
> implemented. **Nothing here is release-ready and nothing here has been proven on a
> production installation yet.**
This is an independent project. It is **not** an official Hermes integration, and it
makes no legal, compliance or accuracy guarantee. It stores and retrieves what a
human put in the vault; it does not certify it.
---
## Why
An agent session forgets. Ad-hoc notes scattered across sessions, temporary files and
chat history are not a memory: they are not searchable, not citable, and not durable.
This project makes memory a first-class, self-hosted component:
- **Read-first retrieval.** When the agent knows which note it needs, it reads the file.
No embedding, no token budget, exact text, and the source path is the citation.
- **Search when the note is unknown.** Exact search first, then budgeted hybrid
retrieval (Qdrant) — and never a confident answer when the corpus has none.
- **Two credentials, two processes.** The read path holds a read-only Qdrant key; only
ingestion can write. A prompt injection in a note cannot turn retrieval into a write.
- **Your data stays yours.** Loopback by default, no telemetry, no cloud dependency.
## What it is not
- Not an official Hermes integration, and not affiliated with Nous Research.
- Not a compliance tool. Marking a note does not make anything legally compliant.
- Not a sync service: it never imports from a private deployment or a third-party vault.
- Not a general RAG framework: it is one opinionated, reproducible stack.
## Architecture
```mermaid
flowchart LR
H[human] -->|writes| RAW[vault/raw/*.md]
S[Scrib] -->|authorized intake| RAW
RAW --> ING[incremental ingest]
ING --> WIKI[vault/wiki/*.md]
ING --> REG[registry.jsonl]
ING -->|write key| Q[(Qdrant<br/>127.0.0.1)]
WIKI --> MCP[MCP Lite<br/>read-only]
Q -->|read-only key| MCP
REG --> MCP
MCP --> A[Hermes agent]
A -->|source path| H
```
Retrieval is deliberately narrow: `get_note(path)`, `search_exact(query)`,
`search_hybrid(query, budget)`, `list_sources()`. Every result carries its source.
Retrieved text is **data**, never an instruction.
More detail: [docs/architecture.md](docs/architecture.md).
## Status and roadmap
| Milestone | Scope | State |
|---|---|---|
| 1 | Clean skeleton, bilingual README, `doctor`, `plan` | **shipped** (0.1.0) |
| 2 | `apply` (idempotent, backed up), persistent manifest, Qdrant collection, MCP registration snippet | **delivered in 0.2.0** on branch `feat/milestone-2-apply`, pending review; MCP registration stays a manual step |
| 3 | `verify` (real ingestion + retrieval), `backup` / `restore` / `rollback`, interruption rehearsal | planned |
| 4 | Public release: benchmark, runbook, compatibility, publishing | planned |
Version pins for the container image and the embedding model are intentionally **empty**
until they are tested. `apply` refuses to pull an unpinned image — that is the point.
## Quickstart (two commands, nothing installed)
Requirements: Python 3.11+ and a terminal. Nothing is installed, started or written.
Measured on the reference host: `doctor` 1.5 s, `plan` 0.2 s — the two commands are the
whole quickstart, well inside a five-minute budget (clone time depends on your network).
```bash
git clone https://github.com/jeromepepermans/hermes-bdc-memory.git
cd hermes-bdc-memory
# 1. Detect the host (read-only)
python3 skills/hermes-bdc-memory/scripts/doctor.py --config config.example.toml
# 2. See what an install would change (dry run, writes nothing)
python3 skills/hermes-bdc-memory/scripts/plan.py --config config.example.toml
```
Or work from the package instead of the standalone scripts:
```bash
python3 -m venv .venv && . .venv/bin/activate
pip install -e . # or: pip install -e ".[dev]"
hermes-bdc-memory doctor --config config.example.toml
hermes-bdc-memory plan --config config.example.toml
# no install at all: PYTHONPATH=src python3 -m bdc_memory doctor ...
```
A real `doctor` run on the reference host (paths shortened):
```text
hermes-bdc-memory doctor (read-only: no file was written)
[ok ] config ~/.config/hermes-bdc-memory/config.toml
[ok ] os Ubuntu 26.04.1 LTS (x86_64)
[ok ] python 3.14.9 (/…/.venv/bin/python3.14)
[ok ] docker_cli Docker version 29.10.0, build fdd4b8e
[ok ] docker_daemon server 29.10.0
[ok ] compose v5.8.0
[ok ] qdrant http://127.0.0.1:6333/healthz healthy (loopback)
[ok ] credentials distinct variable names; no write credential in this shell
[ok ] hermes_home ~/.hermes (9 profile(s), config.yaml present)
[ok ] vault ~/vault readable, 0 markdown file(s) at root, raw/ present
[ok ] intake ~/vault/raw: 1 entry via scrib
[skip] registry no registry yet
[skip] work_dir ~/work absent (will be created by apply)
[ok ] ports qdrant :6333 in use by the configured endpoint; mcp 127.0.0.1:8765 free
[ok ] disk 19.3 GiB free
[warn] versions Qdrant image tag is not pinned
-> Pinned versions are published after testing (milestone 2);
apply refuses to pull an unpinned image.
summary: 15 ok, 1 warn, 0 fail, 2 skipped
```
`plan` prints one block per component — state, actions, unified diff, backup targets,
interruption points — and ends with an approval digest:
```text
[missing ] config Configuration file
- create ~/work/config.toml (write generated configuration)
--- ~/work/config.toml (current)
+++ ~/work/config.toml (desired)
@@ -0,0 +1,43 @@
+[paths]
+vault = "~/vault"
...
[external] qdrant_stack Qdrant container
- skip http://127.0.0.1:6333 (an existing Qdrant answers /healthz; install leaves it alone)
approval digest: sha256:5f981b64f7eae44c5e691a27f7a72debc251f0f84e767f50fcfdb407f4157289
result: changes proposed - review every line above before approving
blocked until a later milestone: collection
```
Exit codes: `0` usable, `1` internal error, `2` blocking problem (or a warning under
`--strict`).
## Install (milestone 2)
```bash
python3 skills/hermes-bdc-memory/scripts/apply.py --config ~/.config/hermes-bdc-memory/config.toml
```
`apply` reconciles the host with the plan and nothing more:
| Guarantee | How it is enforced |
|---|---|
| No partial writes | every decision is taken before the first write; one refusal aborts with zero changes |
| Never touches a file it did not create | ownership comes from `manifest.json` in the work directory, not from a filename |
| Never overwrites a human edit | the recorded content hash must still match, otherwise the run is refused |
| Backup before update | current bytes are copied to `backup/<UTC timestamp>/` with a `pre-state.json` record |
| Idempotent | a second run prints `result: no-op` and rewrites nothing, not even the manifest |
| No silent service change | starting the stack needs `--start-services` **and** `--approve <digest>`; `apply` never stops anything |
| Re-runnable after a failure | a failed step leaves the host converge-able: fix the cause, re-run, it resumes |
`apply` exit codes: `0` applied or no-op, `2` blocking environment, `3` refused by a
safety rule (foreign file, human edit, stale digest), `4` partial — a hard step failed
and re-running converges.
Starting the stack is a separate, approved act:
```bash
hermes-bdc-memory plan --config <file> # prints: approval digest: sha256:...
hermes-bdc-memory apply --config <file> --start-services --approve sha256:...
```
`apply` never edits your Hermes profile: MCP registration stays a human step, described
in [docs/approval-and-interruptions.md](docs/approval-and-interruptions.md).
The digest is bound to the host state: an `apply` that writes files changes it. Run
`plan` once more after that, and approve the fresh digest before `--start-services`.
## Configuration
[`config.example.toml`](config.example.toml) is complete and contains **no secrets** —
only the *names* of environment variables:
| Variable | Used by | Purpose |
|---|---|---|
| `BDC_MEMORY_QDRANT_READONLY_KEY` | MCP Lite, `doctor`, `plan` | read-only Qdrant access |
| `BDC_MEMORY_QDRANT_WRITE_KEY` | ingestion only | indexing writes |
Precedence: `--config PATH` → `HERMES_BDC_MEMORY_CONFIG` →
`~/.config/hermes-bdc-memory/config.toml` → built-in defaults. Configuration is TOML,
parsed with the standard library; a wrong type is a hard error, an unknown key is a
warning.
## Security
- Qdrant binds `127.0.0.1`; nothing is published on a public interface.
- Read and write credentials are different variables; sharing one is refused at load time.
- `doctor` prints variable *names* and presence booleans, never values; URLs are redacted.
- Retrieved text is wrapped with its source and never merged into a system prompt.
- Report a vulnerability privately — see [SECURITY.md](SECURITY.md).
## Backup and rollback
Since 0.2.0, `apply` copies every file it is about to change into
`<work_dir>/backup/<UTC timestamp>/files/` and records the source paths, hashes and the
reason in `pre-state.json`. The ten most recent backups are kept.
`restore` and `rollback` themselves are milestone 3, together with a rehearsed restore
that never erases note data. Until then a backup is restored by copying the files back
and restarting nothing. The procedure a human follows to approve an interruption is in
[docs/approval-and-interruptions.md](docs/approval-and-interruptions.md).
## Compatibility
Tested here: Ubuntu 26.04.1 LTS x86_64, Python 3.14.9 (host) and 3.11.16 (tests),
Docker 29.10.0, Compose v5.8.0, git 2.53.0, Hermes Agent v0.23.6.
CI matrix: Python 3.11 / 3.12 / 3.13 on `ubuntu-latest`, plus a real
`qdrant/qdrant:v1.20.3` container on an ephemeral runner that proves collection
creation and read-only key enforcement.
**Explicitly untested:** macOS, Windows, WSL, ARM64/aarch64, Debian/Fedora/Alpine,
rootless Docker, Podman, and any Hermes version older than the one above.
See [docs/compatibility.md](docs/compatibility.md).
## Benchmark
Methodology only, no published numbers yet: [docs/benchmark.md](docs/benchmark.md).
When results exist they will be reported as measured latency (p50/p95), input tokens,
quality/citation accuracy, corpus and versions — with no guarantees implied.
## Troubleshooting
| Symptom | Meaning |
|---|---|
| `[warn] qdrant ... unreachable` | expected before install; an existing Qdrant is also supported |
| `[warn] qdrant ... non-loopback host` | the endpoint is exposed; put it behind a proxy with auth |
| `[warn] versions ... not pinned` | correct at milestone 1; `apply` will refuse `latest` |
| `[warn] credentials ... write credential is exported` | run the read path without the write key |
| `[warn] ... :8765 is already in use` | change `[serve] port` |
| `result: no-op ... blocked until a later milestone` | converged host; later milestones add the rest |
| `apply` → `[refuse] ... was not created by hermes-bdc-memory` | a file of the same name already exists; review the plan diff, then move it aside yourself |
| `apply` → `[refuse] ... was modified outside apply` | you edited a generated file; re-run `plan`, adopt the change in the configuration, or restore the backup |
| `apply` → `[refuse] ... digest does not match` | the host state or the configuration changed since you approved; re-read `plan` |
| `apply` → `[defer] collection: vector_size is 0` | expected: the embedding model is not pinned yet |
| `apply` → `[adopt]` | a file apply had written exists but the manifest was lost; identical content is adopted, nothing is rewritten |
## Contributing
See [CONTRIBUTING.md](CONTRIBUTING.md). Fixtures are synthetic and multilingual by
rule; CI runs lint, unit/integration tests and a secret scan over the whole history.
## License
MIT — see [LICENSE](LICENSE). Copyright (c) 2026 Jérôme Pepermans.
The licence covers the original code, tests, fixtures and documentation in this
repository. There is no third-party code and no runtime dependency, so nothing else is
being relicensed. Contributions are accepted under the same terms. Details:
[docs/licensing.md](docs/licensing.md).
## Repository layout
```text
src/bdc_memory/ doctor, plan, configuration, read-only probes (stdlib only)
skills/hermes-bdc-memory/ Hermes skill + standalone entry points + references
tests/ unit + integration tests on a fully synthetic host
fixtures/synthetic/ invented multilingual corpus and retrieval expectations
docs/ architecture, runbook, compatibility, benchmark, licensing
scripts/secret_scan.py stdlib secret scanner (working tree, staged, full history)
```