Skip to content

serveSSE fails to propagate headers and session ID #660

Description

@naji247

Describe the bug
The SSE transport in MCP does not pass session ID, authentication info, or request headers through to MCP message handlers, while the StreamableHTTP transport does. This creates feature parity issues between the two transport methods and prevents SSE-based MCP connections from accessing critical request context like authentication tokens and custom headers.

To Reproduce
Steps to reproduce the behavior:

  1. Set up an MCP Agent using SSE transport with McpAgent.serveSSE() or McpAgent.serve() with transport: "sse"
  2. Add authentication middleware that sets request.auth with user credentials
  3. Connect to the agent using an MCP client (e.g., MCP Inspector) over SSE
  4. Observe that MessageExtraInfo received in the MCP server handlers is undefined, lacking:
    - Session ID
    - Authentication info (authInfo)
    - Request headers (requestInfo.headers)

Expected behavior
SSE transport should have feature parity with StreamableHTTP transport. When MCP messages are received over SSE, the handlers should receive:

  • Session ID for tracking connections across requests
  • Authentication info from middleware (if present)
  • Request headers for accessing custom headers, authorization tokens, etc.

This data should be passed via the MessageExtraInfo parameter, matching the StreamableHTTP implementation.

Screenshots
EXPECTED (via StreamableHTTP)

Image

ACTUAL (via SSE)

Image

Version:
agents@0.2.23

Additional context
This issue is important to our team at MCPcat as we're helping Cloudflare Agents users maintain session tracking via Durable objects in Cloudflare workers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions