Negotiates legacy MCP revisions during the initialize handshake.
This compatibility API covers the initialize-based revisions from
2024-11-05 through 2025-11-25. MCP 2026-07-28 is wire-incompatible: clients
select it with :protocol_mode and establish it through server/discover,
not through this module. Consequently, latest_version/0 means the newest
legacy revision rather than the latest upstream MCP revision.
Summary
Functions
Build a legacy initialize-result wrapper using the canonical capability registry.
Get the newest legacy revision supported by initialize negotiation.
Negotiates a legacy protocol revision from the client's offered versions.
Checks whether a revision is supported by legacy initialize negotiation.
Returns the initialize-compatible legacy revisions.
Functions
Build a legacy initialize-result wrapper using the canonical capability registry.
This function is retained as a 1.x compatibility shim. Initialization is
handled by ExMCP's server dispatchers; code that only needs the capability
map should use ExMCP.Server.Capabilities.build_capabilities/2.
@spec latest_version() :: String.t()
Get the newest legacy revision supported by initialize negotiation.
Modern MCP 2026-07-28 uses server/discover and is selected with a protocol
mode instead of this legacy negotiator.
Negotiates a legacy protocol revision from the client's offered versions.
Takes the client's supported versions and returns the best matching version that both client and server support.
Parameters
client_versions- List of protocol versions supported by the client
Returns
{:ok, version}- Successfully negotiated version{:error, :no_compatible_version}- No compatible version found
Examples
iex> ExMCP.Protocol.VersionNegotiator.negotiate(["2025-11-25", "2025-06-18"])
{:ok, "2025-11-25"}
iex> ExMCP.Protocol.VersionNegotiator.negotiate(["2024-01-01"])
{:error, :no_compatible_version}
Checks whether a revision is supported by legacy initialize negotiation.
@spec supported_versions() :: [String.t()]
Returns the initialize-compatible legacy revisions.
Use ExMCP.Types.V20260728 and a modern-enabled :protocol_mode for MCP
2026-07-28 rather than expecting it in this list.