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

未关闭
#1,092 1 条评论 0 个 reaction 已指派 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 行为的同时支持租户特定的结果和会话内省。

由索引模型根据 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 分钟
30 天内合并 PR
30

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

modelcontextprotocol/go-sdk 的其他 Issue

查看 modelcontextprotocol/go-sdk 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。