Public hooks for pre-validation request inspection, extending server/discover and initialize _meta, and wrapping handler results

Đang mở
#3,253 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ó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
api, backend-api-design

Hướng nghiên cứu

Start by reading the public Server and toNodeHandler APIs, then inspect the private Server.connect, _ondiscover, _oninitialize, and _wrapHandler points named in the issue, along with the proposed interceptor in #2507. The issue requests maintainers to agree on a direction across four API seams, so completion criteria depend on that decision and would likely involve coordinated API and documentation changes.

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

Mô tả

v2

@lushly-dev/afd-server (pinned @modelcontextprotocol/server ~2.4.0, @modelcontextprotocol/node ~2.1.2) patches a few private points of Server and depends on one internal shape. We keep guard tests on each, but we'd like to stop depending on private API. Each item below is a request for a public seam.

  1. Pre-validation request inspection. We wrap Server.connect and replace transport.onmessage to read tools/call arguments exactly as the transport delivered them. Schema validation rebuilds arguments and drops a member named __proto__, so a security-relevant key nested under one disappears instead of being refusable. Ask: a documented hook (for example ServerOptions.onRawRequest(message, extra)) that runs before schema validation and can answer with an error.
  2. Contributing _meta to server/discover and InitializeResult. We wrap the private Server._ondiscover() and Server._oninitialize() to add a _meta entry that advertises our server's contract. Ask: a public way to contribute _meta (or capability extensions) to both results.
  3. Wrapping handler results. We patch Server._wrapHandler so tools/call can return an MCP Tasks CreateTaskResult. Ask: a public result-wrapping or task hook. The interceptor proposed in #2507 might cover this if it can replace the result, but because it runs after input validation, it doesn't cover item 1.
  4. The request shape toNodeHandler reads. We pass toNodeHandler a re-created request whose body has already been read. Ask: document which IncomingMessage properties toNodeHandler reads, or accept a pre-read body.

We're happy to contribute a PR for any of these if the maintainers agree on a direction.

Ngôn ngữ chính
TypeScript
Star
13.8k
Fork
2.5k
Merge trung bình
6 ngày 23 giờ
Pull request đã merge (30 ngày)
2

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

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

Issue tương tự

Thêm issue về TypeScript

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.