Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3.8k
Fix unknown-method error code and add a protocol version registry#2836
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
89722dd3230c3f4468a7f3789d002374c9922176efb978383e1bf53f5dd7e4aFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,37 @@ | ||
| """Protocol-version registry and comparison helpers. | ||
| Date-string protocol revisions happen to sort lexicographically, but versions | ||
| are an enumerated set, not an ordered scalar: future identifiers are not | ||
| guaranteed to be date-shaped, and unrecognized peer strings must compare | ||
| conservatively instead of accidentally (e.g. "zzz" > "2025-11-25"). All | ||
| ordering questions go through KNOWN_PROTOCOL_VERSIONS. | ||
| """ | ||
| from typing import Final | ||
| from mcp.types import LATEST_PROTOCOL_VERSION | ||
| KNOWN_PROTOCOL_VERSIONS: Final[tuple[str, ...]] = ( | ||
| "2024-11-05", | ||
| "2025-03-26", | ||
| "2025-06-18", | ||
| "2025-11-25", | ||
| ) | ||
| """Every released protocol revision, oldest to newest.""" | ||
| SUPPORTED_PROTOCOL_VERSIONS: list[str] = ["2024-11-05", "2025-03-26", "2025-06-18", LATEST_PROTOCOL_VERSION] | ||
| """Protocol revisions this SDK can negotiate.""" | ||
| def is_version_at_least(version: str, minimum: str) -> bool: | ||
| """Return True if `version` is a known revision at least as new as `minimum`. | ||
| Unknown `version` strings return False (treat unrecognized peers | ||
| conservatively). `minimum` must be a member of KNOWN_PROTOCOL_VERSIONS; | ||
| passing anything else is programmer error and raises ValueError. | ||
| """ | ||
| if minimum not in KNOWN_PROTOCOL_VERSIONS: | ||
| raise ValueError(f"minimum must be a known protocol version, got {minimum!r}") | ||
| if version not in KNOWN_PROTOCOL_VERSIONS: | ||
| return False | ||
| return KNOWN_PROTOCOL_VERSIONS.index(version) >= KNOWN_PROTOCOL_VERSIONS.index(minimum) | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looks correct but feels brittle to tie the logic specifically to a random array constant being in the right order, but seems fine 🤷♂️ we won't change this that often I guess. | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not adding 2026-07-28 as part of this yet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep not yet