Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions client/sse.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,18 @@ func NewSSEMCPClient(baseURL string, options ...ClientOption) (*SSEMCPClient, er
// Start initiates the SSE connection to the server and waits for the endpoint information.
// Returns an error if the connection fails or times out waiting for the endpoint.
func (c *SSEMCPClient) Start(ctx context.Context) error {

req, err := http.NewRequestWithContext(ctx, "GET", c.baseURL.String(), nil)

if err != nil {

return fmt.Errorf("failed to create request: %w", err)

}

req.Header.Set("Accept", "text/event-stream")
req.Header.Set("Cache-Control", "no-cache")
req.Header.Set("Connection", "keep-alive")
// set custom http headers
for k, v := range c.headers {
req.Header.Set(k, v)
}

resp, err := c.httpClient.Do(req)
if err != nil {
Expand Down Expand Up @@ -391,6 +391,10 @@ func (c *SSEMCPClient) Initialize(
}

req.Header.Set("Content-Type", "application/json")
// set custom http headers
for k, v := range c.headers {
req.Header.Set(k, v)
}

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