*/ class DiscoverResult implements ResultInterface { /** * @param list $supportedVersions every revision this server can answer */ public function __construct( public readonly array $supportedVersions, public readonly ServerCapabilities $capabilities, public readonly ?string $instructions = null, ) { if ([] === $this->supportedVersions) { throw new InvalidArgumentException('A DiscoverResult must advertise at least one supported version.'); } } /** * `resultType`, caching hints and serverInfo are wire vocabulary, stamped * by {@see \Mcp\Server\Wire\Rev2026Codec} rather than modelled here. * * @return array{ * supportedVersions: list, * capabilities: ServerCapabilities, * instructions?: string, * } */ public function jsonSerialize(): array { $data = [ 'supportedVersions' => array_values(array_map( static fn (ProtocolVersion $version): string => $version->value, $this->supportedVersions, )), 'capabilities' => $this->capabilities, ]; if (null !== $this->instructions) { $data['instructions'] = $this->instructions; } return $data; } }