feat(types): add SEP-2549 cache hints to result models#2824
Open
MicroYui wants to merge 1 commit into
Open
Conversation
Add cache hint fields to list and resource-read protocol result models with conservative defaults of ttlMs=0 and cacheScope=public. Cover default serialization, explicit hints, validation, low-level wire behavior, high-level MCPServer defaults, and migration notes without adding new high-level server configuration API.
8c3934f to
c8cc2eb
Compare
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.
Summary
Implements SEP-2549 cache hints for Python SDK protocol result models.
Adds
ttlMsandcacheScopesupport to:ListToolsResultListPromptsResultListResourcesResultListResourceTemplatesResultReadResourceResultThe SDK defaults to
ttlMs=0andcacheScope="public"so existing Python code constructing these models remains usable while serialized responses include the new cache hint fields. Older server responses that omit the fields also parse with those defaults.This PR does not implement client-side caching, cache invalidation logic, or new high-level
MCPServercache configuration APIs.Fixes #2802.
Tests
uv run --frozen pytest tests/test_types.py -quv run --frozen pytest tests/server/lowlevel/test_server_listing.py tests/interaction/lowlevel/test_wire.py tests/server/mcpserver/test_server.py -quv run --frozen pytest tests/interaction/test_coverage.py tests/interaction/lowlevel/test_wire.py -quv run --frozen ruff format --check .uv run --frozen ruff check .uv run --frozen pyright --pythonplatform Linux