discover method
- required ProtocolVersion protocolVersion,
- required ClientCapabilities capabilities,
- Implementation? clientInfo,
- LoggingLevel? logLevel,
- ProgressToken? progressToken,
Asks the server which protocol versions and capabilities it supports, see DiscoverRequest.
Sends protocolVersion and capabilities under the two reserved
envelope keys the schema requires, plus clientInfo, logLevel and
progressToken when given.
Returns the result as it arrived, without setting this connection's ServerConnection.protocolVersion, serverCapabilities or serverInfo.
Clients should probe with this before sending any other request, see https://modelcontextprotocol.io/specification/2026-07-28/basic/transports/stdio#backward-compatibility.
A server that does not serve protocolVersion rejects this with
McpErrorCodes.unsupportedProtocolVersion. A server from before
2026-07-28 answers with an error of its own choosing, or not at all. To
handle both, use initializeAcrossVersions.
Implementation
Future<DiscoverResult> discover({
required ProtocolVersion protocolVersion,
required ClientCapabilities capabilities,
Implementation? clientInfo,
LoggingLevel? logLevel,
ProgressToken? progressToken,
}) => sendRequest(
DiscoverRequest.methodName,
DiscoverRequest(
meta: MetaWithRequestEnvelope(
protocolVersion: protocolVersion,
capabilities: capabilities,
clientInfo: clientInfo,
logLevel: logLevel,
progressToken: progressToken,
),
),
);