modelcontextprotocol / modelcontextprotocol/go-sdk
server/discover is not customizable or host-invokable (no DiscoverHandler option / session Discover API)
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 5.1k
- Forks
- 543
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 37
Description
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:
- Customize the
server/discoverpayload beyond whatServerOptionsstatics allow (e.g. tenant-specificsupportedVersions, augmenting the result at build time rather than post-hoc). - 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/discoveris handled entirely internally: unexportedServer.discover(server.go), registered inserverMethodInfos, special-cased in dispatch. It buildsDiscoverResultfroms.capabilities(),s.impl,s.opts.Instructions, and the session version list.- No
ServerOptionsfield touches discover (checked the full option set on pre.2), and there is no exportedDiscover(...)onServer/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 —
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading server.go, the unexported Server.discover implementation, serverMethodInfos, and the dispatch special case to understand how server/discover is assembled. Compare the ServerOptions and ServerSession APIs, then define and validate one supported customization or host-invocation seam that preserves the existing discover behavior while enabling tenant-specific results and session introspection.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100