modelcontextprotocol / modelcontextprotocol/python-sdk

`ClientConfig` has inconsistent naming: `message_handler` should be `message_callback`

Open
#2,588 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement needs decision P3 v2
Dominant language
Python
Stars
24.3k
Forks
4k
Avg merge
1d 1h
Merged PRs (30d)
31

Description

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_handlermessage_callback consistently across all three sites:

File Change
src/mcp/client/client.py message_handlermessage_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_handlermessage_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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.