AllMemoryMCP
Supports OpenAI embedding generation for semantic search when configured; the README notes this code path exists but was not verified against the live API.
Provides a PostgreSQL storage backend, with optional pgvector semantic search, for deploying the shared memory service beyond SQLite.
Provides a local/single-host SQLite storage backend for tenant-isolated memories, ownership and audit records, negotiation threads, and managed credentials.
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.
AllMemoryMCP
A shared, tenant-isolated memory service for AI agents.
AllMemoryMCP gives several agents one place to store what they learn. Every memory keeps its uploader's identity, so an agent reading a shared fact can tell which agent contributed it — and only that uploader can change or withdraw it. Agents can also discuss disagreements in append-only negotiation threads without silently rewriting shared memory. A single browser console lets an administrator inspect the same space, delete records and manage each agent's credential, with a session that survives a page refresh.
Copy to your AGENT
Paste this prompt into your coding agent — it will read the repository, install and deploy the service, and guide you through using it (GitHub's copy button is in the top-right corner of the box):
Read this GitHub repository, install and deploy it for me, and guide me step by step through using it: https://github.com/mohui1999/AllMemoryMCPLanguages: English (canonical) | 简体中文 | 日本語 | 한국어 | Deutsch | Français | Русский
Localized guides live in
docs/i18n/. Simplified Chinese mirrors this document in full; the other five languages are condensed guides. This English README is the reference for the current implementation — see Contributing if you would like to help keep translations in sync.
Why
Agents that work on the same project usually keep separate, private notes. The result is duplicated research, contradictory assumptions, and no way to tell where a claim came from. A shared vector store alone does not solve this: it has no notion of who wrote a fact or who is allowed to retract it.
AllMemoryMCP is a small, self-hostable service built around three rules:
Shared within a tenant, isolated across tenants. Any authenticated agent in a tenant can read all of that tenant's memories; no agent can see another tenant's data.
Provenance and ownership are first-class. Reads return
owner_agent_id; writes are only permitted to the uploader.Discussion is not memory. Negotiation threads are append-only records. Reaching a conclusion never mutates a memory by itself — an agent must explicitly write the conclusion.
It speaks both REST and the Model Context Protocol, so it works with MCP-capable agents, plain HTTP clients, and a browser.
Related MCP server: Cerefox
Repository layout
alembic/ Database schema migrations
deploy/ Reverse proxy, process manager, and backup examples
docs/i18n/ Localized README files
web/ Browser console (single account, cookie session)
app.py REST API and browser routes
mcp_server.py MCP server and stdio bridge
memory_service.py, credentials.py, db.py, embeddings.py
Shared service, access control, persistence, and search logicRuntime modules stay at the project root because the documented local and container entry points import them directly.
Project status
Pre-1.0 / experimental (API version 0.6.0, November 2026). The three memory layers, offline vector retrieval, context assembly and reindexing are covered by scripted checks on both SQLite and PostgreSQL + pgvector. A live MCP handshake over Streamable HTTP has also been exercised, and the unified browser console (cookie session, CSRF guard, credential lifecycle, memory deletion) is covered by scripted checks against a local service. Remote embedding providers, backup restore and concurrency testing remain unverified. Please read this before deploying to production.
Verified by execution (2026-11-09) | Not yet exercised |
Legacy memory CRUD, ownership rejection, soft deletion, audit records | OpenAI / OpenAI-compatible embedding calls (code path only) |
Summary / timeline / event writes, optimistic locking, revisions, supersedes and time filters | MCP stdio handshake; browser session restore against a live deployment |
Unified console: one admin account, HttpOnly cookie session, refresh restore, CSRF guard, issue / list / revoke / rotate / delete credentials, admin memory deletion | Backup restore, concurrency / load testing |
Offline vector retrieval on SQLite: sparse chunk vectors, RRF fusion, version-aware filtering, reindex | Backup restore, concurrency / load testing |
PostgreSQL 16 + pgvector: Alembic | |
| |
| |
|
There is currently no automated test suite committed to the repository — the checks above were run as local scripts. Adding pytest coverage is one of the most valuable contributions (see Roadmap).
The source is published at github.com/mohui1999/AllMemoryMCP. Fork the repository to contribute; see Contributing.
Contents
Features
Two agent interfaces: REST API and remote MCP over Streamable HTTP, plus a local stdio bridge for clients that launch MCP servers as subprocesses.
Tenant isolation enforced in SQL, not just in application checks — every read and write carries a
tenant_idcondition.Provenance and ownership: every result includes
owner_agent_id; only the uploader can update or soft-delete a memory; all writes produce audit records.Three memory layers with an explicit contract: one long, whole-memory Markdown summary per agent, append-only dated timeline memories, and versioned event memories for continuing areas such as
development,financeorhealth. Agents can fetch the contract at runtime withmemory_guide.Summary-first reading:
memory_agentslists every agent together with its single overview, so another agent knows what it is doing before pulling detailed event/timeline rows. Summaries also rank first in layer-free listing and receive a small boost in hybrid search.Vector retrieval by default: every memory is split into paragraph-aware chunks and embedded. The default SQLite deployment uses offline, zero-dependency vectors plus keyword/RRF hybrid ranking; PostgreSQL can use pgvector/HNSW with a remote embedding model.
One-call context loading:
memory_contextreturns an Agent's Markdown summary, categories, counts and ready-to-use follow-up calls;detail_level=summarykeeps the first read small, whiledetail_level=fullalso returns timeline and event rows.Append-only negotiation:
directthreads (creator + named recipients) and tenant-wideglobalthreads, with creator-controlledresolved/closedstatus.Managed credentials: issue tokens at runtime with
read/writescopes, optional expiry, revocation and rotation. Only SHA-256 hashes are stored; raw tokens appear once.Unified browser console: one administrator credential opens every workspace — memory search and filters, discussion timelines, soft-deleting any memory, and issuing / revoking / rotating / removing agent credentials. Sign-in is kept in an HttpOnly
SameSite=Laxcookie, so refreshing the page does not require entering the token again.Session CSRF guard: browser writes must carry an
X-AllMemory-Web: 1header and a matchingOrigin; Bearer clients (Agents / MCP) are unaffected.Pluggable storage: SQLite for local / single-host use (vector retrieval included); PostgreSQL with optional pgvector/HNSW semantic search via
DATABASE_URL.Batteries-included deployment: Dockerfile, Compose, Supervisor, nginx / Caddy examples, and a backup script.
Memory layers
Each Agent writes within its own identity and tenant. Other Agents in that tenant can read the memory and see owner_agent_id; only the uploader can change or soft-delete it.
Layer | What it actually means | How many | Update behavior |
| One overview of ALL of that Agent's memories. A long Markdown digest: who it is, what it is working on, key decisions, conventions, current state and pointers to details. It is not a single memory entry — it is the whole picture, and the first thing another Agent should read. | Exactly ONE active row per | Writing replaces the entire document and keeps a revision snapshot. Up to 100 000 characters. |
| Time memory. An append-only, dated log entry answering "what happened, and when" ( | Many rows per Agent | Immutable; a correction appends a new row with |
| Event memory. The CURRENT STATE of one long-running subject, keyed by | One active row per | Versioned upsert; revisions are kept; pass |
| Older free-form records created through | Many rows per Agent | Normal versioned updates; kept for compatibility. |
The summary is deliberately allowed to be long: it is the digest an Agent maintains so that other Agents can understand its work in one read. Do not create a second summary to add information — replace the existing one. Other Agents can read it but never replace or delete it.
GET /v1/memory-guide (or the memory_guide MCP tool) returns this contract in machine-readable form — layer meanings (English and Chinese), cardinality, length limits, read/write tools, reading order and rules — so an Agent never has to guess what summary, timeline or event mean. GET /v1/whoami, memory_whoami, memory_context and memory_search also carry a compact layer reminder in their responses.
Event memories are grouped by a free-form category and a stable event_key. Conventional categories are development, finance and health (开发 / 理财 / 健康), but any string is accepted. GET /v1/categories (or memory_categories) lists the categories in use.
Every layer is chunked and embedded on write. Retrieval combines keyword candidates with cosine-similar chunks and merges the two rankings (RRF), while filtering tenant, layer, category, event key, time range and memory version before ranking. Summaries are placed first when listing without a query and receive a small relevance boost in hybrid search. Vectors are tied to a memory version, so an update never surfaces stale chunks. If a provider fails, chunks are marked failed and keyword search still works; POST /v1/admin/reindex rebuilds missing or failed vectors without modifying canonical text.
Agent reading protocol
The layers are a progressive disclosure ladder, not three equal buckets. A newly connected Agent should:
memory_whoami— confirm which identity this connection uses. The response also carries a compact reminder of the three layers.memory_agents/GET /v1/agents— read every Agent's single summary plus its timeline/event counts in one call. This answers "who is doing what?" without pulling thousands of detail rows. Usesummary_mode=previewfor large tenants.memory_summary_get(agent_id=...)/GET /v1/memory-summaries/{agent_id}— read the full, potentially long overview of the Agent you care about. This is the highest-priority source.Only then fetch details —
memory_search(memory_layer="event", category=..., owner_agent_id=...)for a subject's current state,memory_search(memory_layer="timeline", occurred_from=..., occurred_to=...)for dated history, ormemory_revisions(memory_id=...)for how an overview/subject changed.
memory_context(detail_level="summary") / GET /v1/memory-context?detail_level=summary bundles step 3 with layer descriptions, counts, reading_order and concrete next_calls, so a client can copy the next request instead of inventing it. detail_level="full" (the default, backward compatible) also returns recent timeline and matching event rows.
Writing is the reverse order: append dated facts with memory_timeline_write, keep subject state current with memory_event_write, then refresh the one summary with memory_summary_write so the global overview stays accurate.
What you need | Read first | Then call |
Understand another Agent / the team |
|
|
The current state of one project or topic | that Agent's summary |
|
What happened during a period | that Agent's summary |
|
How an overview changed | that Agent's summary |
|
Unsure which layer to use |
| follow |
How it works
flowchart LR
A[AI Agents] -->|REST / Bearer| R[FastAPI REST + console :8099]
A -->|MCP / Bearer| M[Streamable HTTP MCP :8001]
A -->|stdio| S[Local MCP bridge]
U[Human browser] -->|admin token -> HttpOnly session cookie| R
R --> C[Shared service layer<br/>tenant + scope + ownership]
M --> C
S --> C
C --> D[(SQLite or PostgreSQL)]REST, MCP, and the browser console call the same service layer and database — there is no second source of truth.
Concept | Meaning |
Tenant | An isolated memory space, identified by |
Principal | An authenticated identity: |
Memory | A text record with |
Structured memory | A summary, timeline event, or categorized event document. Summary/event changes keep revision snapshots; timeline corrections supersede prior events. |
Negotiation | A |
Scope |
|
When not to use it
Being explicit about the boundaries saves evaluation time:
Not a general RAG or vector database. Default retrieval is case-insensitive keyword matching; semantic search is an optional PostgreSQL + pgvector enhancement.
Not a user account system. The browser has one account type: a static
ADMIN_TOKENScredential, exchanged at/viewer/loginfor an HttpOnly cookie session. There are no passwords, per-user roles, self-service signup, or OAuth/OIDC. Agent credentials are for MCP/REST clients, not for browser sign-in.Not a general content-versioning system. Summary/event memories keep snapshots and timeline corrections preserve superseded events, but legacy memory edits are not version-snapshotted.
Not a high-concurrency datastore. SQLite is the default for a small single-host deployment; there is no rate limiting, write idempotency, or message pagination.
Not multi-organization ready out of the box. Tenants isolate data, but there is no tenant provisioning UI, membership model, or per-tenant admin delegation.
Treat memory content as untrusted input when feeding it into an agent: another agent may have written stale claims or prompt-injection text.
Quick start (local)
Requirements: Python 3.11+ (the Docker image uses 3.12).
git clone https://github.com/mohui1999/AllMemoryMCP.git
cd AllMemoryMCP
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
pip install -r requirements.txt
cp .env.example .envEdit .env. Use a distinct, high-entropy token for each agent. AGENT_TOKENS is a nested JSON map of tenant IDs to agent IDs and tokens:
AGENT_TOKENS={"default":{"codex":"REPLACE_WITH_RANDOM_TOKEN","cursor":"REPLACE_WITH_ANOTHER_RANDOM_TOKEN"}}
DATABASE_URL=sqlite:///./data/memory.db
DATABASE_PATH=./data/memory.db
MCP_HOST=0.0.0.0
MCP_PORT=8001
MCP_TRANSPORT=streamable-httpGenerate tokens with python3 -c 'import secrets; print(secrets.token_urlsafe(48))'. The service loads .env automatically; keep it private (it is excluded by .gitignore).
Start REST and MCP in separate terminals from the project directory:
# Terminal 1: REST API and browser console
source .venv/bin/activate
uvicorn app:app --host 0.0.0.0 --port 8099# Terminal 2: remote MCP server
source .venv/bin/activate
python mcp_server.pyService | Local address |
Browser console | |
REST API | |
MCP endpoint | |
Health check | |
Interactive API docs |
Both processes must point at the same DATABASE_URL / DATABASE_PATH.
Docker Compose deployment
Compose runs REST and MCP under Supervisor in one container, persists data under ./data, and publishes service ports on loopback only. A reverse proxy must provide public HTTPS. SQLite is the default to keep the single-host footprint small; PostgreSQL remains an opt-in backend.
git clone https://github.com/mohui1999/AllMemoryMCP.git
cd AllMemoryMCP
cp .env.production.example .envBefore starting, replace all placeholder values in .env, especially AGENT_TOKENS and ADMIN_TOKENS. Then:
docker compose build
docker compose up -d
docker compose ps
curl --fail http://127.0.0.1:8099/healthConfigure one of the supplied reverse proxy examples:
Proxy | Console | MCP | REST |
Caddy (automatic HTTPS) |
|
|
|
nginx (subpath) |
|
|
|
Do not expose ports 8099 or 8001 directly to the internet. deploy/backup.sh creates atomic SQLite .backup snapshots with WAL handling, or uses pg_dump for PostgreSQL, and retains the latest 30 snapshots by default. Verify restores as part of deployment operations — restore has not been exercised yet.
Connect an agent
Configure the agent's MCP client with the remote endpoint and that agent's own Bearer token:
MCP URL: https://<your-domain>/mcp
HTTP header: Authorization: Bearer <agent-token>For the nginx subpath setup use https://<your-domain>/allmemory/mcp.
Give each agent a separate credential. Never put the token in a tool argument, prompt, source file, or shared agent configuration. Some MCP clients cannot set custom HTTP headers; use the local stdio bridge below (or a compatible OAuth flow, which is not implemented yet) for those clients.
Issue one credential per agent
Static AGENT_TOKENS in .env are fine for a first test, but every Agent that shares a token becomes the same identity: all memories are attributed to one owner_agent_id and the "only the uploader may edit" rule stops protecting anything. For real multi-agent use, issue a separate managed credential per Agent. Only its SHA-256 hash is stored, and it can be revoked or rotated without restarting the service:
curl -X POST https://<your-domain>/v1/admin/credentials \
-H 'Authorization: Bearer <admin-token>' -H 'Content-Type: application/json' \
-d '{"tenant_id":"default","agent_id":"claude-code","scopes":["read","write"]}'The response contains the raw token once; put it only in that Agent's MCP configuration. Repeat with a different agent_id for every Agent. GET /v1/admin/credentials lists credentials (never tokens), and the revoke/rotate endpoints manage their lifecycle. The same operations — including copying a ready-to-paste MCP configuration — are available from the browser console described below, so no terminal access is needed for day-to-day onboarding.
After connecting, call memory_whoami (or GET /v1/whoami) in each Agent and confirm it sees its own agent_id. If two Agents report the same id, they are sharing one token.
Reusable agent instructions
After connecting, give the agent this operational guidance:
Use AllMemoryMCP for shared memory. Call memory_guide if you are unsure about a layer.
MEMORY MODEL (three layers):
- summary = EXACTLY ONE long Markdown document per Agent. It is the overview of
ALL of that Agent's memories (what it is, what it is working on, decisions,
conventions, pointers to details), NOT one memory entry. It may be long.
Read it FIRST to understand another Agent. Writing REPLACES the whole document
and never creates a second summary; only the owning Agent may write it.
- event = the CURRENT STATE of one long-running subject, keyed by
(category, event_key), e.g. (development, my-project), (finance, allocation),
(health, treatment). A living, versioned document for detailed context.
- timeline = an append-only dated log entry with occurred_at, answering what
happened and when. Immutable; corrections append a row that supersedes the old one.
READ in this order (progressive disclosure):
1. memory_whoami - confirm your own identity.
2. memory_agents - see EVERY Agent's one summary at once.
3. memory_summary_get(agent_id=...) - the full overview of the Agent you need.
4. ONLY THEN memory_search(memory_layer="event"|"timeline", owner_agent_id=...)
for the details. memory_context(detail_level="summary") bundles step 3 with
layer descriptions and ready-to-use next_calls.
WRITE in this order:
1. memory_timeline_write - append dated facts as they happen.
2. memory_event_write - keep each subject's current state up to date.
3. memory_summary_write - refresh your ONE overview of everything.
expected_version is optional for a single writer.
- Every memory result includes owner_agent_id; preserve that source when summarizing.
- You may update or delete only memories you uploaded. memory_write creates a
legacy free-form record; prefer the three layers above.
- Use negotiation_start / negotiation_post / negotiation_resolve for discussions;
messages never change memories automatically. Update a memory separately.
- Never claim a write succeeded until the tool confirms it.Local stdio bridge
For clients that only launch local MCP subprocesses, run one process per agent with the same database URL and tenant as the service:
MCP_TRANSPORT=stdio \
MCP_AGENT_ID=codex \
MCP_TENANT_ID=default \
DATABASE_URL=sqlite:////absolute/path/to/AllMemoryMCP/data/memory.db \
.venv/bin/python /absolute/path/to/AllMemoryMCP/mcp_server.pyMCP_AGENT_ID binds that process to one identity. Never share a single stdio process between agents.
REST API
Replace <agent-token> with a token assigned to an agent in the default tenant.
Create a memory:
curl -X POST http://127.0.0.1:8099/v1/memories \
-H 'Authorization: Bearer <agent-token>' \
-H 'Content-Type: application/json' \
-d '{"content":"The service uses PostgreSQL in production.","memory_type":"fact","tags":["deployment"]}'Search memories, optionally filtering by source agent and paginating:
curl 'http://127.0.0.1:8099/v1/memories?q=PostgreSQL&owner_agent_id=codex&limit=20&offset=0' \
-H 'Authorization: Bearer <agent-token>'Start a global negotiation:
curl -X POST http://127.0.0.1:8099/v1/negotiations \
-H 'Authorization: Bearer <agent-token>' \
-H 'Content-Type: application/json' \
-d '{"subject":"Review deployment choice","channel":"global","first_message":"Should we use SQLite or PostgreSQL for this workload?"}'Route summary (all /v1/* routes require a Bearer token):
Method | Path | Purpose |
|
| Service health (unauthenticated) |
|
| Search/list and create memories |
|
| Read, update, or soft-delete a memory |
|
| Read or REPLACE the caller's ONE long Markdown summary |
|
| Read another Agent's summary in the same tenant |
|
| Search or append dated events |
|
| Search or upsert a versioned category/event memory |
|
| Update an owned event memory with |
|
| Read summary/event revision snapshots |
|
| Return the identity (tenant, Agent id, scopes) behind this token, with a layer reminder |
|
| The machine-readable three-layer contract (meanings, cardinality, reading/writing order) |
|
| Directory of all Agents in this tenant WITH each one's single summary |
|
| List categories in use, with event/timeline counts |
|
| Load an Agent's summary first; |
|
| List visible threads or start a thread |
|
| Read a thread and its messages |
|
| Append a message |
|
| Resolve or close a thread as its creator |
|
| Issue or list managed credentials (admin token required) |
|
| Revoke a managed credential |
|
| Rotate a managed credential |
|
| Remove a credential row; memories are kept (admin token required) |
|
| Rebuild missing/failed chunk vectors (admin token required) |
|
| Console-only soft delete of any memory, audited with its owner; Agent clients keep the uploader-only rule |
|
| Exchange an |
|
| Restore the console identity after a page refresh |
|
| Clear the session cookie |
GET /v1/... requires the read scope; memory writes require write and /v1/admin/... requires admin. A missing scope returns 403. Browser requests authenticated by the session cookie must also send X-AllMemory-Web: 1 on writes, and an Origin header (when present) must match the host; Bearer clients are exempt. FastAPI also serves interactive docs at /docs and an OpenAPI schema at /openapi.json.
Structured-memory examples:
# Create or REPLACE your ONE summary (the long overview of ALL your memories).
# expected_version is optional for a single writer; pass it when writers may race.
curl -X PUT http://127.0.0.1:8099/v1/memory-summary \
-H 'Authorization: Bearer <agent-token>' -H 'Content-Type: application/json' \
-d '{"markdown":"# Who I am\nMemory-service agent.\n\n## Current work\nStructured memory layers.\n\n## Details\nSee event/timeline rows in category development."}'
curl -X POST http://127.0.0.1:8099/v1/timeline-memories \
-H 'Authorization: Bearer <agent-token>' -H 'Content-Type: application/json' \
-d '{"title":"Added vector retrieval","content":"Implemented chunked embeddings.","occurred_at":"2026-11-09T12:00:00Z","category":"development"}'
curl -X PUT http://127.0.0.1:8099/v1/event-memories \
-H 'Authorization: Bearer <agent-token>' -H 'Content-Type: application/json' \
-d '{"category":"development","event_key":"memory-storage","title":"Memory storage design","content_markdown":"## Current approach: Use versioned event memory and vector chunks."}'Updates based on a stale expected_version return 409; read the latest memory and merge before retrying. Omitting it lets the service detect the current version automatically.
Read the layer contract, see what every Agent is doing, then load one Agent's overview first and follow the returned next_calls for details:
curl http://127.0.0.1:8099/v1/memory-guide -H 'Authorization: Bearer <agent-token>'
curl 'http://127.0.0.1:8099/v1/agents?summary_mode=full' \
-H 'Authorization: Bearer <agent-token>'
curl 'http://127.0.0.1:8099/v1/memory-context?detail_level=summary' \
-H 'Authorization: Bearer <agent-token>'
curl 'http://127.0.0.1:8099/v1/memory-context?category=finance' \
-H 'Authorization: Bearer <agent-token>'
curl http://127.0.0.1:8099/v1/categories \
-H 'Authorization: Bearer <agent-token>'
curl -X POST 'http://127.0.0.1:8099/v1/admin/reindex?batch_size=200' \
-H 'Authorization: Bearer <admin-token>'MCP tools
Tool | Purpose |
| Search tenant-visible memories and return uploader metadata |
| Read a memory by ID |
| Confirm which |
| Full three-layer contract: what summary / event / timeline mean and how to read them |
| List every Agent WITH its one summary — the cross-agent first read |
| Create a memory owned by the calling agent (legacy layer) |
| Update only the calling agent's memory |
| Soft-delete only the calling agent's memory |
| Read the ONE whole-memory overview, or REPLACE your own (never creates a second one) |
| Append a dated TIME-memory row or a superseding correction |
| Create/version-update an EVENT memory: the current state of one |
| Load an Agent's summary first; `detail_level=summary |
| List the categories currently in use |
| Read visible summary/event revision snapshots |
| Start a direct or global discussion |
| List threads visible to the caller |
| Append a message to a visible thread |
| Resolve or close a thread created by the caller |
Tool schemas never accept credentials as arguments; identity always comes from the Bearer header (or the stdio process binding).
Browser console
The console at / has one account: a static ADMIN_TOKENS credential. POST /viewer/login validates it and stores it in an HttpOnly, SameSite=Lax, Secure-on-HTTPS cookie named allmemory_session. JavaScript never sees the token again — the login response contains only the identity. GET /viewer/session restores the session on every page load, so refreshing does not sign you out; POST /viewer/logout clears the cookie. The default lifetime is 30 days (WEB_SESSION_TTL). Agent credentials, including read-only ones, cannot sign in to the browser.
The unified identity holds read, write and admin scopes for the tenant configured by WEB_ADMIN_TENANT (default by default). Every workspace is available from the same session:
Memories — keyword/semantic search, layer or type filters, source-agent filtering, pagination, a detail panel with full metadata and a Delete memory action. Console deletion is a soft delete that keeps revision history and writes an audit record with the original owner; Agent clients can still only delete their own memories via
DELETE /v1/memories/{id}.Discussions — direct and global threads with an append-only message timeline.
About — a short map of the memory layers and the access model.
Administration — list credentials (optionally including revoked ones), issue one with
read/writescopes and an optional expiry, and show the raw token once together with a ready-to-paste MCP client configuration derived from the current page URL. Revoke (disable immediately, keep the record), rotate (replace the token) or remove (delete the credential row). None of these delete the memories that agent uploaded.
Structured memory cards show their category, event key or event time. Stat cards are computed from the results currently loaded, the theme follows the system preference and can be toggled, and the sidebar becomes a bottom navigation bar on narrow screens. Every displayed value comes from the API.
Security note: the session cookie is HttpOnly (no JavaScript access), SameSite=Lax, and Secure when the request is HTTPS or WEB_COOKIE_SECURE=true. Browser writes additionally require the X-AllMemory-Web: 1 header and a matching Origin, which blocks cross-site request forgery without affecting Bearer clients. The admin credential is a root credential — use it on a trusted device over HTTPS, and rotate ADMIN_TOKENS operationally if it is exposed; changing the value immediately invalidates every session. The newly issued Agent tokens are rendered in the page only until dismissed or signed out, and are never written to localStorage, log files or the repository.
The browser UI is in English; localization into other languages is future work. The static assets have no build step and no external dependencies — web/index.html, web/app.js and web/style.css are served directly.
Set an admin token in .env:
ADMIN_TOKENS={"memory-admin":"REPLACE_WITH_RANDOM_ADMIN_TOKEN"}
# Optional session tuning:
# WEB_SESSION_TTL=2592000
# WEB_ADMIN_TENANT=default
# WEB_COOKIE_SECURE=trueAgent credentials are for MCP / REST clients only. Issue one per Agent from the Administration workspace or with:
curl -X POST http://127.0.0.1:8099/v1/admin/credentials \
-H 'Authorization: Bearer <admin-token>' \
-H 'Content-Type: application/json' \
-d '{"tenant_id":"default","agent_id":"grokbot","scopes":["read","write"]}'The raw token is returned only once. End that Agent's access with POST /v1/admin/credentials/<credential-id>/revoke.
Configuration
Variable | Description | Default |
| SQLAlchemy database URL |
|
| Legacy SQLite path / container data path |
|
| Static |
|
| Static |
|
| Browser session cookie lifetime in seconds |
|
| Tenant whose memories the browser console browses |
|
|
|
|
| Remote MCP bind address and port |
|
|
|
|
| Identity for a local stdio process | unset |
| Tenant for a local stdio process |
|
|
|
|
| Vector dimension; must match the remote model when using |
|
| Key for the | unset |
| Remote embedding model name |
|
| OpenAI-compatible endpoint (Ollama, a private gateway, ...) | unset |
The REST listener port (8099) is set in the uvicorn command or deploy/supervisord.conf, not via an environment variable.
Storage and semantic search
SQLite is the default for local and single-host use: one file, trivial backups, and a small memory footprint. PostgreSQL is supported through SQLAlchemy and Alembic migrations. It is kept opt-in because the intended host is a memory-constrained single machine; a bundled PostgreSQL sidecar would add permanent memory pressure for a low-concurrency workload.
Vector retrieval is on by default and works on SQLite. EMBEDDING_PROVIDER=local produces deterministic offline vectors (word, word-bigram and CJK character-bigram feature hashing): no API key, no model download, no extra package. It captures lexical/character similarity. For true semantic vectors set EMBEDDING_PROVIDER=openai with OPENAI_API_KEY, optionally pointing OPENAI_BASE_URL at Ollama or another OpenAI-compatible gateway. Use EMBEDDING_PROVIDER=none for keyword-only search.
Every structured memory is split into paragraph-aware chunks; each chunk stores its content hash, memory version, provider/model and vector. On SQLite the vectors are sparse JSON and cosine distance is computed in Python; on PostgreSQL with pgvector the same distance is computed in SQL using the HNSW index. Both paths apply tenant, layer, category, event key, time range and memory-version filters before ranking, then fuse keyword and vector candidates with reciprocal rank fusion. Legacy memory_write records keep a whole-record embedding. If a provider fails, chunks are marked failed: canonical text is still written and keyword search still works. POST /v1/admin/reindex rebuilds missing/failed vectors, which is also required after switching provider or model. EMBEDDING_DIM must match the remote model's output size; set it before running PostgreSQL migrations.
To apply PostgreSQL migrations:
DATABASE_URL='postgresql+psycopg://user:password@host:5432/allmemory' alembic upgrade headThe chain is 0001_initial (multi-tenant tables) → 0002_embedding (legacy vector column and HNSW index on PostgreSQL) → 0003_agent_credentials (managed credentials) → 0004_structured_memory (three memory layers, revisions, chunks and a chunk-vector HNSW index). SQLite databases are created on startup via create_all; PostgreSQL deployments must run alembic upgrade head. The compose file includes a commented-out pgvector/pgvector:pg16 service; review and secure its credentials before enabling it.
Contributing
Contributions are welcome, especially the ones listed in the roadmap. The project is small and has no build step for the frontend, so a change can usually be validated locally in minutes.
Development setup
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env # use throwaway tokens locally
uvicorn app:app --host 127.0.0.1 --port 8099Before opening a pull request
Run the checks that exist today:
python -m compileall -q app.py memory_service.py credentials.py db.py embeddings.py mcp_server.py node --check web/app.js rm -f /tmp/allmemory-check.db && DATABASE_URL=sqlite:////tmp/allmemory-check.db alembic upgrade headKeep
tenant_idand scope checks in every new query and write path. A feature that bypassesmemory_service.pywill leak data across tenants.Never commit
.env,data/, backups, or real tokens. Both.gitignoreand.dockerignoreexclude them — do not weaken those rules.Follow the existing style: Python type hints, SQLAlchemy ORM only (no raw SQL), JSON-valued fields serialized as text, and no hardcoded credentials or hostnames.
For a schema change, add an Alembic migration with a correct
down_revision; do not edit an already-published migration.Update the README (and, where relevant, the translations) when behavior or configuration changes.
Reporting a bug: include the backend (SQLite or PostgreSQL), the transport used (REST / remote MCP / stdio), the exact request or tool call, the response, and a redacted version of the relevant configuration. Never paste a real token into an issue.
The highest-impact contribution right now is a committed pytest suite covering tenant isolation, ownership, scopes and the REST routes. There is no CI pipeline yet, so local verification is part of the review process.
Roadmap and known limitations
These are candidates, not commitments or scheduled releases:
Not implemented: OAuth/OIDC login, per-user accounts and role management, tenant provisioning UI, credential self-service, cross-tenant browsing from the console, session-revocation UI.
Needs real-world verification: OpenAI embeddings, the MCP stdio handshake, the full browser sign-in flow in a real browser against a live deployment, backup restore, concurrency / load testing.
Hardening: committed
pytestsuite and CI, login rate limiting, session rotation on privilege change, write idempotency, message pagination, semantic reranking, automated restore checks.Experience: browser console localization beyond English.
Ecosystem: an official MCP client configuration example for each major agent, and keeping the translated READMEs in sync with this one.
Remote MCP clients must be able to set an Authorization header until an OAuth-compatible flow exists. ADMIN_TOKENS remain a static root credential; rotate them operationally.
Security
Use HTTPS for any non-local access and keep ports 8099/8001 behind the reverse proxy, bound to
127.0.0.1.Use separate high-entropy credentials for each agent and tenant. Browser access uses one
ADMIN_TOKENScredential in an HttpOnly cookie session — never reuse it as an Agent token or put it in an MCP client configuration.Static
AGENT_TOKENS/ADMIN_TOKENSlive in environment variables. Managed credential records store only SHA-256 hashes and support expiry, revocation and rotation. Browser writes are CSRF-guarded; Bearer clients are not affected.Memory content is untrusted data. Agents consuming it should treat it as potentially stale or containing prompt injection.
Reporting a vulnerability: this project does not yet have a dedicated private reporting channel. Please do not post exploit details in a public issue; open a minimal issue requesting a private channel (or contact the maintainers through the repository once it is published).
Troubleshooting
Symptom | Likely cause |
| Missing, revoked or expired Bearer token, or no valid browser session cookie. |
| The agent credential is |
| A cross-site form or a custom script omitted the CSRF header (or sent a foreign |
Console login returns 401 | Only |
Refresh returns to the sign-in screen | The cookie was not stored (for example |
Browser still shows the old UI after deploying | A CDN cached |
| The memory belongs to another agent or another tenant; ownership is intentionally not disclosed. |
MCP client cannot connect | Confirm the client sends |
REST and MCP see different data | The two processes are using different |
Tables missing after switching to PostgreSQL | Run |
| The creator set the thread to |
Acknowledgements
Built on Model Context Protocol, FastAPI, SQLAlchemy and Alembic. Semantic search uses pgvector when enabled; the deployment examples use Caddy, nginx and Supervisor.
License
Distributed under the MIT License.
Copyright (c) 2026 AllMemoryMCP contributors.
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
Document hosting and encrypted agent memory with multi-tenant persistence.
One memory for your AI agents: scoped, expiring, revocable per-agent tokens and an audit log.
Versioned agent memory in your own Postgres: portable context, permissioned, audit trail.
Hosted self-curating shared memory that keeps your agents working like a high-performing team
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to store, retrieve, and manage contextual knowledge across sessions using semantic search with PostgreSQL and vector embeddings. Supports memory relationships, clustering, multi-agent isolation, and intelligent caching for persistent conversational context.21 npm50MIT
- AlicenseNot gradedqualityAmaintenanceUser-owned shared memory for AI agents, providing a persistent, curated knowledge layer with hybrid search and cross-agent coordination via Postgres + pgvector.20Apache 2.0
- AlicenseAqualityCmaintenanceGives AI agents private, persistent, semantically searchable long-term memory with RAG, governed multi-agent scopes, and real-time memory-change subscriptions.2450 PyPI27MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to store, retrieve, validate, and prune persistent memory with sub-2ms latency, and to execute tenant-isolated external integrations.2MIT