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/draft/basic/lifecycle#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: Assert::that($version)
50: ->isNonEmptyString('"protocolVersion" must be a non-empty string.')
51: ->matchesRegularExpression('/\A\d{4}-\d{2}-\d{2}\z/', '"protocolVersion" must be in the format "YYYY-MM-DD".')
52: ;
53:
54: $this->version = $version;
55: }
56: }
57: