Knowledge as of Oct 26, 2026
The Inference TimesReference architectures, tutorials, demos and free skills — by Nitin Goswami
Epoch III · Step 16Ask the AI Nitin →

REFERENCE ARCHITECTURE · mcp-agent-memory · October 26, 2026

Agent memory over MCP: giving any model a long-term memory it can call

Agent memory over MCP puts an assistant's long-term memory in its own small server, so that any app that speaks the Model Context Protocol can save facts and look them up again. Explained with three diagrams and one worked example.

Domain
AI agents
Level
Beginner
Key concepts
MCP host · client · server · tools vs resources · vector store and embeddings · retrieval and learning actions
Related demos
MCP Memory Demo

In one picture

A language model forgets everything when a conversation ends. Agent memory over MCP fixes that by running a memory server: a small program that stores memories in a vector store and offers them as tools the model can call, over the Model Context Protocol (MCP), an open standard for connecting AI apps to outside tools and data (MCP specification, 2025). In the terms of the CoALA framework (Sumers et al., 2023), saving a memory is a learning action and looking one up is a retrieval action. Both move information between long-term memory and the model's working memory, which is its context window.

Host (chat app, IDE) Model context window = working memory MCP client tool call memories Memory server write · learning search · retrieval list recent delete · forget stats (resource) MCP stdio or HTTP Long-term memory Embedder text → vector Vector store + tags, time, source text vector top-k
Agent memory over MCP at a glance: the host keeps the model, a separate memory server owns long-term memory, and search results flow back into the context window.

Why it matters

Without a shared memory, every AI app builds its own. A chat app keeps a history in its database, a coding assistant keeps notes in a file, and a custom agent keeps a vector index in its own code. None of them can read the others' memories, and moving to a new client means starting again. Stuffing everything into the prompt doesn't scale either: the context window fills up, costs rise, and old details get cut off.

Putting memory behind MCP makes three questions easy to answer:

  • Where does the agent's memory live, and who owns it? In one server you run, whatever app you use to chat.
  • When does the model remember, and when does it look things up? Exactly when it calls the write or search tool, and each call is visible to the user.
  • Can I swap the parts? Yes. Change the client, the embedding model or the vector store, and the other two stay the same.

The building blocks

PartHolds / doesEveryday example
HostThe app the person uses. It runs the model and decides which servers to connect (MCP architecture, 2025)A desktop chat app or an IDE
MCP clientLives inside the host. It keeps one connection to one server and passes messages back and forthA phone line to one specific helpdesk
Model and context windowThe model reasons over whatever is in its context window. This is CoALA's working memoryThe notes on your desk right now
Memory serverA separate program that exposes memory through MCP. It never sees the whole conversation, only the calls it receivesA librarian you send requests to
ToolsActions the model chooses to call: write, search, list recent, delete. MCP calls tools "model-controlled"Asking the librarian to file or find a note
ResourcesRead-only data the host decides to show, addressed by a URI (MCP calls these "application-driven")The library's notice board
EmbedderTurns text into a vector, a list of numbers where similar meanings sit close togetherShelving books by topic, not by title
Vector storeSaves each memory's text, vector and metadata (tags, time, source), and finds the nearest vectors to a queryThe card catalogue

Two kinds of long-term memory from CoALA show up here. Episodic memory holds what happened ("on Monday you said the kickoff moved"). Semantic memory holds lasting facts ("you're allergic to shellfish"). A simple memory server keeps both in one collection. Tags and timestamps are what let you tell them apart later.

How it works

One turn of a conversation, reading and then writing:

  1. Discover. When the host starts, the client connects to the memory server and asks for its list of tools. Each tool comes with a name, a description and an input schema, and the host shows these to the model.
  2. Decide. The person asks something like "what did I say about the project kickoff?" The model sees a search tool that fits, and chooses to call it with a short query.
  3. Search. The client sends the call to the server. The server turns the query into a vector and asks the vector store for the closest matches (the top-k), optionally filtered by tags.
  4. Return. The server sends back each match with its text, metadata and a similarity score. The host places these in the context window, so they're now in working memory.
  5. Answer. The model answers from the memories it just retrieved. This is the same pattern as retrieval-augmented generation (Lewis et al., 2020), except the model decides when to retrieve.
  6. Learn. When the person says something worth keeping, the model calls the write tool. The server embeds the text and stores it with a timestamp. The next session, on any client, can find it.
Model MCP client Memory server Vector store Read · retrieval Write · learning search(query) tools/call embed + top-k ids + distance matches + score into the context write(fact) tools/call embed + add
One turn: the model calls search and the matches land in its context window, then it calls write to store a new fact.

A worked example: the MCP Memory Demo

The MCP Memory Demo is this architecture in about 200 lines of Python. Its personal-memory server offers four tools: remember is the learning action, recall is the retrieval action, list_recent reads the latest memories in time order (an episodic read), and forget deletes one by id. A memory://stats resource shows how many memories are stored. Memories live in one local ChromaDB collection, searched by cosine similarity and embedded with the small all-MiniLM-L6-v2 model, so it needs no API key. It runs over stdio for a desktop client, or over HTTP. What it leaves out is just as useful to see: there's no login or per-user separation, no merging of duplicate memories, no time-range filters and no keyword search alongside the vector search.

