Personal Agent Memory MCP
This server is a provider-independent long-term memory sidecar for AI agents, exposing MCP tools to retrieve durable context and save candidate memories.
get_context: retrieve compact, bounded durable memory relevant to the current task input, with optional session ID, chunk inclusion, max context size, and diary lookback.ingest_turn: store an interaction as candidate durable memory, requiring user input, assistant output, and metadata such as an explicit ingest reason.Maintain memory through REST workflows for candidate review, merging/splitting candidates, diary creation/fetching, and dry-run previews.
Organize memory using notes, diaries, profile memory, tags, links, lifecycle status (
candidate -> active -> archived), and provenance.Track provider/model usage separately in a ledger without logging prompt/response text or credentials.
Support authentication and account management via tokens, OAuth, and admin CLI.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Personal Agent Memory MCP Remember this decision and link it to yesterday's project notes."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Personal Agent Memory MCP
Personal Agent Memory MCP is a provider-independent memory layer for AI assistants. It gives different agents and model providers a shared place to read and write persistent context.
It is not meant to run the full agent loop, make general tool-use decisions, or replace the short-term conversation state managed by an outer runtime such as Codex, Claude Desktop, Dify, Gemini, ChatGPT, or another agent host.
The project focuses on one boundary: long-term personal memory that lives outside any single model provider.
Why I Am Building This
I do not want my assistant memory to be locked inside a single model provider.
In practice, I use different assistants in different contexts: sometimes ChatGPT, sometimes Claude, sometimes Gemini, and potentially other local or hosted agents later. Each of those tools has its own context and memory system, but those memories are disconnected from one another.
The goal of this project is to build a provider-independent memory layer: an overall assistant brain that can hold persistent context outside any single model provider, and let different AI agents read from and write to the same durable memory.
MCP, PostgreSQL, pgvector, embeddings, tags, links, and graph expansion are implementation choices for that goal. They are not the goal themselves.
Related MCP server: Cerefox
How Agents Use It
This project is designed as a memory sidecar for AI agents.
An outer agent runtime stays responsible for the actual conversation, reasoning, tool use, and response generation. This memory server only answers two questions:
What durable context should the agent know before working on this task?
What part of this interaction is worth saving after the task is done?
sequenceDiagram
participant User
participant Agent as Outer agent runtime
box rgba(235, 245, 255, 0.45) Provider-independent memory layer
participant Memory as Personal Agent Memory MCP
end
participant Tools as Other tools
User->>Agent: Ask for help
Agent->>Memory: get_context(task input)
Memory-->>Agent: Compact durable context
Agent->>Agent: Reason with current task and retrieved memory
Agent->>Tools: Call tools when needed
Tools-->>Agent: Tool results
Agent-->>User: Respond
Agent->>Memory: ingest_turn(interaction, ingest_reason)
Memory-->>Agent: Candidate memory savedThis keeps memory outside the model provider while still making it available to any assistant runtime that can speak the supported interface.
Entry Points
The main agent-facing entry point is MCP.
get_context: read relevant durable memory for the current task.ingest_turn: write candidate memory from an interaction, with an explicitmetadata.ingest_reason.
There is also a small REST user API for user management, but it is not the primary interface for agent memory.
REST maintenance supports candidate review and diary creation. Remaining work includes:
updating profile-derived memory;
normalizing tags;
repairing and updating links;
archiving stale or superseded memory.
Design Principles
Memory should be provider-independent, not owned by ChatGPT, Claude, Gemini, or any single model vendor.
Recent chat and durable memory are different things. The outer runtime owns short-term conversation state; this project owns long-term memory.
Memory should be explicit. The caller must provide an
ingest_reasoninstead of letting every interaction silently become permanent memory.Memory should be inspectable and maintainable. Notes, diary entries, profile memory, tags, links, and lifecycle events should remain understandable outside any one agent session.
Retrieval should return bounded context, not perform reasoning on behalf of the agent.
Implementation details should be replaceable as long as the memory contract remains stable.
Quick Start
Pending. The local development flow is still being shaped.
The expected flow will be:
Install Python dependencies with
uv.Copy
.env.exampleto.env.Copy
memory.example.jsontomemory.json.Start PostgreSQL + pgvector and Ollama.
Run database migrations.
Start the stdio MCP server locally, or the unified HTTP server for deployment.
Run the smoke test against the real MCP tool boundary.
For now, the Chinese README has the most complete local setup notes: 中文 Quick Start.
Expected Lifecycle
The expected memory lifecycle is:
Read: an agent asks for relevant durable context.
Use: the agent reasons with that context in its own runtime.
Write: the agent saves meaningful outcomes or observations as candidate memory.
Review: maintenance workflows clean up, merge, split, link, and organize candidates.
Activate: reviewed memory becomes part of the long-term assistant brain.
Archive: stale, duplicate, or superseded memory is kept out of active retrieval.
Memory item status is intentionally simple:
candidate -> active -> archivedP0 Scope
P0 focuses on durable text memory:
note: explicit knowledge, ideas, project notes, and reusable information.diary: chronological daily context and observations.profile_memory: retrieval-friendly memory derived from the user profile.
Recent chat is intentionally outside the core database for now. The outer agent runtime should manage short-term conversation state.
Technical Docs
The README is meant to explain the project intent and usage model. Technical details live in:
Not Yet Done
Planned later work includes:
better extraction from interactions;
full-text search and reranking;
merging reviewed notes across batches;
tag alias normalization;
profile stability rules;
richer link types;
heat and importance scoring;
stronger provenance support.
See TODO for the longer backlog.
Candidate review and diaries
POST /maintenance/review-candidates processes pending candidate notes from all
dates, oldest first. It merges/splits candidates within a batch into new active
notes, preserves source text and provenance, copies tags and graph edges, links
related active notes, and archives the consumed candidates. Existing active
notes are references and are not rewritten. Canonical profile updates and tag
alias consolidation remain future work.
Use {"dry_run": true, "limit": 3} to preview. The default limit is 10 (maximum
50); continue while has_more is true. Diary entries use original source dates,
including ingest timestamps, rather than the review date. Later batches refresh
that day's diary using earlier reviewed source material as well. All database
writes for a batch are atomic; failed validation leaves candidates pending.
GET /diary/YYYY-MM-DD returns the authenticated user's diary and links, or 404.
The existing POST /maintenance/daily-diary remains a standalone date-summary
utility; it does not review candidates. Both maintenance endpoints support
dry_run and use the existing user API token in the Bearer header.
The workflow reviews candidates at 10:17 UTC,
first waiting for the public /health endpoint to become ready, then processing up
to 10 batches of 1. Manual runs may select a batch size from 1 to 5. Configure
MEMORY_BASE_URL and MEMORY_DEFAULT_USER_TOKEN GitHub
repository secrets, deploy the new server, and add the workflow to the default
branch to enable it. Use the same MEMORY_DEFAULT_USER_TOKEN value configured on
the deployed server; Actions does not inherit local .env or Render environment
variables. Manual runs default to preview and no longer accept a date.
See the Chinese setup guide for API behavior and limits.
Invalid model review plans are discarded in full; summary service errors/timeouts use the same lossless fallback. Candidates are promoted individually with their original title/body and no model-proposed related links; plan_mode=verbatim_fallback is recorded in the response and creation events. Embedding outages, source-budget errors, and concurrent changes still fail without consuming candidates.
Batch/time limits finish successfully with a warning that candidates remain for the next run. Actual request, validation, or no-progress errors still fail the workflow.
Model usage ledger
Provider calls are recorded separately in logs/model-usage.sqlite3 (override with
MEMORY_USAGE_LOG_PATH; use a persistent mount in containers). Records include
run/call IDs, model, operation, system-prompt hash, reported input/output tokens,
latency and outcome. Missing usage is NULL, never zero. Dry runs, retries and calls
whose output later fails validation are retained independently of memory transactions.
No prompt/response text or credentials are logged. Successful maintenance responses
include usage_run_id. See the Chinese README for fields and querying examples.
Role-separated message ingestion
See message source schema and rollout for ingest_messages, reply links, multi-valued content kinds, and compatibility. No turn_id is required. Legacy ingest_turn remains available.
Daily workflow controls: manual runs default to dry_run=true and preview one batch.
Scheduled runs save results in batches of 1 after a bounded /health warm-up.
Manual batch_size accepts 1–5 (default 5); max_batches accepts
1–10 (default 10). The Actions job summary includes counts and server usage run IDs,
never note/diary bodies. Token counts stay in the server's usage ledger. A timeout does
not automatically retry a POST because server completion may be unknown. The workflow
stops starting batches after 30 minutes (45-minute job limit).
The Action calls the deployed /maintenance/review-candidates endpoint; it does not
run the local Python implementation or deploy it. Deploy current code and migrations
006/007 first to use selective work summaries and the new source schema.
Authentication upgrade
HTTP user-management routes (GET /users, GET /users/{user_id},
PUT /users/{user_id}, and PATCH /users/{user_id}) have been removed and return
404. MEMORY_ADMIN_API_ENABLED and MEMORY_ADMIN_API_TOKEN are no longer read;
remove them from deployment settings. Manage accounts with the
memory-admin CLI, which connects directly using
DATABASE_URL. Existing users, passwords, and memory data are preserved.
Scripts calling the removed endpoints must be retired or updated to use the
CLI's supported account operations; the CLI is not a one-for-one replacement
for the old arbitrary-ID upsert or display-name update endpoints.
User 0 accepts only the current MEMORY_DEFAULT_USER_TOKEN. After rotating or
removing that setting, restart every server process: the old stored hash is
rejected immediately, without first using the new token. Other users' database
tokens are unchanged. Already issued OAuth tokens have a separate lifecycle.
No database schema migration is required for this update.
OAuth login limits now apply per source IP (120 GETs/30 POSTs per minute) and per normalized account (10 password checks per minute after browser-state validation). Registration allows 60 attempts per IP per minute. These windows are process-local; configure trusted proxy IPs in the ASGI server and shared edge limits for multi-worker deployments. Forwarding headers are not trusted by the application itself. Each limiter retains at most 10,000 active keys and rejects new keys at capacity until old windows expire.
Unapproved OAuth clients expire after 24 hours. Registration reclaims expired, unreferenced clients and expired authorization requests without issued codes. Clients with authorization codes or token families are retained to preserve existing connections. A transaction-serialized database cap of 10,000 clients bounds registration storage across workers; capacity exhaustion returns 503. Expired rows are cleaned lazily on registration, not by a background timer.
Available Tools
2 toolsget_contextB
Retrieve compact durable memory context for the caller input.
Inputs: input (required), token (required), session_id, include_chunks, +2 more. Returns: object
ingest_turnC
Store one interaction as candidate durable memory.
Inputs: token (required), metadata (required), user_input (required), assistant_output (required). Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 2 tools
The two tools have completely distinct purposes: one stores a turn for potential durable memory, the other retrieves context. There is no ambiguity between writing and reading operations.
Both tool names follow the consistent verb_noun pattern: ingest_turn and get_context. The naming is clear and predictable.
With only 2 tools, the server is on the thin side for a full memory system, but it covers the basic store/retrieve workflow. It feels borderline for its stated purpose.
The memory domain typically requires update, delete, and list operations in addition to ingest and retrieve. The absence of these leaves significant gaps that could hinder agents needing to manage durable memory effectively.
Maintenance
Related MCP Connectors
Universal persistent memory and knowledge retrieval layer for AI agents and LLMs.
Persistent memory for AI agents. Semantic search, memory graph, W3C DID identity.
Persistent memory for AI agents. Search, store, and recall across sessions.
Universal memory for AI agents and tools. Save, organize and search context anywhere.
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.19Apache 2.0
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to store and retrieve long-term memories with semantic search, supporting various memory types and tags via PostgreSQL and pgvector.11 npmMIT
- AlicenseAqualityCmaintenanceProvides persistent, searchable memory for AI agents, enabling them to retain, recall, and reflect on information across conversations.1925 PyPI1MIT