Repository navigation
fix(server/mcp): include ttlMs and cacheScope in server/discover result - #4428
Open
arijitbakshi15-stack wants to merge 1 commit into
Open
arijitbakshi15-stack wants to merge 1 commit into
arijitbakshi15-stack wants to merge 1 commit into
Conversation
The 2026-07-28 schema defines DiscoverResult as a CacheableResult, so ttlMs and cacheScope are required. Toolbox omitted both from the server/discover result, while every other cacheable result includes them. Clients built on rmcp 3.4+ (such as Goose) send server/discover first, fail to parse the incomplete result, and abort the handshake without falling back to initialize, over both stdio and HTTP. Embed CacheableResult in DiscoverResult and fill it from the group the client is connected to (g.GetTTLMs() / g.GetCacheScope()), the same way tools/list does. Fixes googleapis#4371 Fixes googleapis#4338
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the server/discover handler for the v20260728 MCP protocol version to include the spec-required ttlMs and cacheScope fields in its response. These cache hints are retrieved from the client's connected group, matching the behavior of other cacheable results like tools/list. The changes also update the corresponding unit and integration tests, including a new test TestStdioSessionServerDiscover to ensure compatibility with clients like Goose that require these fields during the handshake. I have no feedback to provide.
This branch has not been deployed
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.
Description
Starting with v1.8.0, Toolbox serves MCP
2026-07-28by default. In that spec,DiscoverResultextendsCacheableResult, sottlMsandcacheScopeare required. Toolbox already includes them ontools/list,prompts/list,resources/list,resources/templates/list,resources/read,groups/get,skills/listandskills/get, but not onserver/discover.Impact: clients built on rmcp 3.4+ (such as Goose CLI 1.52+) send
server/discoverfirst. They can't parse the incomplete result, so they abort the handshake without falling back toinitialize:Failed to start extension 'databases-toolbox' (process quit before initialization …)failed to initialize MCP client: expect initialized result, but received: Some(CallToolResult(…))Toolbox v1.7.0 and earlier weren't affected: they rejected
2026-07-28with-32022, so clients fell back toinitialize. The bug is still present in v1.16.0.Fix: embed
CacheableResultinDiscoverResultand fill it from the group the client is connected to (g.GetTTLMs()/g.GetCacheScope()), the same waytools/listdoes.ProcessMethodnow passes the group intoserverDiscoverHandler. Groups without custom values fall back to the existing defaults (300000 /public).Tests
TestServerDiscoverHandler: asserts the default group's values (300000 /public) and a custom group's values (60000 /private).TestMcpEndpoint: the 2026-07-28server/discoverexpectation now includesttlMsandcacheScope.TestStdioSessionServerDiscover: replays Goose's openingserver/discover→tools/listthrough a real stdio session.Manual verification
ttlMs: 60000andcacheScope: privatereturns those values from bothserver/discoverandtools/list.Security: no query building, credentials, file paths or auth checks are touched. The change only adds two response fields sourced from existing group config.
Related: #4363 (closed as a duplicate of #4338).
PR Checklist
CONTRIBUTING.md
bug/issue
before writing your code! That way we can discuss the change, evaluate
designs, and agree on the general idea
review
!if this involve a breaking change🛠️ Fixes #4371
🛠️ Fixes #4338