Encrypted-first embedded database with vector search and agent memory, exposed as MCP tools
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent β or use 1-click editor setup below.
π‘ Paste into ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows)
MockEmbedder needs no download and is enough to try the API. For real recall
quality use CandleEmbedder with a local e5-large, which is the benchmark setup.
Uses the citadeldb and citadeldb-mem crates (enable citadeldb-mem's candle-embed feature). e5_large loads the recommended local embedder, and adding a CrossEncoder reranker gives the best recall (the benchmark config). Other presets (bge_large, bge_small, ...) or a custom Embedder work too.
Uses the citadeldb and citadeldb-sql crates - or try SQL with no install in the live playground.
citadeldb-langgraph is a drop-in BaseStore,
so create_react_agent(store=...) and the rest of the LangGraph API work unchanged. Namespace
prefix search is served by an index rather than a scan, TTLs refresh on read, and deleting a
key destroys it cryptographically.
citadeldb-crewai implements CrewAI's StorageBackend. One call at startup routes every
crew's memory through Citadel; a crew that names its own backend keeps it.
MemoryRecord.importance maps onto the native atom score, so it survives as a ranking signal
instead of metadata the store ignores.
Serve an encrypted memory region to Claude Desktop or any MCP client. citadeldb-mcp is
published to PyPI and listed in the official MCP registry
as dev.citadeldb/mcp. Run it with no install via uvx citadeldb-mcp, or
pip install citadeldb-mcp / cargo install citadeldb-mcp, then add it to claude_desktop_config.json:
For the best recall (the benchmark config), pull e5-large + pull ms-marco-minilm first,
then use --embedder e5-large --reranker ms-marco-minilm. Omit both for instant keyword-only recall.
Citadel is scored on the LoCoMo and LongMemEval long-term-memory benchmarks. Execution speed against unencrypted SQLite across 58 head-to-head benchmarks is under Speed benchmarks.
LoCoMo - gpt-4o-mini reader and judge (the field's standard setup):
| Metric | Score |
|---|---|
| Overall | 85.7% |
| Full context at the same reader (no retrieval) | 72.9% |
Memory is built with no LLM - raw turns only, indexed and recalled deterministically.
LongMemEval_S (arXiv 2410.10813) full-haystack split (~40-50 sessions/question), gpt-4o reader, official CoT prompt and gpt-4o-2024-08-06 judge:
| Metric | Score |
|---|---|
| Overall | 86.2% |
| Task-averaged | 86.8% |
| Abstention | 80.0% |
Full-haystack stresses retrieval against distractors (not the oracle reader ceiling). Protocol and per-type results in citadel-membench.
The same encrypted pages that hold SQL tables also hold memory. Three crates make up the memory engine:
VECTOR(N) SQL type, distance operators (<-> L2, <#> inner, <=> cosine), and a PRISM-backed filtered ANN index that reads through the encrypted page store.citadeldb-mem uses no LLM at ingest or retrieval: it stores raw conversation content and recalls with embeddings, BM25 keyword matching, and a cross-encoder reranker. Remembering costs zero tokens, recall is deterministic, and the conversation is never sent to an LLM to build or search the memory. The readers and judges above are separate LLMs - gpt-4o-mini for LoCoMo, gpt-4o for LongMemEval. Protocol and a comparison with published systems are in citadel-membench.
.upgradeSingle-threaded, durability off (pure engine overhead). Most benchmarks run on 100K rows of (id INTEGER PK, name TEXT, age INTEGER); per-benchmark queries and schemas are in Methodology. Ratio = SQLite / Citadel time (higher is faster). Two-run medians.
Every iteration computes its result: writes, and reads whose parameters rotate per iteration or whose shape re-executes against the storage engine.
42 execution benchmarks. Citadel is faster on all 42. Geometric mean speedup: ~3.4x.
Deterministic read-only statements re-executed with identical parameters against unchanged data are served from a generation-keyed result cache. Any commit invalidates the cache, and the first execution after a write recomputes at execution speed. SQLite has no result cache and re-executes every query.
16 memoized benchmarks. Geometric mean speedup: ~3,700x.
Fixed-parameter reads; every benchmark except json_table is served from the result cache on repeat execution.
Rotating probes; both arms measure execution speed.
H2H benchmarks:
SELECT COUNT(*) FROM t WHERE id IN (SELECT id FROM ref_table WHERE ref_table.val = t.age)SELECT a.id, b.data FROM a FULL OUTER JOIN b ON a.id = b.a_idSELECT COUNT(*) FROM tSELECT a.id, (SELECT COUNT(*) FROM b WHERE b.a_id = a.id) FROM aSELECT * FROM t WHERE id = 50000SELECT age, COUNT(*) FROM t GROUP BY ageSELECT * FROM t WHERE email = ? AND deleted_at IS NULLWITH filtered AS (SELECT ... WHERE age < 50) SELECT age, COUNT(*) FROM filtered GROUP BY ageSELECT * FROM v WHERE id = 50000TRUNCATE TABLE tINSERT INTO t (id, val) VALUES (...) RETURNING id, valINSERT ... ON CONFLICT (id) DO UPDATE SET c = c + 1 RETURNING cSELECT * FROM v WHERE age = 42SELECT * FROM t WHERE age = 42SELECT SUM(age) OVER (ORDER BY id ROWS 50 PRECEDING) FROM tSELECT id FROM users WHERE data @> '{"role":"admin"}'::jsonbBEGIN; SAVEPOINT sp; RELEASE sp; COMMITSELECT * FROM t ORDER BY age LIMIT 10INSERT ... ON CONFLICT (id) DO UPDATE SET c = c + 1SELECT ROW_NUMBER() OVER (PARTITION BY age ORDER BY id) FROM tDELETE ... WHERE id = ? RETURNING id, valINSERT ... ON CONFLICT (id) DO NOTHINGSELECT data ->> 'name' FROM usersDELETE FROM t WHERE id = ?UPDATE t SET age = age + 1 WHERE id BETWEEN 10000 AND 10099SELECT age, id FROM t WHERE age = ? on an indexed column, parameter rotating per iterationSELECT COUNT(*) FROM t WHERE age >= ? on an indexed column, parameter rotating per iterationSELECT id, name FROM t WHERE id > ? ORDER BY id LIMIT 20, parameter advancing per iterationSELECT a.val, b.data FROM a JOIN b ON b.a_id = a.id WHERE a.id = ?, parameter rotating per iterationSELECT COUNT(*) FROM t WHERE EXISTS (SELECT 1 FROM ref_table WHERE ref_table.id = t.id)BEGIN; SAVEPOINT sp1; ... ; RELEASE/ROLLBACK TO sp1; COMMITWITH d AS (DELETE FROM src RETURNING *) INSERT INTO archive SELECT * FROM dSELECT DISTINCT age FROM tINSERT INTO sink SELECT id, val FROM aBEGIN; INSERT 1K rows; SAVEPOINT sp; INSERT 10K rows; ROLLBACK TO sp; COMMITUPDATE t SET c = c + ? WHERE id = ? RETURNING cINSERT INTO t (id, val) VALUES (?, ?)SELECT * FROM tSELECT id FROM wide (24-column table: 3 INT keys, 8 INT, 12 TEXT; 10K rows)SELECT id, k1 FROM wideSELECT id, k1, t1 FROM wideSELECT * FROM wideSELECT name FROM t ORDER BY name COLLATE NOCASE LIMIT 10SELECT SUM(age) FROM tINSERT INTO t (id, a, b) VALUES (?, ?, ?)SELECT id, val FROM a UNION ALL SELECT id, data FROM bSELECT id, s FROM t WHERE s > ?UPDATE t SET a = a + ? WHERE id = ?INSERT ... ON CONFLICT (id) DO UPDATE SET c = c + 1INSERT ... ON CONFLICT (id) DO NOTHINGWITH RECURSIVE seq(x) AS (SELECT 1 UNION ALL SELECT x+1 FROM seq WHERE x < 1000) SELECT SUM(x) FROM seqINSERT INTO t (id, a, b) VALUES (?, ?, ?)DELETE FROM parent WHERE id = ?DELETE FROM parent WHERE id = ? (no index on child)SELECT a.id, b.data FROM a INNER JOIN b ON a.id = b.a_idSELECT id FROM docs WHERE body @@ to_tsquery('rust & database')SELECT id FROM docs WHERE body @@ phraseto_tsquery('rust database')SELECT id, ts_rank(body, to_tsquery('rust & database')) FROM docs WHERE body @@ ... ORDER BY r DESC LIMIT 10Citadel-only benchmarks:
SELECT AVG(EXTRACT(HOUR FROM ts)) FROM eventsSELECT DATE_TRUNC('month', ts), COUNT(*) FROM events GROUP BY 1SELECT a, b, c FROM JSON_TABLE(j, '$[*]' COLUMNS (a INT PATH '$.a', b TEXT PATH '$.b', c INT PATH '$.c'))SELECT c.id, p.name FROM c, LATERAL (SELECT name FROM p WHERE p.cat_id = c.id ORDER BY price DESC LIMIT 1) pSELECT COUNT(*) FROM events WHERE d BETWEEN DATE '2024-02-01' AND DATE '2024-03-31'SELECT COUNT(*) FROM events WHERE ts + INTERVAL '1 day' > TIMESTAMP '2024-06-01 00:00:00'SELECT id FROM events ORDER BY ts LIMIT 100Index speedups (same query, with vs without the index):
SELECT id FROM users WHERE data @> '{"role":"admin"}'::jsonb; index CREATE INDEX ... USING gin (data)SELECT id FROM docs WHERE body @@ to_tsquery(...); index CREATE INDEX ... USING fts (body) (body is a TSVECTOR column)SQLite config: journal_mode=OFF, synchronous=OFF, cache_size=8192 (~32 MB).
Citadel config: SyncMode::Off, cache_size=4096 (~32 MB).
Reproduce with cargo bench -p citadeldb-sql --bench h2h_bench
Statements - CREATE/DROP TABLE (incl. TEMP), ALTER TABLE (ADD/DROP/RENAME COLUMN, RENAME TABLE, DISABLE/ENABLE TRIGGER), CREATE/DROP INDEX (incl. partial WHERE, expression keys, CONCURRENTLY), CREATE/DROP VIEW, CREATE/DROP MATERIALIZED VIEW (with REFRESH [CONCURRENTLY]), CREATE/DROP TRIGGER (BEFORE/AFTER/INSTEAD OF, FOR EACH ROW/STATEMENT, REFERENCING NEW/OLD TABLE, WHEN, UPDATE OF cols), INSERT (VALUES, SELECT, ON CONFLICT DO NOTHING/DO UPDATE, ON CONSTRAINT), SELECT, UPDATE, DELETE, TRUNCATE TABLE, RETURNING (with OLD/NEW), BEGIN [READ ONLY | READ WRITE]/COMMIT/ROLLBACK, SAVEPOINT/RELEASE/ROLLBACK TO, SET TIME ZONE, EXPLAIN, REFRESH MATERIALIZED VIEW
Constraints - PRIMARY KEY, NOT NULL, UNIQUE, DEFAULT, CHECK (column + table level), FOREIGN KEY with full referential actions (ON DELETE / ON UPDATE CASCADE / SET NULL / SET DEFAULT / RESTRICT / NO ACTION), GENERATED ALWAYS AS (...) STORED|VIRTUAL
Types - INTEGER, REAL, TEXT, BLOB, BOOLEAN, DATE, TIME, TIMESTAMP (WITH TIME ZONE), INTERVAL, JSON, JSONB, TSVECTOR, TSQUERY, ARRAY
Clauses - JOINs (INNER, LEFT, RIGHT, CROSS, FULL OUTER, LATERAL), subqueries (scalar, IN, EXISTS, correlated), CTEs (WITH / WITH RECURSIVE / WITH-DML: WITH x AS (INSERT/UPDATE/DELETE ... [RETURNING *]) SELECT ...), UNION/INTERSECT/EXCEPT [ALL], CASE, BETWEEN, LIKE, DISTINCT, ANY / ALL (subquery + array forms), GROUP BY/HAVING, ORDER BY, LIMIT/OFFSET
Window functions - ROW_NUMBER, RANK, DENSE_RANK, NTILE, LAG, LEAD, FIRST_VALUE, LAST_VALUE, SUM/COUNT/AVG/MIN/MAX OVER with PARTITION BY, ORDER BY, ROWS/RANGE frames
Views - CREATE/DROP VIEW, OR REPLACE, IF NOT EXISTS/IF EXISTS, column aliases, nested views
Materialized views - CREATE MATERIALIZED VIEW [IF NOT EXISTS] name AS SELECT ..., REFRESH MATERIALIZED VIEW [CONCURRENTLY] name (CONCURRENTLY does a diff-merge - DELETE removed rows, UPDATE changed rows, INSERT new rows - instead of TRUNCATE+repopulate), DROP MATERIALIZED VIEW [CASCADE], full backing-table semantics (indexes, joins, planner sees a real table), pg_matviews introspection
Triggers - CREATE TRIGGER name {BEFORE|AFTER|INSTEAD OF} {INSERT|UPDATE [OF cols]|DELETE} ON table FOR EACH {ROW|STATEMENT} [REFERENCING NEW TABLE AS new_t OLD TABLE AS old_t] [WHEN (expr)] BEGIN ... END. INSTEAD OF triggers make views writable. Transition tables work as virtual tables in trigger bodies. ALTER TABLE ... DISABLE/ENABLE TRIGGER [name|ALL]. PG-faithful name-order firing. Introspection via information_schema.triggers and SHOW TRIGGERS [ON table].
TEMP tables - CREATE TEMP TABLE ... lives in a per-connection in-memory database, dropped on disconnect. Full DDL/DML/index/constraint/trigger parity with persistent tables.
Functions - COUNT, SUM, AVG, MIN, MAX, LENGTH, UPPER, LOWER, SUBSTR/SUBSTRING, TRIM/LTRIM/RTRIM, REPLACE, INSTR, CONCAT, HEX, ABS, ROUND, CEIL/CEILING, FLOOR, SIGN, SQRT, RANDOM, COALESCE, NULLIF, CAST, TYPEOF, IIF
Date/Time Functions - NOW, CURRENT_TIMESTAMP, CURRENT_DATE, CURRENT_TIME, LOCALTIMESTAMP, LOCALTIME, CLOCK_TIMESTAMP, EXTRACT, DATE_PART, DATE_TRUNC, DATE_BIN, AGE, MAKE_DATE, MAKE_TIME, MAKE_TIMESTAMP, MAKE_INTERVAL, JUSTIFY_DAYS, JUSTIFY_HOURS, JUSTIFY_INTERVAL, ISFINITE, DATE, TIME, DATETIME, STRFTIME, JULIANDAY, UNIXEPOCH, TIMEDIFF, AT TIME ZONE. Supports INTERVAL '1 year 2 months', DATE '2024-01-15', TIMESTAMP '2024-01-15 12:30:00Z', infinity/-infinity sentinels, BC dates, full IANA zone parsing (jiff), PG-normalized INTERVAL comparison.
Full-text search - tsvector / tsquery types, to_tsvector / to_tsquery / plainto_tsquery / phraseto_tsquery / websearch_to_tsquery builders, @@ match operator, ts_rank / ts_rank_cd ranking with weighted positions (A/B/C/D), prefix matching (term:*), phrase distance (<N>), inverted indexes via CREATE INDEX ... USING fts for ~461x speedup over sequential scan
System catalog - information_schema.tables, information_schema.columns, information_schema.key_column_usage, information_schema.table_constraints, information_schema.triggers, pg_timezone_names, pg_timezone_abbrevs, pg_matviews (virtual tables, queryable). SHOW TRIGGERS [ON table] and SHOW MATERIALIZED VIEWS shorthands for the corresponding catalog queries.
Prepared statements - $1, $2, ... positional parameters with LRU statement cache plus snapshot-tagged plan caching for joins and compound queries (cache invalidates only on commit, never per-call)
Multi-statement scripts - Connection::execute_script(sql) runs ;-separated statements in one call, returning per-statement outcomes with partial-success preserved. WASM: db.run(sql) returns [{type, ...}, ...].
UPSERT - INSERT ... ON CONFLICT (cols) DO NOTHING / DO UPDATE SET col = excluded.col ... WHERE ... and ON CONFLICT ON CONSTRAINT idx_name. excluded.* refers to the proposed row; bare col refers to the existing row. Single-descent storage primitive: on the canonical DO UPDATE SET counter = counter + 1 pattern, Citadel is ~1.5x faster than SQLite.
No plaintext on disk. Every page is encrypted before writing and authenticated before reading.
Separate key file. Encryption keys live in {dbname}.citadel-keys, not inside the database. The passphrase derives a master key in memory via Argon2id (or PBKDF2 in FIPS mode) and never touches disk.
Key backup. Export an encrypted key backup with a separate recovery passphrase. Restore access without re-encrypting the entire database.
Instant rekey. Changing the passphrase re-wraps the root encryption key. No page re-encryption - instant regardless of database size.
Encrypted sync. Noise protocol (NNpsk0_25519_ChaChaPoly_BLAKE2s) with a 256-bit pre-shared key. Ephemeral Curve25519 keys per session for forward secrecy.
Fresh random IV per page. HMAC verified before decryption.
Shadow paging with a god byte - one byte selects the active commit slot. Atomic commits without WAL:
What the at-rest integrity machinery does and does not guarantee against an attacker with file access:
(epoch, page_id, IV, ciphertext). Any modification of a page's bytes is detected before decryption. It does not bind the commit generation: a page image validly written in the past for the same (page_id, epoch) verifies forever.txn_id and Merkle root outside the attacker's reach and compare after opening.Static or dynamic library with auto-generated citadel.h (cbindgen). All 37 functions are panic-safe.
Install with npm install @citadeldb/wasm.
Build: wasm-pack build crates/citadel-wasm --target web
One importable wheel with the full engine (SQL, vectors, memory, agent runtime) and bundled type stubs.
Rust 1.88+.
| Flag | Description |
|---|---|
audit-log | HMAC-chained tamper-evident audit log (default: on) |
fips | FIPS 140-3: PBKDF2 + AES-256-CTR only |
io-uring | Linux io_uring async I/O |
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/citadel)<a href="https://allmcps.com/mcp/citadel"><img src="https://allmcps.com/api/badge/citadel?style=directory" alt="Citadel on AllMCPs" /></a>