Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 12, 2026

The safeinputs HTTP backend returns "Session not found" (404) because the gateway doesn't send the required Accept header during session establishment.

Changes

  • Added Accept: application/json, text/event-stream header to HTTP MCP requests
    • initializeHTTPSession(): Ensures proper content negotiation during session creation
    • sendHTTPRequest(): Maintains consistency for all HTTP backend communication

Context

HTTP MCP backends like safeinputs require explicit content type negotiation to establish sessions. Without the Accept header, the backend cannot determine the response format, leading to session initialization failures.

// Before: Missing Accept header
httpReq.Header.Set("Content-Type", "application/json")
httpReq.Header.Set("Mcp-Session-Id", tempSessionID)

// After: Content negotiation enabled
httpReq.Header.Set("Content-Type", "application/json")
httpReq.Header.Set("Accept", "application/json, text/event-stream")
httpReq.Header.Set("Mcp-Session-Id", tempSessionID)

This aligns with the safeinputs server's documented initialization flow, which captures the session ID from response headers for subsequent authenticated requests.


💡 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.

Added 'Accept: application/json, text/event-stream' header to both
initializeHTTPSession and sendHTTPRequest methods to ensure proper
content negotiation with HTTP MCP backends like safeinputs.

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix error connecting gateway to backend safeinputs server Add Accept header for HTTP MCP backend session establishment Jan 12, 2026
Copilot AI requested a review from lpcox January 12, 2026 05:45
@lpcox lpcox marked this pull request as ready for review January 12, 2026 05:46
@lpcox lpcox merged commit b5c9ec1 into main Jan 12, 2026
3 checks passed
@lpcox lpcox deleted the copilot/fix-gateway-connection-error branch January 12, 2026 05:47
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.

2 participants