KeyValueResponseCacheStore (client/caching.py)

fastmcp · fastmcp_slim/fastmcp/client/caching.py · python · Apache-2.0
database

Adapter implementing ResponseCacheStore using AsyncKeyValue for distributed caching.

# Source: https://github.com/PrefectHQ/fastmcp | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
# Provided via justclaw.it.com; keep this notice with the code.
"""A client response cache store backed by AsyncKeyValue.

The MCP SDK's client response cache (SEP-2549) reads and writes through a
pluggable `ResponseCacheStore` protocol; the default is a per-client in-memory
LRU. This module adapts that protocol onto the `AsyncKeyValue` key-value
abstraction FastMCP already uses for its other state-management surfaces (the
event store, the OAuth proxy, the response-caching middleware), so a fleet of
FastMCP clients — for example a set of proxy replicas — can share one
Redis-backed response cache.

Because a shared store mingles cached responses across

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key