set_sampling_callback and set_elicitation_callback don't update live session
Description
set_sampling_callback and set_elicitation_callback on Client only update _session_kwargs without touching the live ClientSession. This means changes made while connected won't take effect until reconnect — the same bug that set_roots had before #3714.
Context
Identified during review of #3714 (fix for #326). The set_roots fix was scoped to roots only; these sibling methods need the same treatment.
Proposed approach
Apply the same pattern used in set_roots: after updating _session_kwargs, check is_connected() and mutate the live session's private callback attribute (_sampling_callback / _elicitation_callback). Since these methods are not called from __init__, they don't need the hasattr(self, '_session_state') guard.
Note: _sampling_callback and _elicitation_callback are private attributes on the upstream MCP SDK's ClientSession — same fragility caveat as _list_roots_callback.
Files
src/fastmcp/client/client.py—set_sampling_callback,set_elicitation_callback- Tests needed for both methods
Source: PrefectHQ/fastmcp