Searching for mcp stateful vs stateless (or “server stateful / or stateless”) usually means you already picked remote HTTP for MCP—and now ops asks whether every request can hit any replica. Short answer—match session features to deploy shape. If the host needs multi-turn elicitation, sampling callbacks, subscriptions, or server→client notifications that assume a living session, prefer stateful (sticky) HTTP sessions. If tools are request/response and you need horizontal scale or serverless cold starts, prefer stateless designs. Transport choice first: stdio vs Streamable HTTP; sampling vs elicitation: sampling vs elicitation.

01

Independence note

02

What each term means (working definitions)

  • Stateful HTTP MCP: the server (or a session store it trusts) keeps session-scoped state across requests—so follow-ups, sampling/elicitation round-trips, and notifications can resume the same logical session. Often implies sticky routing or an external session backend.
  • Stateless HTTP MCP: each request carries what the server needs to authorize and execute; replicas stay interchangeable. Great for scale-out and many serverless shapes; weak when the protocol feature assumes a living session.

This fork is mostly about remote HTTP deployments. Local stdio already implies a process-bound session. Do not confuse “stateless tools” (idempotent handlers) with “stateless transport”—you can have careful tool design on either deploy shape.

03

Selection checklist

Prefer stateful when any of these are true:

  • You rely on elicitation or multi-turn user prompts mid-tool—see sampling vs elicitation.
  • You rely on sampling where the server asks the host/model mid-session.
  • You need subscriptions or server→client notifications tied to a session.
  • Tool handlers keep expensive in-memory handles (DB cursors, browser contexts) that must survive follow-ups.

Prefer stateless when most of these are true:

  • Tools are request/response with no mid-call host round-trips.
  • You need horizontal scale, autoscaling, or serverless with interchangeable instances.
  • Session affinity is expensive or unreliable in your mesh / CDN / load balancer.
  • Failure recovery should mean “retry the request,” not “rehydrate a sticky worker.”

04

Stateful vs stateless at a glance

Stateful HTTPStateless HTTP
Session featuresElicitation / sampling / notify / subscribe friendlierBest for pure request/response tools
ScalingNeeds stickiness or shared session storeAny replica; serverless-friendly
Failure modeLost sticky worker can drop mid-session workRetry / replay on another instance
Ops complexitySession TTL, affinity, store HAAuth, idempotency, payload size
Best default when…Protocol round-trips mid-sessionScale-out with simple tools

05

When to use which

  • Start stateful if your product story depends on elicitation, sampling, or live notifications. Design session TTL and sticky routing (or an external store) explicitly—do not discover affinity bugs in production.
  • Start stateless if tools are curated request/response actions and you already run horizontally scaled HTTP. Keep handlers idempotent; put long jobs behind job IDs rather than in-memory sessions.
  • Revisit after transport choice: if you are still on local stdio for a single developer host, this fork may not matter yet—see stdio vs Streamable HTTP.

06

Ops implications (without an SDK dump)

  • Auth still matters either way—remote MCP without auth is an attack surface; see best practices.
  • Timeouts and size caps apply to both shapes; stateful sessions need idle TTL as well.
  • Observability: tag logs with session / request IDs; alert on sticky failures separately from handler errors—see server testing.
  • Do not mirror SDK flag tables here—pin your SDK version and read its session/stream docs for exact knobs.

07

Anti-patterns

  • Claiming “stateless” while holding in-memory browser/DB handles per session with no shared store—replicas will lie.
  • Forcing sticky sessions for tools that never elicit or notify—paying affinity cost for no feature gain.
  • Ignoring idle TTL on stateful sessions until file descriptors and memory melt.
  • Restating the entire SDK config page on a blog—pin SDKs; keep indie pages as judgment.
  • Skipping auth because sessions are “internal”—meshes and leaked URLs are real.

09

FAQ

Is stateful MCP always better?

No. Stateful helps when session features (elicitation, sampling, notifications, subscriptions) matter. Stateless wins for scale-out and many serverless shapes with request/response tools.

Does this replace stdio vs Streamable HTTP?

No. Pick transport first (stdio vs Streamable HTTP), then decide whether remote HTTP sessions must be sticky or interchangeable.

Do I need stateful for elicitation or sampling?

Usually yes for a coherent mid-session round-trip. See sampling vs elicitation. If you can redesign the tool to avoid mid-call host prompts, you may stay stateless.

Is this an SDK configuration guide?

No. Deliberately not. Pin your SDK and read upstream session docs for exact flags. This page is selection judgment from 墨码 / codemo.fun.

Is this official documentation?

No. Unofficial engineering notes from 墨码 / codemo.fun. Spec text and SDK docs remain authoritative.