Conversation
| } | ||
|
|
||
| #[tokio::test] | ||
| async fn list_resources_should_get_default_cache_hints_for_2026_07_28() { |
There was a problem hiding this comment.
Thanks for this fix - I just ran into this issue with atuin mcp (https://github.com/atuinsh/atuin) in claude, where the two sides negotiate 2026-07-28 protocol version and then the connection fails because of missing ttlMs / cacheScope.
Change looks good overall, only comment is that atuin has a list_tools() that doesn't use the #[tool_handler] macro, I wonder if it's worth also adding test coverage for manual list_tools() and list_prompts() handlers too?
There was a problem hiding this comment.
Thanks for testing it, @rolandd! Makes sense. I added a test server with hand-written list_tools() and list_prompts() handlers.
| if !sep_2322_supported { | ||
| // legacy wire shape without `resultType: "complete"`; newer | ||
| // peers require caching hints (SEP-2549) on cacheable results. | ||
| if sep_2322_supported { |
There was a problem hiding this comment.
Shouldn't this be driven by something referencing sep 2549?
https://modelcontextprotocol.io/seps/2549-TTL-for-list-results
Also, how do we feel generally about referencing certain sep numbers in the code? I know this one was pre-existing but it feels like we should consider modeling things based on a more generic description of the relevant functionality vs the SEP ids. I can see benefits to either approach. What do you think?
There was a problem hiding this comment.
@alexhancock Good catch. All three gates depend on the peer's protocol version, not on a specific SEP. I renamed the check to is_2026_07_28_or_later.
I'd keep the SEP number in doc comments, but not in function or variable names. Happy to clean up the existing ones in a follow-up. :)
Motivation and Context
Protocol version
2026-07-28requiresttlMsandcacheScopeon every completetools/list,prompts/list,resources/list,resources/templates/list, andresources/readresult. The caching utility describes this requirement. The#[tool_handler]and#[prompt_handler]macros already add these hints, but there is no equivalent macro for resources. As a result, hand-written resource handlers, which often build results with..Default::default()orReadResourceResult::new, send results without the required hints. Strict clients reject them.The fix follows the existing
strip_result_type_for_legacy_peerstep. A newServerResult::fill_missing_cache_hintsruns for modern peers in the same place whereresultTypeis stripped for legacy peers. Missing hints default to the most conservative values,ttlMs: 0(immediately stale) andcacheScope: "private", matchingDiscoverResult::new. Any hints set by the handler, including the macros'publicscope, are left unchanged. Legacy peers are unaffected.Before responding to a peer using protocol version
2026-07-28or newer, the server handler now fills in any missing SEP-2549 caching hints (ttlMsandcacheScope) on cacheable results.How Has This Been Tested?
Added tests
Breaking Changes
None.
Types of changes
Checklist