mcp: client skips elicitation schema defaults when the handler returns no content, and validates before applying them

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

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

@chaholl đang làm issue này rồi.

Từ ngày 4/11/2026.

  • #1496 của @chaholl — đ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
78/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ệ
go
Lĩnh vực
api

Hướng nghiên cứu

Start in mcp/client.go at the elicit form branch described in the issue, then inspect the elicitation-sep1034-client-defaults conformance scenario. Verify the accept path when Content is nil and the ordering of default application and validation. Done means an accepted empty response receives schema defaults before validation and the scenario no longer fails its five cases.

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

Mô tả

Describe the bug

The client applies requestedSchema defaults (SEP-1034) only under res.Action == "accept" && schema != nil && res.Content != nil, and only after resolved.Validate(res.Content) (mcp/client.go, the elicit form branch; present in v1.8.0 and on main at 53effc0). That causes two problems:

  1. No content means no defaults. A handler that accepts what was offered returns &ElicitResult{Action: "accept"}, so Content is nil and no defaults are applied. The server receives an accept with no values.
  2. Validation runs first. A required property that has a default, which the user left alone, fails validation before the default could fill it: required: missing properties: [...].

The conformance suite's elicitation-sep1034-client-defaults scenario (2025-11-25 requirements) fails 0/5 with a client whose handler returns {Action: "accept"}.

To Reproduce

schema := map[string]any{"type": "object", "required": []string{"color"},
    "properties": map[string]any{"color": map[string]any{"type": "string", "default": "blue"}}}
// server: res, _ := req.Session.Elicit(ctx, &mcp.ElicitParams{Message: "color?", RequestedSchema: schema})
// client:
opts := &mcp.ClientOptions{ElicitationHandler: func(context.Context, *mcp.ElicitRequest) (*mcp.ElicitResult, error) {
    return &mcp.ElicitResult{Action: "accept"}, nil
}}
// server sees res.Content == nil; expected map[color:blue]

Expected behavior

For an accept, start from an empty map when Content is nil, apply defaults, then validate. Happy to send a PR.

Additional context

Found while moving PromptKit's MCP client onto go-sdk v1.8.0 (AltairaLabs/PromptKit#2141). We currently apply defaults in our own handler wrapper: applyElicitDefaults.

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.