discover method
Answers the server/discover request with the protocol versions this
server serves, the capabilities initialize registered, and the
instructions it was given.
Only the revisions from ProtocolVersion.v2026_07_28 on are advertised:
earlier ones are negotiated with the legacy initialize handshake, which
this request replaced. A transport that serves a narrower set than this
package implements rejects the versions it does not serve itself, the way
handleStreamableHttpRequest does with its own version header check.
The request-scoped dispatcher fills in the rest of what the schema
requires, resultType and the caching hints, and stamps the server's
identity into _meta. This only answers the fields that are specific to
discovery. Override it to advertise something else.
The request has no parameters of its own beyond the _meta envelope, and
the per-request context that envelope carries reaches a server through
initialize rather than through here, so it is optional the way the other
requests without parameters are.
https://modelcontextprotocol.io/specification/2026-07-28/server/discover
Implementation
FutureOr<DiscoverResult> discover([DiscoverRequest? request]) =>
DiscoverResult(
supportedVersions: [
for (final version in ProtocolVersion.values)
if (version.methodIsValid(DiscoverRequest.methodName))
version.versionString,
],
capabilities: advertisedCapabilities,
instructions: instructions,
);