# Where should an MCP server store per-user data? State after MCP sessions

Source: https://crabtalk.ai/blog/mcp-server-per-user-data-storage
Published: 2026-11-25

> Where an MCP server should store per-user data now that MCP 2026-07-28 removed sessions: four storage options, keyed by the verified user, compared.

An MCP server that remembers anything between calls (a user's preferences, a draft, a saved search) needs somewhere to keep it, keyed by who is calling. The 2025-11-25 transport let a server hold state against a protocol session. The [2026-07-28 revision](https://modelcontextprotocol.io/specification/2026-07-28/changelog) removed sessions: "Remove protocol-level sessions and the `Mcp-Session-Id` header from the Streamable HTTP transport." This post covers what the specification now says about state, four places to keep per-user data, and the mistake each one invites.

## What changed in 2026-07-28

The [Streamable HTTP transport](https://modelcontextprotocol.io/specification/2025-11-25/basic/transports) in 2025-11-25 let a server assign an `Mcp-Session-Id` at initialization and tie state to it. In 2026-07-28:

- **No sessions and no handshake.** "Make MCP stateless: remove the `initialize`/`notifications/initialized` handshake." Every request carries its protocol version and capabilities in `_meta`.
- **Cross-call state goes in handles.** "Servers that need cross-call state use explicit, server-minted handles passed as ordinary tool arguments." [SEP-2567](https://modelcontextprotocol.io/seps/2567-sessionless-mcp) describes the shape as `create_*() -> handle`, with the handle passed to later calls.
- **Lists don't vary per connection.** `tools/list` and the other list endpoints "no longer vary per-connection".

Handles are for things created across calls: a draft, a search, a running job. Data that simply belongs to the user, such as their preferences, needs no handle at all; the server looks it up by the authenticated user on every call.

## Bind state to the verified user

The 2026-07-28 [security best practices](https://modelcontextprotocol.io/docs/2026-07-28/tutorials/security/security_best_practices) set the rule for handles: "MCP servers **MUST NOT** treat possession of a state handle as authentication." It recommends binding each handle to the authenticated user, for example by "keying stored state as `<user_id>:<handle>`", with the user ID "derived from the verified token rather than supplied by the client."

A handle can leak into a log, a transcript or another agent's context. If the handle alone unlocks the data, whoever holds it reads it. Bound to the user, a leaked handle is useless to anyone else.

## Four places to keep per-user data

| Where | Keyed by | A bug that leaks data | Deleting one user's data |
| --- | --- | --- | --- |
| Client-held state | A token the client passes back | A token not bound to its user, or replayed | The server can't delete copies the client holds |
| Key-value store | `user_id:key` | A key built from a client argument | List and delete by prefix |
| Shared database, `user_id` column | A column every query filters on | A query without the filter | Delete from every table |
| A database per user | The database itself | Opening the wrong user's database | Delete one file |

**Client-held state.** Small state can travel in a token the client passes back. Signing it protects its integrity, and authenticated encryption also hides its contents. It still needs binding to its user, and a copy can be replayed until it expires unless the server tracks revocation or a version. Nothing to store, but nothing to query or delete either.

**Key-value.** A store keyed by `user_id:key` fits preferences and small documents. The mistake to avoid is building the key from a tool argument, so that any user can name any key.

**A shared database.** One set of tables with a `user_id` column, as in most web apps. It supports queries across users, and it carries the classic risk: one query that forgets `WHERE user_id = ?` returns everyone's rows. We compare it with the alternatives in [Database per tenant](/blog/database-per-tenant-shared-schema-or-database).

**A database per user.** Each user's data in its own SQLite database, opened by the server for the verified user. A query can't reach another user's rows because they aren't in the file, and one user's data is exported or deleted as one file. What it gives up is queries across users, which belong in a shared database beside it.

Cloudflare's stateless [`createMcpHandler`](https://developers.cloudflare.com/agents/model-context-protocol/apis/handler-api/) points the same way: "Store cross-request data behind an authenticated handle in a Durable Object, D1, KV, or R2". Its session-based [`McpAgent`](https://developers.cloudflare.com/agents/model-context-protocol/apis/agent-api/) is now marked deprecated.

## Where the user ID comes from

Whichever store you choose, the key has to come from verified identity, never from the request body. A tool argument such as `{"user": "alice"}` is something the model wrote, and a model can be talked into writing someone else's name. With OAuth, take the user from the access token your server validated, issued for your server. An opaque token is resolved from your own credential store if your server issued it, or by [token introspection](https://www.rfc-editor.org/rfc/rfc7662.html) where the authorization server supports it; introspection's `sub` is optional, so check that the response names a user. If the server accepts several issuers, key by issuer and subject together, since two issuers can use the same subject. We cover the OAuth flow in [Remote MCP server authentication](/blog/mcp-server-authentication-oauth-api-keys).

## Per-user data on CrabTalk

A CrabTalk service declares [caller storage](/docs/development/caller-storage), and the host gives each caller its own SQLite database:

```rust
use berm_lang::caller_storage;

caller_storage::set("timezone", &zone)?;
let timezone: Option<String> = caller_storage::get("timezone")?;
```

- **The host picks the database** from the verified caller: the billed account and, when present, the end user, by issuer and subject. An end user comes from a verified app sign-in or from a service that vouched for them. The code above names no user, so no argument can select another user's data. Members of an organization calling as the org, with no separate end user, share one database.
- **SQL or key-value.** `caller_storage::rows` runs SQL against the caller's tables; `get` and `set` store values by key.
- **Shared data sits beside it.** Data every caller sees, such as a catalog or counters, goes in the service's [shared storage](/docs/development/data).
- **The caller holds it.** Each caller's database counts toward the billed account's plan storage. Accounts download or delete it from their Storage page, and verified app users reach theirs through the [storage API](/docs/guides/caller-storage#api).

Direct anonymous calls get an empty, temporary database initialized from the migrations, and their writes are refused. See [Caller storage](/product/caller-storage).
