server/discover is not customizable or host-invokable (no DiscoverHandler option / session Discover API)

Đang mở
#1,092 1 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

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

Từ ngày 1/8/2026.

  • #1129 của @arimu1 — đang mở

Đá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
backend-api-design

Hướng nghiên cứu

Bắt đầu bằng cách đọc server.go, phần triển khai không export của Server.discover, serverMethodInfos và trường hợp đặc biệt trong dispatch để hiểu server/discover được tập hợp như thế nào. So sánh các API ServerOptions và ServerSession, sau đó xác định và kiểm thử một điểm mở rộng được hỗ trợ cho việc tùy chỉnh hoặc gọi từ host, sao cho vẫn giữ nguyên hành vi discover hiện có đồng thời cho phép trả về kết quả riêng theo tenant và introspection phiên.

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

Mô tả

P3
Use case

We run a multi-tenant MCP gateway (Arcade) on v1.7.0-pre.2, stateless StreamableHTTP, one logical server per gateway. Two things we cannot do today:

  1. Customize the server/discover payload beyond what ServerOptions statics allow (e.g. tenant-specific supportedVersions, augmenting the result at build time rather than post-hoc).
  2. Invoke discover from the host (for health/introspection: "what would this session advertise right now?") without synthesizing an HTTP request against ourselves.
Current behavior
  • server/discover is handled entirely internally: unexported Server.discover (server.go), registered in serverMethodInfos, special-cased in dispatch. It builds DiscoverResult from s.capabilities(), s.impl, s.opts.Instructions, and the session version list.
  • No ServerOptions field touches discover (checked the full option set on pre.2), and there is no exported Discover(...) on Server/ServerSession.
Why middleware isn't a workaround

Receiving middleware can type-assert *DiscoverResult and mutate it post-hoc, keyed off the method string — reactive, fragile, and only for inbound requests. It cannot let the host invoke discover, and it runs strictly after the SDK computed the payload.

Per the maintainers' stance in #565 (keep the API small), the concrete need here is not "export the internals" but a supported seam:

Proposal (either would do)
type ServerOptions struct {
    // DiscoverHandler, if non-nil, can augment the server/discover
    // response after the SDK builds it.
    DiscoverHandler func(context.Context, *DiscoverRequest, *DiscoverResult) (*DiscoverResult, error)
}

or an exported, host-callable form:

func (ss *ServerSession) Discover(ctx context.Context) (*DiscoverResult, error)

Related but distinct: #1034 fixed a discover/initialize parity bug; this asks for a customization/introspection seam.

🐕 Written by Kyoto, an AI agent, on Pascal's behalf —

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.