modelcontextprotocol / modelcontextprotocol/python-sdk

More control over stderr in stdio client

Đang mở Phù hợp với người mới
#1,806 1 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 P3
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ả

Description

Currently, a TextIO object (defaulting to sys.stderr) must be set for errlog when creating a new stdio client session.
https://github.com/modelcontextprotocol/python-sdk/blob/2aa1ad2a69b56bc6cef089c9b4c3ecccbbc8e84d/src/mcp/client/stdio/__init__.py#L106
However, the underlying calls to Python's native Popen and anyio.create_process both support subprocess.DEVNULL: int = -3 for stderr, which allows the stream to be ignored.
By updating the type hint, we can easily support int for errlog. This change would benefit downstream projects and resolve issues for CLI users. Furthermore, I believe ignoring errlog is a better default than piping them into stderr, as the current behaviour can create unexpected side-effects that are difficult to trace.

References

Related Issues:
https://github.com/modelcontextprotocol/python-sdk/issues/156
https://github.com/langchain-ai/langchain-mcp-adapters/issues/72

Documentation:
https://docs.python.org/3/library/subprocess.html#subprocess.Popen
https://anyio.readthedocs.io/en/stable/api.html#anyio.open_process

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 trong src/mcp/client/stdio/init.py, tại định nghĩa errlog được issue tham chiếu, sau đó so sánh các giá trị stderr được chấp nhận trong Python subprocess.Popen và anyio.create_process. Xác nhận cách xử lý dự kiến của subprocess.DEVNULL và cập nhật client API tương ứng; công việc được xem là hoàn tất khi các caller có thể truyền giá trị số nguyên mà không gặp vấn đề về kiểu hoặc khi chạy, đồng thời hành vi stderr hiện có vẫn được bao phủ.

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
Tính năng
Độ 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
68/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.