Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ type Client struct {
// NewClient creates a new MCP client with the given transport.
// Usage:
//
// client, err := NewClient(transport.NewStdio("mcp", nil, "--stdio"))
// stdio := transport.NewStdio("./mcp_server", nil, "xxx")
// client, err := NewClient(stdio)
// if err != nil {
// log.Fatalf("Failed to create client: %v", err)
// log.Fatalf("Failed to create client: %v", err)
// }
func NewClient(transport transport.Interface) *Client {
return &Client{
Expand Down
2 changes: 1 addition & 1 deletion client/sse.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func NewSSEMCPClient(baseURL string, options ...transport.ClientOption) (*Client

// GetEndpoint returns the current endpoint URL for the SSE connection.
//
// Note: This method only works with SSE transport.
// Note: This method only works with SSE transport, or it will panic.
func GetEndpoint(c *Client) *url.URL {
t := c.GetTransport()
sse := t.(*transport.SSE)
Expand Down
2 changes: 1 addition & 1 deletion client/stdio.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func NewStdioMCPClient(
// GetStderr returns a reader for the stderr output of the subprocess.
// This can be used to capture error messages or logs from the subprocess.
//
// Note: This method only works with stdio transport.
// Note: This method only works with stdio transport, or it will panic.
func GetStderr(c *Client) io.Reader {
t := c.GetTransport()
stdio := t.(*transport.Stdio)
Expand Down
5 changes: 5 additions & 0 deletions client/transport/sse.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ func (c *SSE) Start(ctx context.Context) error {
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 {
return fmt.Errorf("failed to connect to SSE stream: %w", err)
Expand Down