modelcontextprotocol / modelcontextprotocol/python-sdk

HTTP transport swallows non-2xx status codes causing client to hang

Aberta
#2,110 7 comentários 2 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

bug P1 v2
Linguagem predominante
Python
Estrelas
24.3k
Forks
4k
Merge médio
1d 1h
PRs com merge (30d)
31

Descrição

Summary

When an MCP server returns non-2xx HTTP status codes (401/403/404/5xx), the Streamable HTTP and SSE transports do not reliably propagate the error to the caller. In the Streamable HTTP transport, post_writer catches exceptions and logs them, but the caller blocks indefinitely waiting for a response on the read stream. HTTP 404 responses are also converted to JSONRPCError(code=32600), losing the original HTTP status information.

Expected Behavior

  • Non-2xx HTTP responses should be surfaced as exceptions to the caller, not silently logged
  • The original HTTP status code should be preserved and accessible
  • Auth-related errors (401/403) should be distinguishable from other failures

Current Behavior

  • post_writer in Streamable HTTP transport catches and logs errors without forwarding them through the read stream
  • Callers hang indefinitely waiting for a response
  • HTTP 404 is converted to JSONRPCError(code=32600), destroying HTTP-level context

Affected Code

  • src/mcp/client/streamable_http.py (post_writer)
  • src/mcp/client/sse.py (sse_reader)

Related

  • #1742 — broader typed error classes design

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Direção de pesquisa

Comece rastreando o tratamento de erros em src/mcp/client/streamable_http.py, especialmente em post_writer, e em src/mcp/client/sse.py, especialmente em sse_reader. Revise a issue relacionada #1742 sobre o design de erros tipados. Está concluído quando as respostas não-2xx chegam ao chamador como exceções, mantêm seu status HTTP, distinguem 401/403 e não deixam mais os chamadores esperando indefinidamente.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
python
Domínio
api, backend
Tipo de issue
Bug
Dificuldade
4/5
Tempo estimado
3-5 dias
Status de atividade
Pouca atividade
Clareza
Razoavelmente clara
Facilidade para iniciantes
48/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.