Skip to content

Conversation

DW8Reaper
Copy link

Updated the _startOrAuthSse method of StreamableHTTPClientTransport to include the requestInit parameters that were provided in the constructor.

Motivation and Context

To include credentials in HTTP calls you need to configure options like credentials and mode in the requestInit options. Currently the requestInit options are included in all the requests except the initial GET request when setting up SSE. Since this request uses Accept: text/eventsource it will not include the credentials without settings credentials: "include".

How Has This Been Tested?

Added unit tests and updated this in our application that uses the client to connect to an MCP server that is where we noticed it was not including the headers. Since I could not include the change without an official release in our system I had to test is by implementing a workaround that overrides fetch:

    const requestInit =  { credentials: 'include', redirect: 'manual', mode: 'cors' };
    this.transport = new StreamableHTTPClientTransport("https://some-mcp-server", requestInit,
      fetch: (input: RequestInfo | URL, _: RequestInit): Promise<Response> => {
         return fetch(input,  requestInit).
        })
    });

Breaking Changes

No, it is possible that users may have implemented a similar workaround but their workaround will still override the default init options in that case.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

None

@DW8Reaper DW8Reaper requested review from a team and felixweinberger August 22, 2025 02:28
@DW8Reaper DW8Reaper changed the title fix: client sss start include requestInit options (modelcontextprotocol#895) fix: client initial GET sse include requestInit (modelcontextprotocol#895) Aug 22, 2025
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.

1 participant