Skip to content

Commit 3670e87

Browse files
committed
fix(client): fix(client): set custom HTTP headers for start and init calls
1 parent a0e968a commit 3670e87

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

client/sse.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,18 @@ func NewSSEMCPClient(baseURL string, options ...ClientOption) (*SSEMCPClient, er
8181
// Start initiates the SSE connection to the server and waits for the endpoint information.
8282
// Returns an error if the connection fails or times out waiting for the endpoint.
8383
func (c *SSEMCPClient) Start(ctx context.Context) error {
84-
8584
req, err := http.NewRequestWithContext(ctx, "GET", c.baseURL.String(), nil)
86-
8785
if err != nil {
88-
8986
return fmt.Errorf("failed to create request: %w", err)
90-
9187
}
9288

9389
req.Header.Set("Accept", "text/event-stream")
9490
req.Header.Set("Cache-Control", "no-cache")
9591
req.Header.Set("Connection", "keep-alive")
92+
// set custom http headers
93+
for k, v := range c.headers {
94+
req.Header.Set(k, v)
95+
}
9696

9797
resp, err := c.httpClient.Do(req)
9898
if err != nil {
@@ -391,6 +391,10 @@ func (c *SSEMCPClient) Initialize(
391391
}
392392

393393
req.Header.Set("Content-Type", "application/json")
394+
// set custom http headers
395+
for k, v := range c.headers {
396+
req.Header.Set(k, v)
397+
}
394398

395399
resp, err := c.httpClient.Do(req)
396400
if err != nil {

0 commit comments

Comments
 (0)