feat(mcp): let clients cache tools/list for an hour and share it across users - #245
Open
mattzcarey wants to merge 1 commit into
Open
mattzcarey wants to merge 1 commit into
mattzcarey wants to merge 1 commit into
Conversation
…ss users MCP 2026-07-28 requires ttlMs and cacheScope on tools/list. We sent the SDK default, ttlMs: 0 and private, so no client ever reused a list. Since #235 every caller gets the same tool metadata, which is what public means, so tools/list now returns ttlMs: 3600000 and cacheScope: 'public' on both tool surfaces. An hour matches how long a warm isolate keeps the spec artifacts; the lists change only on deploy or the daily spec refresh. Clients key cached lists by server name@version, as the TypeScript SDK client does, and both surfaces reported cloudflare-api. With the hint alone, a client sharing one cache store across /mcp and /mcp?codemode=false served the Code Mode tools to the endpoint surface. The endpoint surface now reports cloudflare-api-endpoints. Metrics still report cloudflare-api for both.
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.
MCP 2026-07-28 requires
ttlMsandcacheScopeontools/list(caching). We sent the SDK default,ttlMs: 0andprivate, so no client ever reused a list. Since #235 every caller gets the same tool metadata, and the spec callspublic"appropriate for lists of tools ... when they are identical for all users."tools/listreturnsttlMs: 3600000, cacheScope: 'public'on both tool surfaces. The lists change only on deploy or the daily spec refresh, and a warm isolate already keeps the spec artifacts for an hour.?codemode=falsenow reportsserverInfo.name: 'cloudflare-api-endpoints'instead ofcloudflare-api. Clients key cached lists byname@version(the TypeScript SDK client does), and both surfaces reported the same identity with different tools. With the hint alone, a client sharing one cache store across both URLs served the Code Mode tools to?codemode=false. Metrics still reportcloudflare-apifor both.server/discoverkeeps the SDK default. 2025-era responses carry no cache fields, so clients on that protocol see no change. ChatGPT's published-app snapshot is unaffected either way.tests/non-codemode.test.tsalready enforce that, and AGENTS.md now says why.The new client test runs three TypeScript SDK clients on one
InMemoryResponseCacheStore, the way a gateway would:Touches the same
createServerblock as #244; the two merge cleanly.