Add Mcp-Session-Id header to HTTP MCP server requests#177
Merged
Conversation
- Modified Connection.SendRequestWithServerID to accept context parameter - Extract session ID from context in sendHTTPRequest method - Add Mcp-Session-Id header to HTTP requests when session ID is available - Updated all call sites in unified.go and server.go to pass context - All unit tests passing Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
- Created connection_test.go with 3 test cases - Tests verify session ID header is added to HTTP requests - Tests verify configured headers are preserved - Tests verify behavior without session ID - All tests passing, including agent-finished checks Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix HTTP 400 error due to missing Mcp-Session-Id header
Add Mcp-Session-Id header to HTTP MCP server requests
Jan 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
HTTP MCP servers require the
Mcp-Session-Idheader for request authentication, but the gateway was not propagating it, causing 400 errors from servers like safeinputs.Changes
SendRequestWithServerIDto acceptcontext.Contextand extract session ID from context to include asMcp-Session-Idheader in HTTP requestsSessionIDContextKeyininternal/mcppackage to avoid circular dependencies; re-exported ininternal/serverfor backward compatibilityunified.goandserver.goto pass request context through to connection layerImplementation
The session ID flows from the HTTP request → context → connection layer → HTTP backend, enabling proper authentication with HTTP MCP servers.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.