Pass headers to SSE (fixes #2705) (#4148)

* Pass headers to SSE

* Add changeset
This commit is contained in:
Matt Rubens 2025-05-30 15:34:19 -04:00 committed by GitHub
parent dabb95f2df
commit 116a50f7b4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 0 deletions

View file

@ -0,0 +1,5 @@
---
"roo-cline": patch
---
Correctly pass headers to SSE MCP

View file

@ -518,6 +518,13 @@ export class McpHub {
const reconnectingEventSourceOptions = {
max_retry_time: 5000, // Maximum retry time in milliseconds
withCredentials: configInjected.headers?.["Authorization"] ? true : false, // Enable credentials if Authorization header exists
fetch: (url: string | URL, init: RequestInit) => {
const headers = new Headers({ ...(init?.headers || {}), ...(configInjected.headers || {}) })
return fetch(url, {
...init,
headers,
})
},
}
global.EventSource = ReconnectingEventSource
transport = new SSEClientTransport(new URL(configInjected.url), {