modelcontextprotocol / modelcontextprotocol/python-sdk
`ClientConfig` has inconsistent naming: `message_handler` should be `message_callback`
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- Python
- Estrelas
- 24.3k
- Forks
- 4k
- Merge médio
- 1d 1h
- PRs com merge (30d)
- 31
Descrição
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)
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Direção de pesquisa
Comece pelas definições de callback e pelas chamadas de encaminhamento em src/mcp/client/client.py e, em seguida, acompanhe o parâmetro relacionado e o atributo interno em src/mcp/client/session.py. Verifique ServerConnectionParams em src/mcp/client/session_group.py, além da variável local e do argumento nomeado em src/mcp/client/main.py. Está concluído quando os quatro locais usarem consistentemente message_callback e não houver mais nenhuma denominação message_handler nesse fluxo.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- python
- Domínio
- backend
- Tipo de issue
- Refatoração
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Status de atividade
- Pouca atividade
- Clareza
- Claramente especificada
- Facilidade para iniciantes
- 73/100