Skip to content

feat(types): add SEP-2549 cache hints to result models - #2824

Closed
MicroYui wants to merge 1 commit into
modelcontextprotocol:mainfrom
MicroYui:feat/sep-2549-cacheable-results
Closed

feat(types): add SEP-2549 cache hints to result models#2824
MicroYui wants to merge 1 commit into
modelcontextprotocol:mainfrom
MicroYui:feat/sep-2549-cacheable-results

Conversation

@MicroYui

Copy link
Copy Markdown

Summary

Implements SEP-2549 cache hints for Python SDK protocol result models.

Adds ttlMs and cacheScope support to:

  • ListToolsResult
  • ListPromptsResult
  • ListResourcesResult
  • ListResourceTemplatesResult
  • ReadResourceResult

The SDK defaults to ttlMs=0 and cacheScope="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 MCPServer cache configuration APIs.

Fixes#2802.

Tests

  • uv run --frozen pytest tests/test_types.py -q
  • uv run --frozen pytest tests/server/lowlevel/test_server_listing.py tests/interaction/lowlevel/test_wire.py tests/server/mcpserver/test_server.py -q
  • uv run --frozen pytest tests/interaction/test_coverage.py tests/interaction/lowlevel/test_wire.py -q
  • uv run --frozen ruff format --check .
  • uv run --frozen ruff check .
  • uv run --frozen pyright --pythonplatform Linux

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.
@MicroYui
MicroYuiforce-pushed the feat/sep-2549-cacheable-results branch from 8c3934f to c8cc2ebCompareJune 9, 2026 16:21
@maxisbey

Copy link
Copy Markdown
Contributor

Thanks for the PR. This has since landed via #2849. I'm closing this out as part of a backlog cleanup now that v2 is out. Feel free to reopen if this is still relevant.

AI Disclaimer

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement SEP-2549: TTL for List Results

2 participants

@MicroYui@maxisbey