> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# No More Sessions

> Explains moving from process-local sticky sessions to handle-based stateless requests, compatibility issues between legacy and modern clients, and best practices for resilient session handling.

Alan builds an app that talks to a remote MCP server.

Every time his app sends a request, the server has forgotten everything about the last one.

Until recently, the server could hand back a header called an MCP session ID, and the client returned it on every later request. In short, the server remembered you. That made several things easier: the handshake happened once, the server could build and cache a tool list, and an open database connection could be keyed to your session ID in the server's memory.

![A stylized infographic titled "The Server That Remembered" showing a laptop labeled "Alan's App" connecting through a cloud to an MCP Server. A session ID tag and a server memory panel illustrate stored session data like handshake, tool list, and DB connection.](https://mintcdn.com/kodekloud-c4ac6d9a/0UyWJzvxepsOrybu/images/Model-Context-Protocol-Associate-MCPA-Certification/Messages-Tools-and-Sessions/No-More-Sessions/alan-app-mcp-server-session-memory.jpg?fit=max\&auto=format\&n=0UyWJzvxepsOrybu\&q=85\&s=642040dc7787f3595701ce9269281c19)

Why is that behavior gone?

Because that memory lived in a single process on a single machine. The session was implicitly tied to one process instance. For requests that used that session ID to work, each request had to be routed to that exact process on that exact machine — a pattern known as sticky sessions (session affinity).

Sticky sessions cause several operational problems:

* Load imbalance: the load balancer routes requests by identity instead of evenly, so a busy host stays busy while others are idle.
* Fragility during deploys: restarting the process drops all sessions it held, breaking live work.
* Ineffective scaling: adding servers doesn't migrate existing sessions to new machines.
* Operational burden to centralize session state (e.g., move to Redis), which requires pre-planning and extra implementation work across teams.

Sticky sessions increase operational complexity and make deployments brittle. Many deployments avoid them by removing session affinity from the protocol.

Instead of relying on process-local sessions, modern servers return short reference handles as ordinary data. The client stores and returns those handles as regular arguments; the server keeps any associated state keyed to the handle on its side. Because the handle itself travels inside the message, the server no longer requires sticky routing.

Example: a server returns a cursor handle when paging through a long list:

```json theme={null}
{
  "tools": [ /* 50 items */ ],
  "nextCursor": "page-abc123"
}
```

On the next request the client passes that handle back as a normal parameter:

```json theme={null}
{
  "method": "tools/list",
  "params": {
    "cursor": "page-abc123"
  }
}
```

Use lightweight handles (cursors, references, or tokens) inside the message body to maintain continuity without requiring sticky sessions. This is more resilient and simplifies load balancing.

Compatibility: what happens when new and old components meet?

There are four combinations to consider:

| Client | Server | Expected behavior |
| - | - | - |
| Modern client | Modern server | Works (handle-based protocol) |
| Legacy client | Legacy server | Works (session-header protocol) |
| Modern client | Legacy server | May hang or receive unexpected error codes (legacy server may wait for a session header the client doesn't send, or return legacy errors the client doesn't expect) |
| Legacy client | Modern server | Fails if the legacy client cannot adapt to the new protocol (e.g., it doesn't accept handle-based responses) |

![A dark-themed infographic titled "When Old Meets New" showing icons for Modern Client/Modern Server and Legacy Client/Legacy Server, with green check marks and red error boxes illustrating compatibility and an error code (-32001) when mixing legacy and modern components.](https://mintcdn.com/kodekloud-c4ac6d9a/0UyWJzvxepsOrybu/images/Model-Context-Protocol-Associate-MCPA-Certification/Messages-Tools-and-Sessions/No-More-Sessions/legacy-modern-compatibility-error-32001.jpg?fit=max\&auto=format\&n=0UyWJzvxepsOrybu\&q=85\&s=160050364d78741a2618d3a8458547f0)

Handling mixed-era deployments

Modern clients typically probe the server to determine its "era" and choose an appropriate code path. Common detection approaches:

* Over standard input/output (stdio): send a `server/discovery` request and consider any response that is not recognized as a modern error to indicate a legacy server.
* Over HTTP: inspect the body of a `400` (or similar) error to detect legacy-style error text such as the JSON-RPC "Method not found" code or a legacy HTTP error indicating a missing session.

Examples of legacy error bodies clients look for:

```text theme={null}
-32601
Method not found
```

```text theme={null}
400 Bad Request
Missing session ID
```

Clients cache the server-era verdict for the lifetime of that server instance because this behavior is an implementation property of the server process, not of individual requests. While older servers remain in deployments, modern clients keep both code paths available to interoperate with either era.

Best practices and references

* If you need shared, durable session state, prefer an external store (for example, Redis) rather than process-local memory. See Redis: [https://redis.io/](https://redis.io/)
* For protocol compatibility patterns and legacy error codes, refer to the JSON-RPC specification: [https://www.jsonrpc.org/specification](https://www.jsonrpc.org/specification)
* For load balancer behavior and session affinity options, see your platform docs (for example, Kubernetes session affinity: [https://kubernetes.io/docs/concepts/services-networking/service/#session-affinity](https://kubernetes.io/docs/concepts/services-networking/service/#session-affinity)).

This section covers tools, resources, and prompts.

> [card] [Watch Video](https://learn.kodekloud.com/user/courses/model-context-protocol-associate-mcpa-certification/module/282d97e2-04f7-4beb-8301-695ecb3f3f99/lesson/221dbf5a-e219-48f5-b0af-1d834f3e9f6e)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.