Skip to content

Default missing MCP-Protocol-Version to 2025-03-26 in StreamableHTTPTransport#392

Open
koic wants to merge 1 commit into
modelcontextprotocol:mainfrom
koic:fallback_missing_protocol_version_in_streamable_http_transport
Open

Default missing MCP-Protocol-Version to 2025-03-26 in StreamableHTTPTransport#392
koic wants to merge 1 commit into
modelcontextprotocol:mainfrom
koic:fallback_missing_protocol_version_in_streamable_http_transport

Conversation

@koic
Copy link
Copy Markdown
Member

@koic koic commented Jun 7, 2026

Motivation and Context

MCP 2025-11-25 (basic/transports#protocol-version-header) specifies:

For backwards compatibility, if the server does not receive an
MCP-Protocol-Version header, and has no other way to identify the
version - for example, by relying on the protocol version negotiated
during initialization - the server SHOULD assume protocol version 2025-03-26.

PR #347 satisfied only the MUST requirement (reject invalid/unsupported values with 400). The SHOULD requirement to default a missing header to 2025-03-26 was deferred to this follow-up.

This change brings the Ruby SDK in line with the Python SDK (src/mcp/server/streamable_http.py), which falls back to DEFAULT_NEGOTIATED_VERSION and then revalidates against the supported list.

Behavior

A new constant MCP::Configuration::DEFAULT_NEGOTIATED_PROTOCOL_VERSION holds "2025-03-26". validate_protocol_version_header now substitutes this value when the MCP-Protocol-Version header is absent, then runs the same supported-version check. Because "2025-03-26" is currently in SUPPORTED_STABLE_PROTOCOL_VERSIONS, missing headers continue to pass through as before. Once "2025-03-26" is dropped from the supported list in a future change, missing headers will start returning 400 with a message naming the defaulted value.

How Has This Been Tested?

Existing test POST request without MCP-Protocol-Version header succeeds continues to pass (observable behavior unchanged today). Added a focused regression test that stubs the supported-version list to exclude "2025-03-26" and verifies that a header-less request is rejected with the defaulted value reported in the error message; this exercises the fallback branch directly.

Breaking Changes

None today. The fallback is future-proofing: when "2025-03-26" is eventually dropped, header-less requests will start returning 400. That is the intended spec-driven behavior.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

…PTransport

## Motivation and Context

MCP 2025-11-25 (basic/transports#protocol-version-header) specifies:

> For backwards compatibility, if the server does not receive an
> `MCP-Protocol-Version` header, and has no other way to identify the
> version - for example, by relying on the protocol version negotiated
> during initialization - the server SHOULD assume protocol version `2025-03-26`.

PR modelcontextprotocol#347 satisfied only the MUST requirement (reject invalid/unsupported
values with 400). The SHOULD requirement to default a missing header to
`2025-03-26` was deferred to this follow-up.

This change brings the Ruby SDK in line with the Python SDK
(`src/mcp/server/streamable_http.py`), which falls back to
`DEFAULT_NEGOTIATED_VERSION` and then revalidates against the supported list.

## Behavior

A new constant `MCP::Configuration::DEFAULT_NEGOTIATED_PROTOCOL_VERSION`
holds `"2025-03-26"`. `validate_protocol_version_header` now substitutes
this value when the `MCP-Protocol-Version` header is absent, then runs
the same supported-version check. Because `"2025-03-26"` is currently in
`SUPPORTED_STABLE_PROTOCOL_VERSIONS`, missing headers continue to pass
through as before. Once `"2025-03-26"` is dropped from the supported
list in a future change, missing headers will start returning 400 with
a message naming the defaulted value.

## How Has This Been Tested?

Existing test `POST request without MCP-Protocol-Version header
succeeds` continues to pass (observable behavior unchanged today).
Added a focused regression test that stubs the supported-version list
to exclude `"2025-03-26"` and verifies that a header-less request is
rejected with the defaulted value reported in the error message;
this exercises the fallback branch directly.

## Breaking Changes

None today. The fallback is future-proofing: when `"2025-03-26"` is
eventually dropped, header-less requests will start returning 400.
That is the intended spec-driven behavior.
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