-
Notifications
You must be signed in to change notification settings - Fork 0
Send MCP-Protocol-Version header in Streamable HTTP client transport #11
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
Conversation
Co-authored-by: halter73 <[email protected]>
Co-authored-by: halter73 <[email protected]>
halter73
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add an integration test to MapMcpStreamableHttpTests?
…p transport Co-authored-by: halter73 <[email protected]>
Added integration test Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
halter73
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of making any changes to McpClient, parse the InitializeResult the same place we set the _mcpSessionId, and set the _negotiatedProtocolVersion.
Moved protocol version setting logic from McpClient to StreamableHttpClientSessionTransport as requested. The protocol version is now parsed from the InitializeResult in the same block where Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
halter73
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like your last commit failed to push. Can you try again and instead of making any changes to McpClient, parse the InitializeResult the same place we set the _mcpSessionId, and set the _negotiatedProtocolVersion. Try to undo as many of the other changes as possible. Also "mcp-protocol-version" should be lower case like "mcp-session-id" when adding the header.
Feal free to start by deleting StreamableHttpProtocolVersionHeaderTests.cs since we'll have to delete SetNegotiatedProtocolVersion. The StreamableHttpClient_SendsMcpProtocolVersionHeader_AfterInitialization should be sufficient.
…sport layer and use lowercase header Co-authored-by: halter73 <[email protected]>
Refactored as requested - moved protocol version parsing to StreamableHttpClientSessionTransport where _mcpSessionId is set, removed SetNegotiatedProtocolVersion method, reverted McpClient changes, changed header to lowercase "mcp-protocol-version", and deleted StreamableHttpProtocolVersionHeaderTests.cs. Integration test updated accordingly. Committed in 37e0c52. |
Implements the MCP specification requirement for HTTP clients to send the
MCP-Protocol-Versionheader with all requests after initialization.Changes Made
Core Implementation
StreamableHttpClientSessionTransport: Added support for storing and sending the negotiated protocol version
_negotiatedProtocolVersionfield to store the version negotiated during initializationSetNegotiatedProtocolVersion()method to set the version after successful handshakeCopyAdditionalHeaders()to include theMCP-Protocol-Versionheader when availableMcpClient: Enhanced initialization flow to set the protocol version on HTTP transports
SetNegotiatedProtocolVersion()with the server's responseStreamableHttpClientSessionTransportandAutoDetectingClientSessionTransportcasesTesting
Specification Compliance
Per the MCP specification update:
This implementation:
MCP-Protocol-Version: 2024-11-05initializerequest (appropriate behavior)Example
After this change, HTTP requests from the client will include:
Fixes #10.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.