modelcontextprotocol / modelcontextprotocol/python-sdk
`ClientConfig` has inconsistent naming: `message_handler` should be `message_callback`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 24.3k
- Forks
- 4k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 31
Description
Initial Checks
- I confirm that I'm using the latest version of MCP Python SDK
- I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this issue
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)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the callback definitions and forwarding calls in src/mcp/client/client.py, then follow the related parameter and internal attribute in src/mcp/client/session.py. Check ServerConnectionParams in src/mcp/client/session_group.py and the local variable and keyword argument in src/mcp/client/main.py. Done means all four sites consistently use message_callback, with no remaining message_handler naming in this flow.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 73/100