Negotiates compatible protocol versions between local and remote endpoints. Use this to ensure forward and backward compatibility in distributed systems.
# Source: https://github.com/sipyourdrink-ltd/bernstein | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
# Provided via justclaw.it.com; keep this notice with the code.
"""Protocol version negotiation for forward/backward compatibility.
Negotiates protocol versions between local and remote endpoints for MCP,
A2A, and ACP protocols. Finds the highest compatible version (same major,
highest minor) and reports any capabilities lost due to downgrade.
Usage::
from bernstein.core.protocols.protocol_negotiation import (
get_supported_versions,
negotiate_version,
)
local = get_supported_versions("mcp")
remote = [ProtocolVersion(protocol="mcp", major=1, minor=0, patch=0)]
result = negotiate_version(local, remote)
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key