|
1 | 1 | """`mcp.server.caching`: `CacheHint` validation, per-field fills, and the |
2 | 2 | `cache_hints` constructor map reaching the wire on both server tiers.""" |
3 | 3 |
|
4 | | -from types import UnionType |
5 | | -from typing import Any, cast, get_args |
| 4 | +from typing import Any, cast |
6 | 5 |
|
7 | 6 | import pytest |
8 | 7 | from inline_snapshot import snapshot |
9 | 8 | from mcp_types import ( |
10 | | - CacheableResult, |
11 | 9 | ListResourcesResult, |
12 | 10 | ListToolsResult, |
13 | 11 | PaginatedRequestParams, |
14 | 12 | Resource, |
15 | 13 | Tool, |
16 | | - methods, |
17 | 14 | ) |
18 | 15 |
|
19 | 16 | from mcp import Client |
20 | 17 | from mcp.server import CacheHint, MCPServer, Server, ServerRequestContext |
21 | | -from mcp.server.caching import CACHEABLE_METHODS, apply_cache_hint |
| 18 | +from mcp.server.caching import apply_cache_hint |
22 | 19 |
|
23 | 20 | pytestmark = pytest.mark.anyio |
24 | 21 |
|
25 | 22 |
|
26 | | -def test_cacheable_methods_match_the_result_models() -> None: |
27 | | - """Spec-mandated set (SEP-2549): `CACHEABLE_METHODS` mirrors exactly the |
28 | | - methods whose monolith result models mix in `CacheableResult` - if the |
29 | | - schema gains or loses a cacheable result, this weld breaks.""" |
30 | | - derived: set[str] = set() |
31 | | - for method, model in methods.MONOLITH_RESULTS.items(): |
32 | | - arms = get_args(model) if isinstance(model, UnionType) else (model,) |
33 | | - if any(isinstance(arm, type) and issubclass(arm, CacheableResult) for arm in arms): |
34 | | - derived.add(method) |
35 | | - assert CACHEABLE_METHODS == derived |
36 | | - |
37 | | - |
38 | 23 | def test_cache_hint_defaults_match_the_conservative_model_defaults() -> None: |
39 | 24 | """SDK-defined: an unconfigured hint fills the same values the result models |
40 | 25 | already default to - immediately stale, not shared - so stamping it is |
|
0 commit comments