modelcontextprotocol / modelcontextprotocol/python-sdk

ServerSession methods (create_message, elicit_form) don't expose progress_callback parameter

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

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

enhancement needs decision P2
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

Mô tả

Summary

The ServerSession high-level methods for sending requests to clients (create_message, elicit_form) don't expose the progress_callback parameter, even though the underlying BaseSession.send_request() fully supports it.

This means servers can't easily receive progress notifications from clients during sampling or elicitation requests.

Current Behavior

# ServerSession.elicit_form() - no progress_callback parameter
async def elicit_form(
    self,
    message: str,
    requestedSchema: types.ElicitRequestedSchema,
    related_request_id: types.RequestId | None = None,
) -> types.ElicitResult:
    return await self.send_request(...)  # progress_callback not passed through

# ServerSession.create_message() - same issue
async def create_message(
    self,
    messages: list[types.SamplingMessage],
    *,
    max_tokens: int,
    # ... other params ...
    related_request_id: types.RequestId | None = None,
) -> types.CreateMessageResult:
    return await self.send_request(...)  # progress_callback not passed through

Expected Behavior

# Should be able to pass progress_callback
result = await server_session.elicit_form(
    message="Please provide your details",
    requestedSchema=schema,
    progress_callback=lambda progress, total, msg: print(f"Progress: {progress}/{total} - {msg}")
)

result = await server_session.create_message(
    messages=messages,
    max_tokens=1000,
    progress_callback=lambda progress, total, msg: print(f"Sampling progress: {progress}/{total}")
)

Context

  • The MCP spec supports bidirectional progress notifications - clients CAN send notifications/progress back to servers during request handling
  • BaseSession.send_request() already supports progress_callback parameter
  • ClientSession.call_tool() exposes progress_callback for the client→server direction
  • The TypeScript SDK exposes this via RequestOptions.onprogress in both createMessage() and elicitInput()
  • Tests in tests/shared/test_progress_notifications.py demonstrate the bidirectional flow works

Suggested Fix

Add progress_callback: ProgressFnT | None = None parameter to:

  • ServerSession.create_message()
  • ServerSession.elicit_form()
  • Any other ServerSession methods that send requests to clients

And pass it through to send_request().

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.

Hướng nghiên cứu

Bắt đầu với các điểm vào ServerSession.create_message() và elicit_form(), sau đó so sánh các lời gọi của chúng với BaseSession.send_request() và cách xử lý callback tiến trình hiện có. Xem lại tests/shared/test_progress_notifications.py, và coi công việc hoàn tất khi cả hai phương thức đều chấp nhận và chuyển tiếp progress_callback, với phần bao phủ cho luồng hai chiều.

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

Đánh giá

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

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.