Skip to content

Send MCP-Protocol-Version header in Streamable HTTP client transport #500

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

halter73
Copy link
Contributor

@halter73 halter73 commented Jun 10, 2025

modelcontextprotocol/modelcontextprotocol#548 updated the MCP specification to require the following:

If using HTTP, the client MUST include the MCP-Protocol-Version: <protocol-version> HTTP header during any subsequent requests to the MCP
server, allowing the MCP server to respond based on the MCP protocol version.

The protocol version sent by the client SHOULD be the one negotiated during initialization.

If the server receives a request with a missing, invalid, or unsupported
MCP-Protocol-VERSION, it MUST respond with 400 Bad Request.

This updates the client Streamable HTTP transport to send this header.

Replaces #493

@halter73 halter73 requested a review from stephentoub June 10, 2025 15:08
{
if (sessionId is not null)
{
headers.Add("mcp-session-id", sessionId);
}

if (protocolVersion is not null)
{
headers.Add("mcp-protocol-version", protocolVersion);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is all lower case correct? I understand header names are case insensitive, but the spec clearly spells it out as MCP-Protocol-Version. Shouldn't we use the same casing?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that we should be writing out the header in a casing that is consistent with the specification.

{
if (!StringValues.IsNullOrEmpty(context.Request.Headers["mcp-session-id"]))
{
protocolVersionHeaderValues.Add(context.Request.Headers["mcp-protocol-version"]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider factoring this and other header names into a constant for DRY purposes.

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.

3 participants