mcp: requests to the client aren't checked against the capabilities it declared

Đang mở
#1,303 1 bình luận 1 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@po-et đang làm issue này rồi.

Từ ngày 9/10/2026.

  • #1363 của @po-et — đang mở

Đánh giá

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

Hướng nghiên cứu

Start with ServerSession.Elicit and compare its capability check with CreateMessageWithTools, CreateMessage, and ListRoots. Then inspect the client handlers for sampling and elicitation, including form versus URL mode; done means unsupported requests are rejected before sending or invoking handlers, with the specified errors such as -32602.

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

Mô tả

The spec has a rule on each side of some requests a server sends to a client. From client/sampling (2025-11-25), servers MUST NOT send tool-enabled sampling requests to a client that hasn't declared sampling.tools, and the schema says the client MUST return an error for such a request. From client/elicitation, "Error Handling": a client MUST answer a request for a mode it didn't declare with -32602.

Only ServerSession.Elicit checks the client's capabilities today. CreateMessageWithTools sends tools to any client, and a client with only a CreateMessageHandler, which declares sampling without tools, drops tools and toolChoice and answers anyway, so the server gets an answer produced without the tools it asked for. CreateMessage and ListRoots don't check sampling and roots either. On the client side, a url-mode elicitation reaches the handler of a client that declared only form mode, which is the default.

This came up in the review of #699 (https://github.com/modelcontextprotocol/go-sdk/pull/699#discussion_r2810556445), with the suggestion to cover all capability-gated server→client requests consistently. I have a change that does that: those server methods return an error before sending, as Elicit does, and the client answers -32602 before calling its handler. I can send it as a PR if that's the direction you want.

Ngôn ngữ chính
Go
Star
5.4k
Fork
623
Merge trung bình
22 giờ 10 phút
Pull request đã merge (30 ngày)
30

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

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/go-sdk

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

Issue tương tự

Thêm issue về Go

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.