memory-gate
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Memory Gate
One authoritative vault. Many assistants. Scoped reads. Human-approved writes.
What it is
Memory Gate puts a wall around a folder of Markdown notes that several AI assistants share. It is an MCP server plus six small command-line tools, written in Python on top of Postgres. Each assistant reads only the part of the vault its scope allows. No assistant can change a note: it can only propose text. A person approves or rejects each proposal, and one writer appends the approved text to the vault.
Related MCP server: wikicore
The problem
You run several assistants over one knowledge base: a chat app with an MCP connector, a coding agent, perhaps a scheduled job. As soon as they share a memory, three questions come up:
Who may read what? Some notes are for every assistant, some for one of them only.
Who may change it? An assistant can be wrong, or can be talked into writing something by a page it read. What it writes, the others read as fact.
How do you know what a machine wrote? Months later, which lines came from which assistant, and who let them in?
Memory Gate answers each question with a mechanism you can test, not with a prompt.
How it works
flowchart LR
vault[("Vault folder: Markdown notes, git")]
sync["memory-gate-sync"]
db[("Postgres: notes by scope, proposals, decisions")]
server["memory-gate (MCP server)"]
a1["Assistant A, scopes: public, finance"]
a2["Assistant B, scope: public"]
person["Person with memory-gate-review"]
writer["memory-gate-writer"]
vault -->|"1 copy"| sync
sync --> db
db -->|"2 only the caller's scopes"| server
server --> a1
server --> a2
a1 -.->|"3 propose"| server
a2 -.->|"3 propose"| server
server -.-> db
db -.->|"4 pending proposals"| person
person -.->|"5 approve or reject"| db
db -.->|"6 approved proposals"| writer
writer -.->|"7 append a block, one git commit"| vaultSolid arrows are the read path, dotted arrows the write path.
Reading
memory-gate-synccopies the vault folder into Postgres. Each note gets a scope from its path (for example everything underFinance/isfinance, the restpublic).An assistant calls
search,fetchorrecenton the MCP server with its own bearer token. The server connects to Postgres as that assistant's own database role, and the database returns only notes of the scopes that role is a member of. A note in another scope answersnot found, exactly like a note that does not exist.
Writing
An assistant calls
proposewith a text and a target note. Nothing is written. The proposal is stored, immutable, under the assistant's name.A person lists the pending proposals with
memory-gate-reviewand reads one in full. Hidden characters and terminal escape sequences are shown as visible escapes.The person approves or rejects it, naming the revision they saw.
memory-gate-writertakes the approved proposals and appends each one to its note as a marked block, without touching the existing text.Each write is one git commit in the vault. The next sync makes the block readable. Every step leaves a row in an append-only history.
More in docs/architecture.md.
What you get
Piece | What it does | Reference |
| the MCP server (streamable HTTP, or local stdio for one consumer). Five tools: | |
| sets a database up as its owner, one command per step: applies the schema shipped in the package, registers scopes, creates each consumer's and each tool's login role with a random password and token written to a file of mode 600 (never shown), sets the path policy | |
| copies a folder of Markdown notes into Postgres, with a scope per path prefix | |
| the approver's terminal tool: | |
| the one writer: appends approved proposals to the vault, append-only, one git commit each | |
| tells a scheduled job whether proposals wait: one line and an exit code (0 none, 10 some); delivery is your own tool | |
| a read-only check that a live database still enforces the wall: roles, grants, triggers, and probes as each consumer | |
| four SQL files: roles, the scoped view, proposals, outcomes, history | |
| what a person needs around it: | |
| all of it in Docker, with a vault of invented notes |
Demo in 5 minutes
You need Docker with Compose v2 and Python 3. From the repository root:
demo/setup.sh
docker compose -f demo/docker-compose.yml --env-file demo/.env up -d --build
python3 demo/try.py
python3 demo/loop.pysetup.sh writes random secrets to demo/.env (mode 600) and prints none of them. Compose starts Postgres,
applies the schema, creates two consumers, copies demo/vault/ into a volume, syncs it and starts the server on
127.0.0.1:8000. alice reads the scopes public and finance; bob reads public only.
try.py calls the server as both. Abridged:
1. search "budget" (a word that appears only in Finance/)
alice 2 result(s): Finance/budget.md, Finance/savings-plan.md
bob 0 result(s)
2. fetch Finance/budget.md, then a note that does not exist
bob Finance/budget.md: error: Error executing tool fetch: not found
Finance/no-such-note.md: error: Error executing tool fetch: not found
bob's two answers are identical: bob cannot tell a hidden note from a missing one.
4. propose a change (nothing is written: a person approves first)
alice proposal 1: decision=pending execution=noneloop.py runs the write loop: propose, an approval with an outdated revision that is refused, the approval, the
writer, the sync, and the note with its new block. Abridged:
$ review approve 3 --revision 1 (exit 0)
proposal 3 approved (revision now 2): it is queued for the writer
$ writer (exit 0)
writer finished: written=1 (already_present=0) failed=0 skipped=0 resumed=0 errors=0 written_ids=3
5. alice fetches Projects/garden-planner.md: the approved text is there, marked with its proposal
<!-- memory-gate:proposal=3 -->
## Added via Memory Gate (2026-11-29 UTC, proposal 3, from alice)
Weather log: water early in the morning when the forecast says above 28 degrees.
<!-- /memory-gate:proposal=3 -->Check the wall, then remove everything:
docker compose -f demo/docker-compose.yml --env-file demo/.env run --rm verify
docker compose -f demo/docker-compose.yml --env-file demo/.env --profile tools down -v --rmi local
rm -rf demo/.env demo/backupsThe verifier ends with verify: 47 passed, 0 failed, 0 warning(s). The full walk-through, with the review tool by
hand, a deliberately broken grant, the backup and the linter, is in docs/demo.md. The demo is for
one machine, not for production: plain HTTP on localhost, and the schema applied by a superuser.
Security model in one page
Each line is an invariant, the mechanism that holds it, and the row of the test map (docs/threat-tests.md) that names the tests.
Invariant | Mechanism | Tests |
A consumer reads only the scopes it was given, and cannot tell a hidden note from a missing one | The server connects to Postgres as the consumer's own login role. A | |
A consumer cannot act as another | One bearer token per consumer, compared in constant time. The database records the role that logged in, never a parameter | |
Nothing reaches the vault without an approval | A consumer's role can only insert a proposal. Only the approver's decision moves it to the write queue, and the writer reads nothing else | |
The approver sees the whole proposal, and decides on the version they saw | Proposals are immutable. Every field is neutralised for the terminal. Each decision is compare-and-swap on a revision | |
One writer, append-only, inside the vault folder | A claim is compare-and-swap. The writer appends a marked block, never follows symbolic links, and refuses any text that contains or imitates its own marker | |
The record is append-only | Triggers refuse changes to proposals and to the history, for the schema owner too. Every change adds a history row | |
Note text, tokens and DSNs stay out of logs and error messages | One metadata line per call. Database errors are reduced to a class and a code. Client messages are fixed texts | |
The wall can be checked from outside |
|
Not covered. The full list, 66 items by category, is in docs/threat-model.md. The ones to know before you rely on this:
The operating system user that runs the tools, the schema owner and any database superuser are outside the wall. They can read every scope and disable the triggers.
A note is returned as data with a notice that it is not instructions. A language model may follow it anyway.
In local stdio mode the client holds a database credential: it can go around the server's checks, not around the database's.
Once a client has read a note, Memory Gate has no say in where the client sends it.
A stolen token is that consumer until you revoke it. Tokens do not expire.
The server speaks plain HTTP and has no rate limit: it needs a reverse proxy in front.
A person who approves without reading approves anything. Persuasive but visible text is not detected.
Paths the owner marks
auto_approveare written without a person when the proposer reads nothing butpublic. The outcome of an approved proposal lets its author probe notes it cannot read.The guard hooks for coding agents in
kit/hooks/are heuristics with a documented list of bypasses. File permissions are the boundary there.Answer times are not equalised between a hidden note and a missing one.
Nobody outside the project has audited any of this.
To report a vulnerability, see SECURITY.md.
How it compares
Memory Gate adds per-consumer scopes inside one memory (enforced in the database), writes only as proposals, a person's approval, one writer and an append-only record. It lacks things other tools have: search by meaning, connectors to mail and chat, automatic capture, a hosted option, a web interface, OAuth. If you want an assistant that remembers on its own and finds things by meaning, look elsewhere. docs/comparison.md describes the neighbouring kinds of tools and compares one named project, fact by fact, from its own pages.
Status and maintenance
Version 0.1, unreleased. A reference implementation: small, meant to be read, run and adapted.
Maintained by one person, on a best-effort basis. No roadmap promises and no guaranteed response time.
Not audited by a third party. The evidence is the test suite and the verifier.
In scope: fixes to the invariants above, to the tools and to the documentation.
Planned next: OAuth, which hosted clients such as ChatGPT require for a protected server, an optional search by meaning, and refused proposals that are stored and counted, so that the answer under a
forbiddenprefix stops being a free probe (D11).Out of scope for now: several vaults in one deployment, a web interface, a hosted service, Windows.
Platforms. The package needs Python 3.12 or later, and the schema PostgreSQL 16 or later. The CI workflow
(.github/workflows/ci.yml) runs the test suite on Linux (ubuntu-latest, Python 3.12) against PostgreSQL 16
and 17; it is also run on macOS (arm64). The demo runs the tools in Linux containers (python:3.12-slim,
postgres:17-alpine). Not on PyPI yet: install from a checkout, with
uvx --from git+https://github.com/diegochiavarelli-code/memory-gate memory-gate-admin --help, or build the
image (docs/operations.md). Windows is not supported: the writer relies on POSIX file descriptors and
flock.
Origin. The design comes from a private single-user setup. This repository is a clean re-implementation of the core ideas, not the code that runs there.
Documentation
Document | For |
components, data model, the state machine of a proposal, design decisions | |
the demo, step by step | |
configuration, tools, errors, logging | |
the scopes file, what is copied, deletions | |
review commands, block format, failure reasons, crash recovery, git | |
the expected file and every check | |
pointing an MCP client at the server; which clients cannot connect | |
production checklist, scheduling, upgrades, monitoring, incidents, restore | |
assets, actors, threats, and every known limitation | |
each threat mapped to the tests that cover it | |
related work | |
short answers | |
applying the schema, roles and privileges, error codes | |
the governance kit | |
tests, what exists, reporting |
License
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Notes and memory assistant: one Markdown vault that Claude, ChatGPT and any MCP client can share.
Markdown notes in folders, with files, that your AI assistant can read, write and organise.
- Very Simple NotesDeprecatedcom.verysimplenotes
Markdown notes in folders, with files, that your AI assistant can read, write and organise.
Governed memory and workspace for any AI: tasks, calendar, mail and pages, with per-action consent.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to securely read and write to an Obsidian-compatible Markdown vault with per-agent access control, audit logging, and conflict resolution.Apache 2.0
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to build and maintain a shared, git-backed Markdown wiki: they search, file, update and link notes with YAML frontmatter, keep verbatim sources, and optionally read code repos, so knowledge one assistant records is available to all the others. Runs without LLM calls, embeddings or a database, with the vault's own files defining page types, instructions and tools.MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI clients to load bounded, verified-first team context from a shared markdown vault and propose human-approved writebacks through a server-enforced safety gate.1Apache 2.0
- AlicenseNot gradedqualityBmaintenanceLets every AI client search, read, write, and edit the same Markdown notes by keyword or meaning, with each change committed to Git.91MIT