Feedback

Chat Icon

Practical MCP with FastMCP & LangChain

Engineering the Agentic Experience

Session State
68%

What Values Can Be Stored

By default, state values must be JSON-serializable — that means Python dicts, lists, strings, numbers, and booleans. This constraint exists because FastMCP needs to be able to persist the value and potentially hand it off across process boundaries or store it in an external backend.

If you need to store something that cannot be serialized — an HTTP client instance, a database connection, a compiled regular expression — you can opt out of serialization by passing serializable=False:

import httpx

@mcp.tool
async def setup_client(ctx: Context) -> str:
    """Create an HTTP client and store it for the session."""

    # serializable=False allows storing non-JSON objects,
    # but the value only survives for the current request
    client = httpx

Practical MCP with FastMCP & LangChain

Engineering the Agentic Experience

Enroll 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!