fix(client): clamp inbound ttlMs only for cacheable methods
Closed
EN
3d ago+44+44+01234567890123456789-3-3-0123456789
Fixes #3866
Summary
- Guard
_clamp_inbound_ttl(raw)inClientSession.send_request(src/mcp/client/session.py) withif method in _methods.CACHEABLE_METHODS:so non-cacheable extension results (e.g.,tools/callclaimed results) retain their rawttlMsvalues for their own model validation. - Cacheable methods (such as
resources/read,tools/list, andserver/discover) continue to normalize negativettlMs. - Add
test_non_cacheable_claimed_result_preserves_negative_and_fractional_ttl_msintests/client/test_session_claims.py.
Verification
.venv\Scripts\python.exe -m pytest tests/client/test_session_claims.py tests/client/test_client_caching.py -q --basetemp=.pytest-tmp->91 passed.venv\Scripts\ruff.exe check src/mcp/client/session.py tests/client/test_session_claims.py->All checks passed!.venv\Scripts\pyright.exe tests/client/test_session_claims.py->0 errors, 0 warnings, 0 informations