Table of Contents

Interface ICacheableResult

Namespace
ModelContextProtocol.Protocol
Assembly
ModelContextProtocol.Core.dll

Represents a result that carries time-to-live (TTL) caching hints, allowing clients to cache the response for a period of time before re-fetching.

public interface ICacheableResult

Remarks

This interface corresponds to the CacheableResult type in the Model Context Protocol schema and is implemented by the results of server/discover, tools/list, prompts/list, resources/list, resources/templates/list, and resources/read.

The TTL is a freshness hint, not a guarantee. It supplements rather than replaces the existing list_changed and resources/updated notification mechanisms; both can coexist. A relevant notification invalidates a cached response regardless of any remaining TTL.

Properties

CacheScope

Gets or sets the intended scope of the cached response.

CacheScope? CacheScope { get; set; }

Property Value

CacheScope?

Remarks

When this property is null (the field was absent from the response), clients should treat the response as Public.

An unrecognized or future scope value sent by a server (or a non-string value) is tolerated and surfaced as null rather than causing deserialization of the whole result to fail, so a single unexpected hint never prevents a client from reading the result.

TimeToLive

Gets or sets a hint indicating how long the client may cache this response before re-fetching.

TimeSpan? TimeToLive { get; set; }

Property Value

TimeSpan?

Remarks

The semantics are analogous to the HTTP Cache-Control: max-age directive. The value is serialized as an integer number of milliseconds under the ttlMs JSON property.

A value of Zero indicates the response should be considered immediately stale; a positive value indicates the client should consider the response fresh for that duration from the time it was received.

When this property is null (the field was absent from the response), clients should assume a default of Zero (immediately stale) and rely on their own caching heuristics or notifications. The SDK preserves whatever value the server sent and does not coerce it; a client that receives a negative value should treat it as immediately stale.