Skip to content

Commit 22176ef

Browse files
committed
Limit the version registry to released protocol versions
KNOWN_PROTOCOL_VERSIONS now lists only released revisions (2024-11-05 through 2025-11-25). Drop DRAFT_PROTOCOL_VERSION, STATEFUL_PROTOCOL_VERSIONS, and is_stateful_protocol_version: nothing uses them yet, and with no post-2025-11-25 revision in the registry the stateful classification is vacuous. They can return alongside the code that needs them.
1 parent 2374c99 commit 22176ef

3 files changed

Lines changed: 7 additions & 53 deletions

File tree

src/mcp/shared/version.py

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Protocol-version registry and comparison/classification helpers.
1+
"""Protocol-version registry and comparison helpers.
22
33
Date-string protocol revisions happen to sort lexicographically, but versions
44
are an enumerated set, not an ordered scalar: future identifiers are not
@@ -16,34 +16,12 @@
1616
"2025-03-26",
1717
"2025-06-18",
1818
"2025-11-25",
19-
"2026-07-28", # draft: recognized for ordering/classification, NOT negotiable
2019
)
21-
"""Every protocol revision this SDK knows about, oldest to newest."""
22-
23-
DRAFT_PROTOCOL_VERSION: Final[str] = "2026-07-28"
24-
"""The in-progress spec revision.
25-
26-
Recognized by the helpers in this module but absent from
27-
SUPPORTED_PROTOCOL_VERSIONS until the SDK actually implements it.
28-
"""
20+
"""Every released protocol revision, oldest to newest."""
2921

3022
SUPPORTED_PROTOCOL_VERSIONS: list[str] = ["2024-11-05", "2025-03-26", "2025-06-18", LATEST_PROTOCOL_VERSION]
3123
"""Protocol revisions this SDK can negotiate."""
3224

33-
STATEFUL_PROTOCOL_VERSIONS: Final[frozenset[str]] = frozenset({"2024-11-05", "2025-03-26", "2025-06-18", "2025-11-25"})
34-
"""Revisions that negotiate via the initialize handshake.
35-
36-
Closed by design: every revision after 2025-11-25 is stateless and negotiates
37-
per-request, never via initialize. Hardcoded - do not derive from
38-
SUPPORTED_PROTOCOL_VERSIONS. (Matches typescript-sdk's
39-
STATEFUL_PROTOCOL_VERSIONS / isStatefulProtocolVersion.)
40-
"""
41-
42-
43-
def is_stateful_protocol_version(version: str) -> bool:
44-
"""Return True if `version` negotiates via the initialize handshake."""
45-
return version in STATEFUL_PROTOCOL_VERSIONS
46-
4725

4826
def is_version_at_least(version: str, minimum: str) -> bool:
4927
"""Return True if `version` is a known revision at least as new as `minimum`.

tests/client/test_auth.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,6 @@ async def test_resource_param_included_with_protected_resource_metadata(self, oa
825825
("2025-03-26", False),
826826
("2025-06-18", True),
827827
("2025-11-25", True),
828-
("2026-07-28", True),
829828
# Unrecognized strings gate conservatively, even ones sorting after 2025-06-18.
830829
("zzz", False),
831830
("9999-99-99", False),

tests/shared/test_version.py

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,10 @@
33
import pytest
44

55
from mcp.shared.version import (
6-
DRAFT_PROTOCOL_VERSION,
76
KNOWN_PROTOCOL_VERSIONS,
8-
STATEFUL_PROTOCOL_VERSIONS,
97
SUPPORTED_PROTOCOL_VERSIONS,
10-
is_stateful_protocol_version,
118
is_version_at_least,
129
)
13-
from mcp.types import LATEST_PROTOCOL_VERSION
1410

1511

1612
@pytest.mark.parametrize(
@@ -21,10 +17,10 @@
2117
("2024-11-05", "2024-11-05", True),
2218
# above
2319
("2025-11-25", "2025-06-18", True),
24-
("2026-07-28", "2024-11-05", True),
20+
("2025-06-18", "2024-11-05", True),
2521
# below
2622
("2025-06-18", "2025-11-25", False),
27-
("2024-11-05", "2026-07-28", False),
23+
("2024-11-05", "2025-03-26", False),
2824
],
2925
)
3026
def test_is_version_at_least_ordering(version: str, minimum: str, expected: bool) -> None:
@@ -52,28 +48,9 @@ def test_is_version_at_least_matches_lexicographic_for_known_versions(version: s
5248
assert is_version_at_least(version, minimum) is (version >= minimum)
5349

5450

55-
def test_draft_version_is_known_but_not_negotiable_and_not_stateful() -> None:
56-
assert DRAFT_PROTOCOL_VERSION in KNOWN_PROTOCOL_VERSIONS
57-
assert DRAFT_PROTOCOL_VERSION not in SUPPORTED_PROTOCOL_VERSIONS
58-
assert not is_stateful_protocol_version(DRAFT_PROTOCOL_VERSION)
59-
60-
61-
def test_draft_version_is_at_least_every_released_version() -> None:
62-
for released in SUPPORTED_PROTOCOL_VERSIONS:
63-
assert is_version_at_least(DRAFT_PROTOCOL_VERSION, released)
64-
65-
66-
def test_every_supported_version_is_stateful() -> None:
67-
for version in SUPPORTED_PROTOCOL_VERSIONS:
68-
assert is_stateful_protocol_version(version)
69-
70-
71-
def test_supported_versions_are_a_strict_subset_of_known() -> None:
72-
assert set(SUPPORTED_PROTOCOL_VERSIONS) < set(KNOWN_PROTOCOL_VERSIONS)
73-
74-
75-
def test_latest_version_is_stateful() -> None:
76-
assert LATEST_PROTOCOL_VERSION in STATEFUL_PROTOCOL_VERSIONS
51+
def test_supported_versions_are_known() -> None:
52+
"""Every negotiable revision must be in the ordering registry."""
53+
assert set(SUPPORTED_PROTOCOL_VERSIONS) <= set(KNOWN_PROTOCOL_VERSIONS)
7754

7855

7956
def test_known_versions_are_strictly_ordered() -> None:

0 commit comments

Comments
 (0)