Initial Checks
Description
ClientConfig exposes five user-facing callback fields, but four of them use the *_callback suffix while one uses *_handler:
# src/mcp/client/client.py
sampling_callback: SamplingFnT | None = None
list_roots_callback: ListRootsFnT | None = None
logging_callback: LoggingFnT | None = None
elicitation_callback: ElicitationFnT | None = None
message_handler: MessageHandlerFnT | None = None # ← inconsistent
The same inconsistency is present in ClientSession.__init__ and ServerConnectionParams:
# src/mcp/client/session.py
def __init__(self, ..., message_handler: MessageHandlerFnT | None = None, ...)
# src/mcp/client/session_group.py
class ServerConnectionParams:
message_handler: MessageHandlerFnT | None = None
A TODO comment in the codebase already flags this:
# TODO(Marcelo): Why do we have both "callback" and "handler"?
message_handler: MessageHandlerFnT | None = None
Proposed Fix
Rename message_handler → message_callback consistently across all three sites:
| File |
Change |
src/mcp/client/client.py |
message_handler → message_callback (field + forwarding call) |
src/mcp/client/session.py |
message_handler parameter → message_callback; internal _message_handler → _message_callback |
src/mcp/client/session_group.py |
ServerConnectionParams.message_handler → message_callback + forwarding call |
src/mcp/client/__main__.py |
local variable + keyword arg rename |
Since this is the v2 rewrite on main, a breaking rename is appropriate and there is no need for a deprecation shim.
I'd like to take this on if you're open to a fix.
Python & MCP Python SDK
Python 3.13
Reproduced on: main @ 161834d (2026-05-13)
Initial Checks
Description
ClientConfigexposes five user-facing callback fields, but four of them use the*_callbacksuffix while one uses*_handler:The same inconsistency is present in
ClientSession.__init__andServerConnectionParams:A TODO comment in the codebase already flags this:
Proposed Fix
Rename
message_handler→message_callbackconsistently across all three sites:src/mcp/client/client.pymessage_handler→message_callback(field + forwarding call)src/mcp/client/session.pymessage_handlerparameter →message_callback; internal_message_handler→_message_callbacksrc/mcp/client/session_group.pyServerConnectionParams.message_handler→message_callback+ forwarding callsrc/mcp/client/__main__.pySince this is the v2 rewrite on
main, a breaking rename is appropriate and there is no need for a deprecation shim.I'd like to take this on if you're open to a fix.
Python & MCP Python SDK