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

オープン
#1,092 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@arimu1 がすでに取り組んでいます。

2026年8月1日 から。

  • #1129 @arimu1 による — オープン

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
静か
技術スタック
go

調査の方向性

まず server.go、非エクスポートの Server.discover 実装、serverMethodInfos、そして dispatch の特殊ケースを読んで、server/discover がどのように組み立てられているかを理解してください。ServerOptions と ServerSession の API を比較し、既存の discover の動作を維持しながら、テナント固有の結果とセッションのイントロスペクションを可能にする、サポート対象のカスタマイズまたはホスト呼び出しの拡張ポイントを 1 つ定義して検証してください。

索引モデルが issue の本文から書いたものです。

説明

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 —

主要言語
Go
スター
5.4k
フォーク
623
平均マージ
22時間 10分
マージ済み PR(30日)
30

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

modelcontextprotocol/go-sdk のほかの issue

modelcontextprotocol/go-sdk の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。