pub fn lifecycle_response(
req: &Request,
server_info: &Value,
capabilities: &Value,
) -> Option<Response>Expand description
Answer the three lifecycle methods every MCP server must handle, in ONE place,
version-aware across both eras — the server-side mirror of the client’s version
negotiation. Returns Some(response) for initialize / server/discover /
ping, or None if req.method is a domain method the Handler must route.
initialize(legacy handshake): negotiate the protocol version — echo the peer’s requested version when it’s supported, else fall back to our latest legacyPROTOCOL_VERSION.server/discover(modern, stateless): advertise the fullSUPPORTED_PROTOCOL_VERSIONSlist + capabilities in one call, so a modern client needn’t fall back to the legacy handshake. This is what makes the embedder a dual-era server.ping: an empty result.
server_info is the {name, version} object and capabilities the advertised
capability object; both are echoed verbatim into the two lifecycle replies. When
the crate gains support for a new protocol version, both replies pick it up here
without the embedder changing anything.