Skip to main content
Serverless MCP servers (Vercel, Lambda, Cloud Run scaled to zero) handle initialize and each tool call on different instances. Two things break without help: session identity (calls stop lining up into one session) and delivery (the platform freezes your process before background events are sent). Both fixes are one-liners.

1. Use await delivery

Background delivery relies on the process staying alive after the response. In serverless, send events before returning instead:

2. Resolve the session per request

The SDK mints identity-bearing session IDs (mcp_<client>_v_<version>_<uuid>) on initialize and reads them back on later requests, so client attribution survives across instances.
Call resolveStatelessHttpSession per request and pass the results to the transport and dispatch context:
Session IDs are attribution metadata, not a security boundary — they are echoed by clients unsigned. Keep authorization on your own auth layer.