fastmcp/docs/servers
Jeremiah Lowin 8363ec4d26
Add stateless session state (UserSession / SessionId) (#4604)
* Design doc: stateless session state

* Add stateless session-state primitives: Scope, SessionCodec, scoped state

* Add SessionProvider and Session() annotation for stateless session state

* Rewrite session-state design to final shape (Session object, two patterns, no seal)

* Rework stateless session state to final Session/SessionId design

Remove Scope, SessionCodec/sealing, and scoped ctx.get_state. Add the
Session object (get/set/delete/clear over one dict per (principal,
session_id) key), injected session: Session (keyed by principal, requires
auth), session_id: SessionId argument with auto-filled description, and
SessionProvider contributing create_session/end_session.

* Rename injected marker to UserSession; auto-wire SessionProvider on SessionId

* Document stateless session state as a v4 feature

* Require SessionProvider and make sessions create-then-validate

Remove the implicit SessionProvider auto-wiring; a SessionProvider must now be
registered explicitly. create_session records an owned session and get_session
validates the id, rejecting uncreated or foreign ids.

* Add Session.id (public id for session_id sessions, None for UserSession)

* Fix ty: narrow Tool | None and ToolResult.structured_content in session tests

* Fix session-provider enforcement gap for non-local tools; stop embedding raw principal in UserSession key

* Fix disabled session_id tools blocking listing; reject local tools shadowing SessionProvider lifecycle names

* Decouple SessionId description from lifecycle tool name so it survives namespaced mounts

* Remove SessionProvider enforcement; get_session validation is the guarantee

* Fix stale enforcement/key-format docs; document store-owned session TTL

* Dedup SessionId contract description; tighten context.mdx session-state lead

* Make session store/description resolution work in Docket task workers and for partial tools

* Expose get_session as a standalone task-safe function; drop foreground-only Context.get_session

* Move get_session to dependencies alongside the other request accessors

* Reframe context state docs as Request State; cross-request persistence points to Session State

* Address UserSession injection edge cases from review

- inject a UserSession instance (not bare Session) so isinstance holds
- support session: UserSession | None = None (inject None when unauth)
- detect SessionId params past a partial's positional binding
2026-07-23 19:21:00 -04:00
..
auth Add server-side identity assertion (SEP-990 ID-JAG) (#4483) 2026-07-18 19:52:15 -04:00
providers Mirror the frontend's protocol era on a proxy's backend connection (#4573) 2026-07-20 12:31:02 -04:00
transforms feat(code-mode): default sandbox limits and per-execution tool-call cap (#4170) 2026-05-20 10:47:12 -04:00
authorization.mdx Support async auth checks (#3152) 2026-02-11 12:48:51 -05:00
completions.mdx Let a server answer argument-completion requests (#4582) 2026-07-21 12:26:24 -04:00
composition.mdx Align server component docs (#4260) 2026-07-19 14:23:36 -04:00
context.mdx Add stateless session state (UserSession / SessionId) (#4604) 2026-07-23 19:21:00 -04:00
dependency-injection.mdx Align server component docs (#4260) 2026-07-19 14:23:36 -04:00
elicitation.mdx Trim fastmcp.types to FastMCP-unique types only 2026-07-20 20:53:11 -04:00
icons.mdx Trim fastmcp.types to FastMCP-unique types only 2026-07-20 20:53:11 -04:00
lifespan.mdx Restructure documentation for FastMCP 3.0 (#2951) 2026-01-19 21:33:35 -05:00
logging.mdx Restructure documentation for FastMCP 3.0 (#2951) 2026-01-19 21:33:35 -05:00
middleware.mdx Run FastMCP middleware for every inbound message (#4553) 2026-07-19 20:29:08 -04:00
pagination.mdx Align server component docs (#4260) 2026-07-19 14:23:36 -04:00
progress.mdx Align server component docs (#4260) 2026-07-19 14:23:36 -04:00
prompts.mdx Align server component docs (#4260) 2026-07-19 14:23:36 -04:00
resources.mdx Align server component docs (#4260) 2026-07-19 14:23:36 -04:00
sampling.mdx Trim fastmcp.types to FastMCP-unique types only 2026-07-20 20:53:11 -04:00
server.mdx Align server component docs (#4260) 2026-07-19 14:23:36 -04:00
sessions.mdx Add stateless session state (UserSession / SessionId) (#4604) 2026-07-23 19:21:00 -04:00
storage-backends.mdx Fix broken code examples in docs (#3869) 2026-04-12 12:53:04 -04:00
tasks.mdx Speed up the unit test suite, and fix the task-notification race it surfaced (#4550) 2026-07-19 18:52:04 -04:00
telemetry.mdx Align server component docs (#4260) 2026-07-19 14:23:36 -04:00
testing.mdx Restructure docs navigation: CLI section, Composition, More (#3361) 2026-03-02 21:09:48 -05:00
tool-fingerprinting.mdx docs: add tool fingerprinting recipe for stable schema hashing (#4233) 2026-05-27 10:52:14 -04:00
tools.mdx Trim fastmcp.types to FastMCP-unique types only 2026-07-20 20:53:11 -04:00
versioning.mdx Align server component docs (#4260) 2026-07-19 14:23:36 -04:00
visibility.mdx Align server component docs (#4260) 2026-07-19 14:23:36 -04:00