Session State
Custom Storage Backends
The default state store keeps everything in memory on the same process that runs the server. That is perfectly fine for a single-server deployment where all requests go to the same process — which is the common case when using STDIO or a single HTTP server.
For deployments where multiple server instances share load — such as a containerised service behind a load balancer — in-memory state will not work, because two requests from the same client may land on different machines. FastMCP supports plugging in an external storage backend for these cases:
from key_value.aio.stores.redis import RedisStore
# All sessions share the same Redis store, so state survives
# across multiple server instances
mcp = FastMCP(Practical MCP with FastMCP & LangChain
Engineering the Agentic ExperienceEnroll now to unlock current content and receive all future updates for free. Your purchase supports the author and fuels the creation of more exciting content. Act fast, as the price will rise as the course nears completion!
