Skip to content

fix: emit cache hints from handler macros - #1120

Merged
DaleSeo merged 1 commit into
mainfrom
fix/1114-handler-cache-hints
Aug 5, 2026
Merged

fix: emit cache hints from handler macros#1120
DaleSeo merged 1 commit into
mainfrom
fix/1114-handler-cache-hints

Conversation

@DaleSeo

@DaleSeo DaleSeo commented Aug 3, 2026

Copy link
Copy Markdown
Member

Fixes #1114

Motivation and Context

Strict clients using protocol version 2026-07-28 reject list responses that don't include ttlMs and cacheScope. 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-generated tools/list and prompts/list responses 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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

@github-actions github-actions Bot added T-test Testing related changes T-macros Macro changes labels Aug 3, 2026
@DaleSeo
DaleSeo marked this pull request as ready for review August 3, 2026 19:31
@DaleSeo
DaleSeo requested a review from a team as a code owner August 3, 2026 19:31
@DaleSeo DaleSeo self-assigned this Aug 5, 2026
@DaleSeo
DaleSeo merged commit 07bcda2 into main Aug 5, 2026
22 checks passed
@DaleSeo
DaleSeo deleted the fix/1114-handler-cache-hints branch August 5, 2026 14:20
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`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-macros Macro changes T-test Testing related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

#[tool_handler] and #[prompt_handler] emit ttl_ms: None / cache_scope: None, which a 2026-07-28 client rejects

2 participants