fix: emit cache hints from handler macros - #1120
Merged
Merged
Conversation
alexhancock
approved these changes
Aug 5, 2026
This was referenced Aug 5, 2026
Merged
Merged
coseto6125
added a commit
to coseto6125/egent-code-plexus
that referenced
this pull request
Aug 7, 2026
* fix(mcp): emit the cache hints 2026-07-28 requires on tools/list `ListToolsResult::with_all_items` leaves `ttlMs` and `cacheScope` unset, and rmcp only strips `resultType` for legacy peers — nothing fills these in. Protocol 2026-07-28 made both fields required on `tools/list` (SEP-2549 `CacheableResult`), so a strict client rejects the response before it reaches a tool call: the TypeScript SDK 2.0.0 client fails with `Invalid result for tools/list: expected number, received undefined` at `ttlMs`. `server/discover` succeeds first, which makes it read like a client bug until you look at the wire. rmcp 3.1.1 fixes this for servers built from `#[tool_handler]` (modelcontextprotocol/rust-sdk#1120). This server hand-writes `ServerHandler::list_tools`, so the macro fix does not reach it. The tool set is derived from the clap tree once in `EcpMcpServer::new` and never changes while the process lives, so the hint is public and any TTL up to the session length would be honest; 60s matches rmcp's own conformance server and keeps a session that outlives an `ecp` upgrade from calling a subcommand the new binary dropped. Peers older than 2026-07-28 predate both fields and keep the legacy wire shape, matching how the macro gates them. Alongside: `cargo update` (rkyv 0.8.18, rmcp 3.1.1, clap 4.6.6, blake3 1.8.6 and their transitive set), and `taiki-e/install-action` to v2.85.10 — tool-manifest updates only, cargo-nextest 0.9.143 among them. * fix(mcp): keep serve_stdio above the test module clippy::items_after_test_module (-D warnings in CI) rejects any item declared after a `#[cfg(test)] mod`.
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.
Fixes #1114
Motivation and Context
Strict clients using protocol version 2026-07-28 reject list responses that don't include
ttlMsandcacheScope. As a result, servers using the documented handler macros don't work until the first tool or prompt call. This PR fixes that by adding immediately stale public cache hints for modern clients while continuing to omit them for legacy clients. With this fix macro-generatedtools/listandprompts/listresponses include the cache hints required by clients that negotiate protocol version 2026-07-28. Older clients still receive the same legacy wire format.How Has This Been Tested?
Added integration tests
Breaking Changes
None. The new fields are emitted only where the negotiated protocol requires them.
Types of changes
Checklist