Skip to content

Cacheable, stably-ordered tools/list (#108) - #124

Merged
TGoodhew merged 1 commit into
mainfrom
issue-108-cacheable-tools-list
Jul 31, 2026
Merged

Cacheable, stably-ordered tools/list (#108)#124
TGoodhew merged 1 commit into
mainfrom
issue-108-cacheable-tools-list

Conversation

@TGoodhew

Copy link
Copy Markdown
Owner

Closes #108.

SEP-2549 adds ttlMs and cacheScope to the list-shaped results so a client can cache instead of poll. tools/list is the only one of the five we expose, and the one worth caching — 29 tool descriptors is a lot of prompt to re-send.

Change

  • tools/list returns ttlMs (one hour) and cacheScope: "private", reusing the CacheableResult helper from MCP 2026-07-28: implement the required server/discover RPC #105.
  • Sent only to a client on the revision that defines them, exactly like resultType: an older client implements no caching, gains nothing from the fields, and might validate strictly against a schema without them.
  • Both values are safe because the registry is built once at start-up and cannot change without a restart — which is precisely what the listChanged: false we already advertise says. A test asserts those two statements agree, so if tools ever become dynamic both have to change together.

Ordering

Already correct — the registry walks its registration order — but untested and undocumented, so the SHOULD held by accident. Now pinned: one test on a synthetic registry proves the order is registration order and not sorted, another pins the real server's list. If a tool is added or moved, a test says so and whoever moved it has to mean it: every client's cached copy and every prompt cache turns over when it does.

Verification

  • 6 new tests — hints present on the new revision, absent on 2025-06-18 and with no _meta; two calls byte-identical; registration order preserved; the real registry's order pinned with no duplicate names; cache hints consistent with listChanged: false.
  • Full suite green: 378 GpibMcp + 113 Hpgl, 0 failures (Release|x86) — was 372 + 113.

README: "Protocol revisions" covers the caching and the ordering guarantee.

SEP-2549 adds ttlMs and cacheScope to the list-shaped results so a client can
cache instead of poll. tools/list is the only one of the five we expose, and it
is the one worth caching: 29 tool descriptors is a lot of prompt to re-send.

Both values are safe here because the registry is built once at start-up and
cannot change without a restart - which is exactly what the listChanged:false we
already advertise says. An hour, and "private" (see CacheableResult from #105 for
why: single user by construction, and the one case where an intermediary could
cache at all is the tunnelled HTTP transport, where you would not want it to).

Sent only to a client on the revision that defines them, like resultType: an
older client implements no caching, so it gains nothing from the fields and
might validate strictly against a schema without them.

Ordering was already right - the registry walks its registration order - but
untested and undocumented, so the SHOULD held by accident. Now there is a
regression guard on the real registry: if a tool moves, a test says so, because
every clients cached copy and prompt cache turns over when it does.

6 tests.
@TGoodhew
TGoodhew merged commit 9fc72bc into main Jul 31, 2026
1 check passed
@TGoodhew
TGoodhew deleted the issue-108-cacheable-tools-list branch July 31, 2026 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP 2026-07-28: tools/list must return ttlMs/cacheScope and a deterministic order

1 participant