Document caching behavior and warn on non-conformant draft cacheable results (SEP-2549 follow-up) (#1669)

Co-authored-by: Tarek Mahmoud Sayed <tarekms@ntdev.microsoft.com>
This commit is contained in:
Tarek Mahmoud Sayed 2026-06-28 09:55:50 -07:00 • committed by GitHub
commit 8e7f28c237
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -92,6 +92,20 @@ public abstract partial class McpClient : McpSession
/// </summary>
private protected abstract int MaxConsecutiveStuckPolls { get; }
/// <summary>
/// Inspects a received cacheable result (<c>tools/list</c>, <c>prompts/list</c>, <c>resources/list</c>,
/// <c>resources/templates/list</c>, or <c>resources/read</c>) so derived clients can emit diagnostics.
/// </summary>
/// <param name="method">The request method that produced the result.</param>
/// <param name="result">The cacheable result returned by the server.</param>
/// <remarks>
/// This is used to warn (never throw) when a server that negotiated a protocol version requiring the
/// SEP-2549 <c>ttlMs</c>/<c>cacheScope</c> fields omits them. The default implementation does nothing.
/// </remarks>
private protected virtual void ValidateCacheableResult(string method, ICacheableResult result)
{
}
/// <summary>
/// Registers one or more tool definitions in the client's tool cache, enabling the transport
/// to send <c>Mcp-Param-*</c> headers for those tools without requiring a prior <see cref="McpClient.ListToolsAsync(RequestOptions?, CancellationToken)"/> call.