Skip to content

Negotiate modern and legacy protocol eras - #304

Open
pushpak1300 wants to merge 13 commits into
mainfrom
mcp/v1/era-aware-client
Open

Negotiate modern and legacy protocol eras#304
pushpak1300 wants to merge 13 commits into
mainfrom
mcp/v1/era-aware-client

Conversation

@pushpak1300

@pushpak1300 pushpak1300 commented Aug 10, 2026

Copy link
Copy Markdown
Member

Currently the client always starts with the legacy initialize handshake. That locks it to the pre-2026-07-28 protocol flow and prevents it from talking to modern servers that expect discovery and per-request protocol metadata.

Existing calls do not need to choose a protocol version:

$client = Mcp::client('everything');

$client->tools();

$client->protocolVersion();
$client->discoverResult();
$client->initializeResult();

The client probes the latest protocol first, then falls back to the legacy handshake only when the response indicates that the endpoint does not support the modern flow. If the server reports its supported versions, the client selects the newest mutual version instead of guessing.

A version can also be pinned when the server is already known:

Mcp::client('everything')
    ->withProtocolVersion(ProtocolVersion::V2025_11_25)
    ->tools();

The HTTP transport keeps session handling in the legacy flow and sends protocol-version headers in the modern flow. Method and name header mirroring is intentionally left for a follow-up so it can be modeled at the method boundary instead of in the transport.

Warning

Custom client transports no longer implement setProtocolVersion(string). Protocol-aware transports should implement UsesProtocol::useProtocol(ProtocolVersion), while protocol-agnostic transports need no protocol method. ProtocolVersion::supported() is replaced by serverSupported(), with clientSupported() and initializeSupported() exposing the other support lists.

Tests cover negotiation, fallback behavior, version pinning, reconnects, protocol metadata, HTTP headers, and legacy sessions.

@pushpak1300
pushpak1300 force-pushed the mcp/v1/era-aware-client branch 2 times, most recently from 32feedd to 6666436 Compare August 10, 2026 16:07
@taylorotwell
taylorotwell force-pushed the mcp/v1/era-aware-client branch from 6666436 to 27a8ec6 Compare August 10, 2026 17:19
@pushpak1300
pushpak1300 force-pushed the mcp/v1/era-aware-client branch from 27a8ec6 to f3e4f47 Compare August 11, 2026 04:56
@pushpak1300
pushpak1300 force-pushed the mcp/v1/era-aware-client branch 2 times, most recently from ef53fb5 to f424d10 Compare August 11, 2026 07:32
@pushpak1300
pushpak1300 force-pushed the mcp/v1/era-aware-client branch from f424d10 to 30fd800 Compare August 11, 2026 07:56
@pushpak1300
pushpak1300 force-pushed the mcp/v1/era-aware-client branch 2 times, most recently from c0d6503 to e6d7a0c Compare August 11, 2026 14:01
@pushpak1300
pushpak1300 force-pushed the mcp/v1/era-aware-client branch from e6d7a0c to 7bd22a4 Compare August 11, 2026 14:12
@taylorotwell
taylorotwell force-pushed the mcp/v1/era-aware-client branch from 7bd22a4 to 3f13af6 Compare August 11, 2026 14:30
Base automatically changed from mcp/v1/apps to main August 11, 2026 14:30
@taylorotwell
taylorotwell force-pushed the mcp/v1/era-aware-client branch from 3f13af6 to 1ec7a5f Compare August 11, 2026 14:30
@pushpak1300 pushpak1300 changed the title Teach the client both protocol eras Negotiate modern and legacy protocol eras Aug 11, 2026
@pushpak1300
pushpak1300 marked this pull request as ready for review August 12, 2026 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant