October 29, 2026

MCP Memory OAuth: Secure Remote Agent Memory Without Shared Keys

Connect remote MCP memory with OAuth 2.1, understand the security boundary, and run a practical scope, write, revocation, and isolation test.

MCP memory OAuth is the right default when a human connects Claude, Cursor, or another interactive client to remote agent memory. Instead of pasting one long-lived shared key into configuration, the client discovers an authorization server, opens a browser, and receives a token after the user signs in and approves access.

Authentication alone is not enough. A memory token must also answer: which person, which project, and read-only or write? Durable memory can contain product decisions, customer context, and operating procedures. For that material, your agent's memory should be files you can read, edit, and self-host—not only embeddings hidden behind a retrieval API. Meshnote exposes readable Markdown wikis over MCP and lets a user approve selected projects and access level.

What the leading MCP OAuth guides cover

The current leading results explain the protocol well. The official Model Context Protocol authorization tutorial separates the MCP server as a protected resource from the authorization server, then walks through RFC 9728 protected-resource discovery, token issuance, and token validation. ScaleKit's implementation guide focuses on shipping the server: OAuth middleware, discovery metadata, HTTPS, and validating issuer, audience, signature, and expiry. Its 2026 authorization guide adds the current client-registration choices, including Client ID Metadata Documents and Dynamic Client Registration, plus scopes and the initial 401 challenge.

Those are useful implementation references, but they stop at “the token works.” This guide adds the missing memory-specific artifact: an authorization acceptance test that proves project isolation, read-only enforcement, revocation, and a clean second-client handoff. That is more valuable than a green login screen.

The OAuth flow, in practical terms

  1. Challenge: the client calls the remote /mcp endpoint without a token. The server returns 401 and a WWW-Authenticate header pointing to protected-resource metadata.
  2. Discovery: the client reads the resource document, finds the authorization server, and reads its metadata. This avoids hard-coding login endpoints into every MCP client.
  3. Registration: a public client identifies itself through a supported registration mechanism. It cannot safely keep a client secret, so the authorization-code flow uses PKCE with S256.
  4. Consent: the browser authenticates the person. The consent screen should expose concrete memory permissions—not a vague “access your account.”
  5. Exchange: the client exchanges the short-lived, single-use code plus its PKCE verifier for an access token.
  6. Enforcement: the MCP server validates the token and applies identity, project, and operation permissions on every tool call.

PKCE protects the authorization code from interception; it does not decide what the token may read. Likewise, a valid signature proves who issued a token, not that write_page should be allowed. Authorization remains an application responsibility.

Working setup: Meshnote with Claude Code

This setup uses Streamable HTTP and browser OAuth. It puts no token in your repository:

claude mcp add --transport http --scope user meshnote https://meshnote.io/mcp
claude mcp list

Start Claude Code, run /mcp, select meshnote, and choose Authenticate. Sign in in the browser, select only the project or projects this client needs, and choose read-only unless the agent must maintain the wiki. After approval, ask Claude to call list_projects and get_index for the selected project.

For Claude.ai, add a custom connector named meshnote with URL https://meshnote.io/mcp; leave client ID and secret empty so the client can use discovery and registration. For a non-interactive worker, a separately issued, narrowly scoped API key can be more appropriate because no person is present to complete browser consent. Do not commit that key.

If you need the broader memory lifecycle after connection, see the MCP memory server guide. For native-plus-external memory boundaries, see Claude Cowork memory; for another OAuth client walkthrough, see Hermes Agent memory.

Run the four-part authorization test

Create two test projects, oauth-red and oauth-blue. Put a harmless marker page in each. Authorize Client A for oauth-red, read-only.

  1. Isolation: call list_projects. Client A should see oauth-red, not oauth-blue. Search for the blue marker; it must not appear.
  2. Write boundary: ask Client A to call write_page in red. The server must reject it. A model instruction saying “do not write” is not enforcement.
  3. Revocation: revoke the connection or API key, then retry get_index. The old credential must fail rather than retain cached access.
  4. Second client: authorize Client B for blue with write access. Write a page, open a fresh session, and read it back. Client B must not gain red access merely because both clients belong to one person.

Also inspect the human-readable source after the test. Confirm that the write landed in the intended wiki, has the expected title, and can be corrected without reverse-engineering an embedding. This combines protocol security with storage ownership.

OAuth, API keys, and local stdio are different choices

ConnectionBest fitStrengthTrade-off
OAuth remote MCPInteractive users and multiple clientsBrowser consent, scoped tokens, revocation without editing configMore server endpoints and state; client compatibility matters
Scoped API keyCI, workers, headless agentsSimple and deterministicSecret distribution and rotation are your responsibility
Local stdio MCPSingle-machine private workflowsNo public network endpointHarder to share across devices and hosted clients

Do not add OAuth merely to make a local process look enterprise-ready. Do not expose stdio memory through an unauthenticated tunnel either. Choose according to where the client runs and whether a human can consent.

How current memory products differ

Mem0 offers a hosted MCP endpoint with OAuth and structured tools for adding, searching, updating, deleting, and enumerating memories. It fits teams that want managed semantic memory. Zep offers remote MCP access to user context through OAuth 2.1 with PKCE and can broker an organization's identity provider; its temporal graph is useful when relationships and facts evolve over time. Letta centers stateful agents and agent-managed memory blocks, which is a better fit when the agent runtime itself should own evolving state. Native ChatGPT and Claude memory reduce setup inside their own products, but portability and administrative controls depend on that host.

Meshnote is deliberately different: the durable project truth is a Markdown wiki, MCP is the client-neutral access layer, and OAuth grants access to selected projects. That favors inspectability, manual correction, and self-hosting over automatic fact extraction. If your workload needs fuzzy recall across millions of conversational fragments, a vector or graph system may be the better retrieval engine—or a derived index beside readable canonical files.

Security checklist for remote memory

  • Require HTTPS and reject bearer tokens sent to the wrong resource.
  • Use authorization-code flow with PKCE for public interactive clients.
  • Validate issuer, audience or resource, signature, expiry, and granted scopes.
  • Separate read from write and default consent to the least privilege.
  • Apply tenant and project filtering in the data layer, not only in tool descriptions.
  • Keep authorization codes short-lived and single-use; support token or key revocation.
  • Never place shared bearer credentials in a committed MCP configuration.
  • Test denial paths, not only successful login.

OAuth secures the route to memory. It does not make bad memories correct, make opaque storage auditable, or decide what deserves promotion from a conversation. Pair the protocol with a clear memory contract and the correction, provenance, and recovery practices in the persistent agent memory architecture.

For a working programmatic client, follow the Pydantic AI OAuth MCP memory setup.

Related Reading

Start syncing — $8/mo, or choose Self-hosted for teams from $10/seat/month.

Custom harness developers can pair this authorization model with the runnable custom agent memory client and its cross-process persistence and correction test.

Your agent's memory should be files you can read and own

Meshnote is readable, self-hosted memory for AI agents — markdown wikis your agents maintain over MCP. Hosted from $8/month.

Start syncing — $8/mo

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.