Allow configuring additionalProperties on generated tool schemas

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

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

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

Đánh giá

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

Hướng nghiên cứu

Bắt đầu với mcp.AddTool và lệnh gọi jsonschema.ForType được mô tả trong issue, sau đó kiểm tra workaround allowAdditionalProperties() trong adcp/addtool.go. So sánh các cách tiếp cận jsonschema-go, SchemaOptions và Tool override được đề xuất, đồng thời kiểm tra các yêu cầu trong pull request adcp-go được tham chiếu. Được xem là hoàn tất khi các typed handler có thể chấp nhận các thuộc tính bổ sung có thể cấu hình mà không cần patch schema thủ công.

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

Mô tả

blocked

Problem

mcp.AddTool generates JSON schemas from Go structs via jsonschema-go, which sets additionalProperties: false on all object types. This means tool inputs that include extra fields (common in protocol envelopes) are rejected at schema validation before reaching the handler.

Use case

The Ad Context Protocol (AdCP) sends protocol-level fields like adcp_major_version alongside tool arguments. These fields are not part of any individual tool's schema but are part of the protocol envelope. The strict additionalProperties: false rejects these requests.

Current workaround

We use the low-level server.AddTool with a manually-patched schema:

schema, _ := jsonschema.ForType(reflect.TypeFor[MyInput](), &jsonschema.ForOptions{})
// Walk schema tree and set AdditionalProperties = nil on all objects
server.AddTool(&mcp.Tool{InputSchema: schema, ...}, rawHandler)

This works but loses the typed handler benefits of mcp.AddTool.

Proposed solution

Either:

  1. Add AllowAdditionalProperties bool to jsonschema.ForOptions (upstream in google/jsonschema-go)
  2. Add a SchemaOptions parameter to mcp.AddTool that allows configuring schema generation
  3. Allow overriding the generated schema on the Tool struct even when using the generic AddTool

Option 1 is the cleanest since it fixes the root cause.

Context

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.