8000 fix(server/mcp): include ttlMs and cacheScope in server/discover result by arijitbakshi15-stack · Pull Request #4428 · googleapis/mcp-toolbox · GitHub
[go: up one dir, main page]

Skip to content

fix(server/mcp): include ttlMs and cacheScope in server/discover result - #4428

Open
arijitbakshi15-stack wants to merge 1 commit into
googleapis:mainfrom
arijitbakshi15-stack:fix/discover-cacheable-result
Open

arijitbakshi15-stack wants to merge 1 commit into
googleapis:mainfrom
arijitbakshi15-stack:fix/discover-cacheable-result

Conversation

@arijitbakshi15-stack
Copy link
Copy Markdown
Contributor

Description

Starting with v1.8.0, Toolbox serves MCP 2026-07-28 by default. In that spec, DiscoverResult extends CacheableResult, so ttlMs and cacheScope are required. Toolbox already includes them on tools/list, prompts/list, resources/list, resources/templates/list, resources/read, groups/get, skills/list and skills/get, but not on server/discover.

Impact: clients built on rmcp 3.4+ (such as Goose CLI 1.52+) send server/discover first. They can't parse the incomplete result, so they abort the handshake without falling back to initialize:

Toolbox v1.7.0 and earlier weren't affected: they rejected 2026-07-28 with -32022, so clients fell back to initialize. The bug is still present in v1.16.0.

Fix: 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. ProcessMethod now passes the group into serverDiscoverHandler. 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-28 server/discover expectation now includes ttlMs and cacheScope.
  • New TestStdioSessionServerDiscover: replays Goose's opening server/discover → tools/list through a real stdio session.

Manual verification

  • Goose 1.57.0 (the version in stdio mode works with Goose up to and including v1.7.0 only #4371): with v1.15.0 and v1.16.0 the extension fails to start over both stdio and HTTP. With this change, Goose completes the handshake and lists the tools.
  • Responses from a built binary validate against the official 2026-07-28 JSON schema.
  • A named group configured with ttlMs: 60000 and cacheScope: private returns those values from both server/discover and tools/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

Thank you for opening a Pull Request! Before submitting your PR, there are a
few things you can do to make sure it goes smoothly:

  • Make sure you reviewed
    CONTRIBUTING.md
  • Make sure to open an issue as a
    bug/issue
    before writing your code! That way we can discuss the change, evaluate
    designs, and agree on the general idea
  • Ensure you have manually reviewed the entire diff before requesting a
    review
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)
  • Make sure to add ! if this involve a breaking change

🛠️ Fixes #4371
🛠️ Fixes #4338

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
@gemini-code-assist gemini-code-assist Bot left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants

0