Document caching behavior and warn on non-conformant draft cacheable results (SEP-2549 follow-up)#1669
Open
tarekgh wants to merge 1 commit into
Conversation
…results Follow-up to the SEP-2549 caching hints work in PR modelcontextprotocol#1623, addressing two of its tracked follow-up issues: Fixes modelcontextprotocol#1645: Tighten the doc comments on the auto-paginating list overloads (tools/prompts/resources/resource-templates) to state plainly that the SDK performs no internal caching of listing results, and that any caching of ttlMs/cacheScope must be done by the caller via the lower-level non-auto-paginating overloads, which surface those fields per page. Fixes modelcontextprotocol#1650: Log a warning (never throw) when a server that negotiated the draft protocol version returns a cacheable result (tools/list, prompts/list, resources/list, resources/templates/list, resources/read) without the now required ttlMs/cacheScope fields. The warning is emitted at most once per method per session so paginated listings do not produce one warning per page. The raw cacheable overloads keep their synchronous argument validation and route results through a shared ValidateCacheableResultAsync helper that calls the new ValidateCacheableResult seam on McpClient. The seam is a no-op by default and overridden by McpClientImpl to perform the conformance check. Issue modelcontextprotocol#1646 (optional client-side caching subsystem) was reviewed and closed as not planned; no caching subsystem is added here.
Contributor
Author
|
Heads-up on a small expected conflict with #1610 (default draft protocol support: sessionless + handshake-less). What overlaps:
How to resolve when the two land together:
Forward-looking (not part of this PR): #1610 adds |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to the SEP-2549 caching hints work in #1623, addressing two of its tracked follow-up issues.
Fixes #1645 (docs)
Tightens the
<remarks>on the auto-paginating list overloads (ListToolsAsync,ListPromptsAsync,ListResourcesAsync,ListResourceTemplatesAsync) to state plainly that:ttlMs/cacheScopeare intrinsically per page and are not surfaced on the flattened convenience overloads.No behavioral change for #1645, docs only.
Fixes #1650 (conformance warning)
Logs a warning (never throws) when a server that negotiated the draft protocol version returns a cacheable result without the now required
ttlMs/cacheScopefields. Covered methods:tools/list,prompts/list,resources/list,resources/templates/list,resources/read.Details:
ValidateCacheableResultAsynchelper that calls a newValidateCacheableResultseam onMcpClient.McpClientImplto perform the check, gated on the negotiated draft protocol version (so older servers never warn).Note on #1646
The optional client-side caching subsystem (#1646) was reviewed and closed as not planned. No caching subsystem is added here; if demand materializes we can add it later on top of the lower-level overloads.
Tests
New
CacheableResultWarningTests(10 tests, using an in-memoryPipe+StreamClientTransportso raw responses can omit the fields, which the real SDK server never does):Verification
dotnet buildclean (0 warnings / 0 errors).#if !NET472.