Claude Desktop host + MCP client context = working mem. MCP stdio, or :8000/mcp personal-memory server remember · learning recall · retrieval list_recent · episodic forget · delete by id memory://stats all-MiniLM-L6-v2 ONNX · 384-d ChromaDB cosine HNSW, local episodic + semantic text vector top-k Not in the demo (dashed) auth · per-user scope dedupe · consolidate time-range filters hybrid keyword search
The MCP Memory Demo mapped onto agent memory over MCP. Dashed boxes are the parts it leaves out.

Patterns & variations

PatternWhat changesWhen to use it
Tool-only memoryThe model calls write and search itself, as in Fig. 2Personal assistants, where the user can watch each call
Automatic recallThe host searches memory before every turn and adds the results without asking the modelWhen the model forgets to look things up, or for very short chats
Memory as resourcesMemory collections ("people", "last 24 hours") are listed as resources the host or user picksWhen people want to choose exactly what context goes in
Self-managed memory (Packer et al., 2023)The model moves information between its context and outside storage itself, like an operating system paging memory in and outLong tasks that outgrow a single context window
Reflection (Park et al., 2023)A background job reads recent memories and writes short summaries or conclusions backLong-running agents with many small, repetitive memories
Shared team memoryOne server over HTTP, with sign-in, and memories scoped per user or teamSeveral people or agents sharing what they've learned

Pitfalls

PitfallWhat you'll noticeRemedy
The model never calls memoryIt asks you things you told it last weekWrite clear tool descriptions, mention memory in the system prompt, or add automatic recall
Remembering everythingSearch returns ten near-copies of the same factRemove duplicates on write, and merge or summarise old memories on a schedule
Pure vector searchQuestions like "last Tuesday" or an exact product code return the wrong memoriesAdd time and metadata filters, and combine keyword search with vector search
An open HTTP endpointAnyone who finds the URL can read or delete memoriesRequire sign-in on remote transports, and scope every query to one user (the MCP spec says servers must implement access controls)
Untrusted text written to memoryA pasted web page plants an instruction that resurfaces in later chatsRecord the source of each memory, show writes to the user, and treat retrieved text as data, not instructions
Changing the embedding modelSearch quality suddenly drops after an upgradeStore the embedding model's name with the collection, and re-embed everything when it changes

Go further

  • See it built: the MCP Memory Demo implements Fig. 3 with four tools and a local vector store.
  • Read: the MCP specification's pages on architecture, tools and resources, then Sumers et al. (2023) for the memory vocabulary. Both are listed below.
  • Next: CoALA: how language agents remember, decide and act explains working, episodic and semantic memory in depth.

Credits & sources

  1. Model Context Protocol. Specification: Architecture (2025)The host, client and server roles, one client per server, and the principle that servers don't see the whole conversation; used in Fig. 1 and the building blocks.
  2. Model Context Protocol. Specification: Tools (2025)Tools as "model-controlled", the tools/list and tools/call messages in Fig. 2, and the requirement that servers implement access controls.
  3. Model Context Protocol. Specification: Resources (2025)Resources as "application-driven" and addressed by URI; the Memory as resources pattern.
  4. Theodore R. Sumers, Shunyu Yao, Karthik Narasimhan, Thomas L. Griffiths. Cognitive Architectures for Language Agents (2023)Working, episodic and semantic memory, and retrieval and learning actions, used to name each part.
  5. Patrick Lewis, Ethan Perez, Aleksandra Piktus, Fabio Petroni, Vladimir Karpukhin, Naman Goyal, Heinrich Küttler, Mike Lewis, Wen-tau Yih, Tim Rocktäschel, Sebastian Riedel, Douwe Kiela. Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (2020)The retrieve-then-generate pattern behind the search step.
  6. Charles Packer, Sarah Wooders, Kevin Lin, Vivian Fang, Shishir G. Patil, Ion Stoica, Joseph E. Gonzalez. MemGPT: Towards LLMs as Operating Systems (2023)The self-managed memory pattern.
  7. Joon Sung Park, Joseph C. O'Brien, Carrie J. Cai, Meredith Ringel Morris, Percy Liang, Michael S. Bernstein. Generative Agents: Interactive Simulacra of Human Behavior (2023)The reflection pattern.
  8. Model Context Protocol contributors. MCP Python SDK · MITThe SDK the worked example is built on, with its stdio and Streamable HTTP transports.
  9. Chroma. Chroma documentation · Apache-2.0The vector store in the worked example.
  10. Sentence Transformers. all-MiniLM-L6-v2 · Apache-2.0The 384-dimension embedding model in the worked example.
  11. Original workThe three figures and the mapping of an MCP memory server onto CoALA's memory types and actions are new in this explainer.

More Reference Architectures

Reference Architecture · Voice AI

Grounded voice insight: turning recorded speech into claims you can check

A pattern for getting judgements out of recorded conversations that a reader can verify: transcribe, measure what can be counted, let an LLM judge the rest with quotes, and check every quote against the transcript before showing it. Explained with two diagrams.

Reference Architecture · Agents

What is an internal agent SDK? One shared way for many teams to build AI agents

A shared toolkit that lets every team in a company build AI agents the same safe way: each team writes only what is unique to its agent, and the SDK supplies the checks, the step-by-step runner, saved progress, human sign-off, model access and cost limits. Explained with two diagrams.

Reference Architecture · Agents

CoALA: how language agents remember, decide and act

A reference architecture for thinking about any LLM agent: three kinds of long-term memory, a working memory where the model reasons, an action space, and a decision cycle that ties them together. Explained with two diagrams and one worked example.