| 1: | <?php |
| 2: | |
| 3: | declare(strict_types=1); |
| 4: | |
| 5: | /** |
| 6: | * This file is part of the Nexus MCP SDK package. |
| 7: | * |
| 8: | * (c) 2026 John Paul E. Balandan, CPA <paulbalandan@gmail.com> |
| 9: | * |
| 10: | * For the full copyright and license information, please view |
| 11: | * the LICENSE file that was distributed with this source code. |
| 12: | */ |
| 13: | |
| 14: | namespace Nexus\Mcp\Core\Schema; |
| 15: | |
| 16: | use Nexus\Assert\Assert; |
| 17: | |
| 18: | /** |
| 19: | * A revision of the Model Context Protocol identified by its release date. |
| 20: | * |
| 21: | * @see https://modelcontextprotocol.io/specification/2026-07-28/basic/versioning#protocol-version-negotiation |
| 22: | */ |
| 23: | final readonly class ProtocolVersion |
| 24: | { |
| 25: | public const string LATEST_VERSION = '2026-07-28'; |
| 26: | |
| 27: | /** |
| 28: | * Superseded spec revisions, newest first. |
| 29: | */ |
| 30: | public const array PREVIOUS_VERSIONS = [ |
| 31: | '2025-11-25', |
| 32: | '2025-06-18', |
| 33: | '2025-03-26', |
| 34: | '2024-11-05', |
| 35: | ]; |
| 36: | |
| 37: | /** |
| 38: | * The protocol revisions this server implements, newest first. |
| 39: | */ |
| 40: | public const array SUPPORTED_VERSIONS = [self::LATEST_VERSION]; |
| 41: | |
| 42: | /** |
| 43: | * @var non-empty-string |
| 44: | */ |
| 45: | public string $version; |
| 46: | |
| 47: | public function __construct(string $version) |
| 48: | { |
| 49: | // The spec types this as a plain string, and a version the server does not recognise must reach |
| 50: | // the support check so it is answered with -32022 rather than rejected as malformed params. |
| 51: | Assert::that($version)->isNonEmptyString('"protocolVersion" must be a non-empty string.'); |
| 52: | |
| 53: | $this->version = $version; |
| 54: | } |
| 55: | } |
| 56: |