Streamable HTTP client logs a WARNING for valid 202 Accepted on session termination (DELETE)

Đang mở Phù hợp với người mới
#3,546 4 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
85/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
api, networking

Hướng nghiên cứu

Bắt đầu trong mcp/client/streamable_http.py, tại phần xử lý phản hồi DELETE để kết thúc phiên. Xác minh rằng phản hồi 202 được coi là thành công mà không có cảnh báo, trong khi 405 vẫn là trường hợp debug và các status không thành công khác vẫn phát cảnh báo; chạy bộ kiểm thử client liên quan nếu có.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

v1 v2
Problem

mcp/client/streamable_http.py treats any DELETE session-termination response outside {200, 204} as a failure and logs:

WARNING mcp.client.streamable_http: Session termination failed: 202

But 202 Accepted is a valid, spec-compliant response for an asynchronous delete — the server accepted the request and will process it later. The current code path:

if response.status_code == 405:
    logger.debug("Server does not allow session termination")
elif response.status_code not in (200, 204):
    logger.warning(f"Session termination failed: {response.status_code}")
Evidence

A long-running Hermes Agent (NousResearch) deployment with several Streamable HTTP MCP servers accumulated 72 Session termination failed: 202 warnings in ~36 hours in errors.log — pure noise from servers that correctly answer 202 to asynchronous termination. Real failures (connection errors) also surface through this same line, so the constant false positives bury the signal.

Suggested fix

Treat 2xx as success on termination, e.g.:

if response.status_code == 405:
    logger.debug("Server does not allow session termination")
elif 200 <= response.status_code < 300:
    pass  # 200/202/204 all acceptable
else:
    logger.warning(f"Session termination failed: {response.status_code}")
Environment
  • mcp Python SDK (client, streamable HTTP transport), observed on recent Hermes 0.21.x installs
  • Servers: multiple Streamable HTTP MCP endpoints (remote + local)

Happy to send a PR if the direction is agreed.

Ngôn ngữ chính
Python
Star
24.3k
Fork
4k
Merge trung bình
1 ngày 1 giờ
Pull request đã merge (30 ngày)
31

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của modelcontextprotocol/python-sdk

Tất cả issue của modelcontextprotocol/python-sdk

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.