Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Preserve native JSON types when passing arguments to tool handlers

Đang mở
#587 0 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
52/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
php
Lĩnh vực
backend-api-design

Hướng nghiên cứu

Start by tracing how validated arguments are passed to tool handlers and review the related decoding work in issue #586. Check the tests covering nested JSON values and handler arguments to identify where objects are converted to associative arrays. Done means handlers receive recursive stdClass, array, and scalar values as specified, with tests confirming the behavior.

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

Mô tả

enhancement
Is your feature request related to a problem? Please describe.

The SDK currently converts JSON objects into associative PHP arrays before passing them to tool handlers. This forces a specific PHP representation on consumers instead of preserving the original JSON types.

Describe the solution you'd like

Pass validated arguments to tool handlers without implicit type conversion:

  • JSON objects → stdClass
  • JSON arrays → array
  • Scalar values → their corresponding PHP types

This should apply recursively to nested structures.

For consumers preferring associative arrays, the SDK could provide an optional, documented recursive stdClass-to-array converter. Its use should be explicitly controlled by the consumer.

Describe alternatives you've considered

A configurable automatic conversion to associative arrays would preserve existing behavior, but introduce application-specific conversion logic and additional maintenance overhead into the SDK's argument-handling pipeline.

Existing Composer packages also provide object-to-array conversion, so consumers could handle this independently without additional SDK functionality.

Additional context

Related to #586, which addresses the loss of JSON type information during decoding and its impact on schema validation.

This request concerns the subsequent delivery of validated values to tool handlers.

The change would be breaking for consumers expecting associative arrays, but could be introduced before the SDK reaches 1.0. Preserving the current interface merely for convenience or backward compatibility would be an unfortunate design decision, as it would perpetuate unnecessary coupling to a specific PHP representation instead of establishing a clean, type-preserving API.

Ngôn ngữ chính
PHP
Star
1.6k
Fork
180
Merge trung bình
2 ngày 16 giờ
Pull request đã merge (30 ngày)
36

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

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

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

Issue tương tự

Thêm issue về PHP

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.