Integrate

Build an MCP memory server agents can trust

An MCP memory server gives compatible AI clients a standard way to remember, search, correct and forget durable context. The protocol handles discovery and transport; your server still owns storage, user and tenant isolation, provenance, retention and deletion.

Updated October 31, 202611 min readAI Memory field guide
A central MCP memory server connected to several isolated AI client memory chambers.

What is an MCP memory server?

A Model Context Protocol memory server is a program that exposes memory operations to an MCP host through tools, resources or prompts. Tools perform actions such as remembering or searching. Resources expose readable context. The MCP specification defines how clients discover and call these capabilities; it does not decide what should be remembered.

That boundary matters. MCP is the connection layer, not the memory architecture. A production server still needs identity, scoped storage, extraction, ranking, source history, correction and deletion. Without those controls, a memory server becomes a shared text file that every connected agent can poison or overread.

Should an MCP memory server run locally or remotely?

Use local STDIO when one desktop or coding client needs memory tied to that machine. Use remote Streamable HTTP when several clients need the same customer or team memory. The MCP architecture describes local STDIO servers as typically serving one client and remote Streamable HTTP servers as serving many clients.

ModeBest fitMain tradeoff
Local STDIOOne developer, one desktop, or a private project storeMemory usually depends on one machine and process lifecycle
Remote Streamable HTTPShared memory across Claude, Cursor, Codex, support tools or team appsRequires strong authentication, tenant isolation and operations
Remote with per-client tokensThe same server serving several products or client installationsEvery connection must resolve to the correct user and tenant before tool execution

Do not copy a local JSON memory file into a remote deployment and call it multi-client memory. The remote version needs a real identity and authorization model.

Which tools should an MCP memory server expose?

Expose a small, unambiguous tool surface. The model should know exactly when to search memory, when to save a durable fact and when a fact should be corrected or removed. Bloated tool sets create ambiguous choices and increase context cost.

ToolInputExpected behavior
search_memoryNatural-language query, optional memory kind, result limitSearch only the authenticated principal’s allowed scopes
rememberA concise event, source and optional subjectExtract or write durable memory; reject secrets and transient chatter
correct_memoryMemory ID, replacement fact and reasonSupersede the old value while preserving an audit trail
forget_memoryMemory ID or authorized scopeDelete the record and its derived retrieval artifacts
memory_summaryAllowed scope and optional topicReturn a bounded summary without dumping the full graph

The tool schema should not accept userId or tenantId from the model. Those values belong to the authenticated MCP connection.

How should an MCP memory server scope user and tenant data?

Resolve authorization before a tool handler runs. Bind the MCP session or access token to a principal, then pass that trusted context into memory reads and writes. If scope resolution fails, return an error instead of falling back to a shared identity.

  • Use the authenticated principal, not generated tool arguments, for scope.
  • Keep tenant at the outermost boundary and user inside it.
  • Use client and agent identifiers for provenance, not as a bypass around user scope.
  • Block writes that contain credentials, payment data or unrelated sensitive details.
Trusted tool boundarytypescript
type Principal = {
  tenantId: string;
  userId: string;
  clientId: string;
};

async function searchMemory(
  input: { query: string; limit?: number },
  principal: Principal
) {
  if (!principal.tenantId || !principal.userId) {
    throw new Error('Authorized memory scope is missing');
  }

  return memory.search({
    query: input.query,
    userId: principal.userId,
    metadata: { tenant: principal.tenantId },
    limit: Math.min(input.limit ?? 8, 12),
  });
}

How can several MCP clients share the same memory?

Share a remote memory service, not a raw transport session. Each host opens its own MCP connection, authenticates the same human identity and receives a scoped view of the same durable graph. A Cursor client, Claude client and web agent can then remember the same project without copying private context into one another’s local files.

Use separate agent identities when working context should stay private. A shared project decision can live at project scope while a coding agent’s temporary hypothesis remains scoped to that agent or run. Promotion from private to shared memory should be an explicit operation.

MemorySuggested scopeExample
Company accounttenantCurrent plan and security region
Personal preferencetenant + userPreferred language and review style
Project decisiontenant + projectPostgres is the approved primary database
Agent working statetenant + agent + sessionA temporary migration hypothesis
Shared team facttenant + teamThe release window and approval owner

How should you secure an MCP memory server?

Remote servers should use standard HTTP authorization, normally OAuth-based access tokens, and validate the token on every request. Local servers still need a boundary because a compromised host process can read anything that server can access.

Memory tools also expand the prompt-injection surface. Treat tool results as untrusted data, attach provenance to every memory, and require confirmation before high-impact actions based on remembered facts. A poisoned preference should not be able to redirect a payment or change production access.

  • Require authenticated transport for remote memory and rotate credentials.
  • Validate token audience, tenant, user and expiry before dispatch.
  • Store source, timestamp and trust level next to every durable fact.
  • Rate-limit searches and writes per principal to contain noisy clients.
  • Log tool name, scope hash and outcome without logging memory content.
  • Test deletion through every client and every read path.

How do you test an MCP memory server?

Test protocol behavior and memory behavior separately. First prove discovery and tool calls work in the MCP Inspector. Then prove the same identity retrieves only authorized memory and that a second user or tenant cannot cross the boundary.

TestPass condition
Client discovers toolssearch_memory, remember and correction/delete tools appear with precise schemas
Same user, second clientThe durable project fact is retrieved without copying local state
Same agent, different tenantNo foreign tenant memory is returned
User asks to forgetThe memory disappears from search, summaries and export
Tool result contains injected instructionsThe host treats it as data, not authority
Remote token expiresThe call fails closed instead of using a default scope

What is the recommended MCP memory architecture?

Keep the MCP layer thin and the memory contract explicit. Resolve identity at the transport boundary, expose only a few tools, enforce scopes inside every handler and make correction and deletion first-class. The protocol makes memory portable across clients only when the service behind it remains portable and governed.

Frequently asked questions

Is MCP itself a memory system?

No. MCP standardizes how clients and servers exchange tools, resources and prompts. Durable storage, extraction, retrieval and lifecycle policy must exist behind the server.

Should an MCP memory server be local or remote?

Use local STDIO for a single private client and remote Streamable HTTP for memory shared across clients. Remote deployment requires stronger authentication and tenant isolation.

Can Claude, Cursor and Codex use the same memory?

Yes, if each host connects to the same authenticated remote memory service and resolves the same authorized user and project scope.

Should tenant IDs be tool arguments?

No. Resolve the tenant from the authenticated MCP connection. Letting the model supply a tenant ID creates an authorization bypass.

How many memory tools should an MCP server expose?

Expose the smallest clear set: search, remember, correct, forget and optionally a bounded summary. Avoid overlapping tools that force the model to guess.

Does AI Memory currently provide a hosted MCP server?

This guide describes the server contract rather than claiming an unsupported hosted feature. Use the AI Memory API for durable storage, or confirm current MCP availability before configuring a client.

Give MCP clients one governed memory boundary

Start with lookup and remember tools, resolve identity outside the model, then test a second client, a second user and a deletion request.