Skip to content

fix: treat empty cacheScope as omitted - #1241

Open
ismail-rt wants to merge 1 commit into
modelcontextprotocol:mainfrom
ismail-rt:tolerate-empty-cache-scope
Open

fix: treat empty cacheScope as omitted#1241
ismail-rt wants to merge 1 commit into
modelcontextprotocol:mainfrom
ismail-rt:tolerate-empty-cache-scope

Conversation

@ismail-rt

@ismail-rt ismail-rt commented Sep 2, 2026

Copy link
Copy Markdown

Fixes #1242.

Motivation and Context

SEP-2549 allows cacheScope to be "public", "private", or omitted. Some hosted servers send "". The deserializer treats that as an unknown variant, so tools/list (and resources/read) fail to parse as the typed result.

ServerResult is untagged. When ListToolsResult rejects the payload, it falls through to CustomResult. The tools are on the wire and then disappear.

Negative ttlMs is already clamped to 0. Empty cacheScope now maps to None. Unknown or whitespace values still error.

How Has This Been Tested?

  • empty_cache_scope_is_treated_as_omitted in crates/rmcp/tests/test_cache_hints.rs
  • unknown_cache_scope_still_errors ("shared" and " " still fail)
  • empty_cache_scope_list_tools_result_does_not_fall_through in crates/rmcp/tests/test_deserialization.rs

Breaking Changes

None. Empty cacheScope previously failed to decode. It is now treated as omitted.

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

@ismail-rt
ismail-rt requested a review from a team as a code owner September 2, 2026 19:20
@github-actions github-actions Bot added T-test Testing related changes T-core Core library changes labels Sep 2, 2026
@ismail-rt ismail-rt changed the title Treat empty MCP cacheScope as omitted fix: treat empty cacheScope as omitted Sep 2, 2026
@ismail-rt
ismail-rt force-pushed the tolerate-empty-cache-scope branch from a4bed59 to 2ccc934 Compare September 2, 2026 20:17
An empty cacheScope string is invalid under SEP-2549, but some hosted
servers emit it. Rejecting the whole tools/list payload currently drops
every tool from an otherwise valid response.
@ismail-rt
ismail-rt force-pushed the tolerate-empty-cache-scope branch from 2ccc934 to 611dc34 Compare September 2, 2026 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-core Core library changes T-test Testing related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Empty cacheScope on tools/list drops every tool

1 participant